This is an automated email from the ASF dual-hosted git repository.

yiguolei pushed a commit to branch branch-4.0
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-4.0 by this push:
     new ce72b33eef2 branch-4.0: [fix](search) Validate mode parameter in 
search() DSL options #60785 (#60813)
ce72b33eef2 is described below

commit ce72b33eef26896c90c8ac2cf7d0ab4d5096cf3b
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Wed Feb 25 14:15:27 2026 +0800

    branch-4.0: [fix](search) Validate mode parameter in search() DSL options 
#60785 (#60813)
    
    Cherry-picked from #60785
    
    Co-authored-by: Jack <[email protected]>
---
 .../trees/expressions/functions/scalar/SearchDslParser.java  | 10 ++++++++++
 .../expressions/functions/scalar/SearchDslParserTest.java    | 12 ++++++++++++
 2 files changed, 22 insertions(+)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/SearchDslParser.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/SearchDslParser.java
index 82cbdcdf240..2f072c60489 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/SearchDslParser.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/SearchDslParser.java
@@ -1779,12 +1779,22 @@ public class SearchDslParser {
         /**
          * Validate the options after deserialization.
          * Checks for:
+         * - mode is "standard" or "lucene"
          * - Mutual exclusion between fields and default_field
          * - minimum_should_match is non-negative if specified
          *
          * @throws IllegalArgumentException if validation fails
          */
         public void validate() {
+            // Validation: mode must be "standard" or "lucene"
+            if (mode != null) {
+                String normalizedMode = mode.trim().toLowerCase();
+                if (!"standard".equals(normalizedMode) && 
!"lucene".equals(normalizedMode)) {
+                    throw new IllegalArgumentException(
+                            "'mode' must be 'standard' or 'lucene', got: " + 
mode);
+                }
+                this.mode = normalizedMode;
+            }
             // Validation: fields and default_field are mutually exclusive
             if (fields != null && !fields.isEmpty()
                     && defaultField != null && !defaultField.isEmpty()) {
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/expressions/functions/scalar/SearchDslParserTest.java
 
b/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/expressions/functions/scalar/SearchDslParserTest.java
index e45790b4efb..0859106b149 100644
--- 
a/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/expressions/functions/scalar/SearchDslParserTest.java
+++ 
b/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/expressions/functions/scalar/SearchDslParserTest.java
@@ -1301,6 +1301,18 @@ public class SearchDslParserTest {
         });
     }
 
+    @Test
+    public void testInvalidMode() {
+        // Test: invalid mode value should throw exception
+        String dsl = "hello";
+        String options = 
"{\"default_field\":\"title\",\"mode\":\"lucenedfafa\"}";
+
+        IllegalArgumentException exception = 
Assertions.assertThrows(IllegalArgumentException.class, () -> {
+            SearchDslParser.parseDsl(dsl, options);
+        });
+        Assertions.assertTrue(exception.getMessage().contains("'mode' must be 
'standard' or 'lucene'"));
+    }
+
     @Test
     public void testMultiFieldSingleTermSameResultForBothTypes() {
         // Test: single term should have same structure for both types


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to