You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2020/08/10 05:56:05 UTC

[GitHub] [incubator-doris] wuyunfeng commented on a change in pull request #4300: fix doc value field NullPointerException

wuyunfeng commented on a change in pull request #4300:
URL: https://github.com/apache/incubator-doris/pull/4300#discussion_r467699429



##########
File path: fe/fe-core/src/test/java/org/apache/doris/external/elasticsearch/MappingPhaseTest.java
##########
@@ -102,4 +103,13 @@ public void testWorkFlow(@Injectable EsRestClient client) throws Exception{
         assertEquals("k2", searchContext1.docValueFieldsContext().get("k2"));
 
     }
+
+    @Test
+    public void testFieldMultAnalyzer() throws Exception {

Review comment:
       ```suggestion
       public void testMultTextFields() throws Exception {
   ```

##########
File path: fe/fe-core/src/test/java/org/apache/doris/external/elasticsearch/MappingPhaseTest.java
##########
@@ -102,4 +103,13 @@ public void testWorkFlow(@Injectable EsRestClient client) throws Exception{
         assertEquals("k2", searchContext1.docValueFieldsContext().get("k2"));
 
     }
+
+    @Test
+    public void testFieldMultAnalyzer() throws Exception {
+        MappingPhase mappingPhase = new MappingPhase(null);
+        EsTable esTableAfter7X = fakeEsTable("fake", "test", "_doc", columns);
+        SearchContext searchContext = new SearchContext(esTableAfter7X);
+        mappingPhase.resolveFields(searchContext, loadJsonFromFile("data/es/test_index_mapping_field_mult_analyzer.json"));
+        assertFalse(searchContext.docValueFieldsContext().containsKey("k3"));
+    }
 }

Review comment:
       add blank new line

##########
File path: fe/fe-core/src/main/java/org/apache/doris/external/elasticsearch/MappingPhase.java
##########
@@ -17,6 +17,7 @@
 
 package org.apache.doris.external.elasticsearch;
 
+import org.apache.commons.lang3.StringUtils;

Review comment:
       import order is not right

##########
File path: fe/fe-core/src/test/resources/data/es/test_index_mapping_field_mult_analyzer.json
##########
@@ -0,0 +1,23 @@
+{
+  "test": {
+    "mappings": {
+      "properties": {
+        "k1": {
+          "type": "long"
+        },
+        "k2": {
+          "type": "keyword"
+        },
+        "k3": {
+          "type": "text",
+          "fields": {
+            "ik": {
+              "type": "text",
+              "analyzer": "ik_max_word"
+            }
+          }
+        }
+      }
+    }
+  }
+}

Review comment:
       add blank new line

##########
File path: fe/fe-core/src/main/java/org/apache/doris/external/elasticsearch/MappingPhase.java
##########
@@ -156,6 +157,8 @@ private void resolveDocValuesFields(SearchContext searchContext, JSONObject fiel
             }
             docValueField = colName;
         }
-        searchContext.docValueFieldsContext().put(colName, docValueField);
+        if (StringUtils.isNotEmpty(docValueField)) {

Review comment:
       Can you add some comments for what you resolved




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org