]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-8798 term_vector must be enabled for hightlighting on field too
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Mon, 17 Jul 2017 09:42:10 +0000 (11:42 +0200)
committerDaniel Schwarz <bartfastiel@users.noreply.github.com>
Wed, 9 Aug 2017 13:09:54 +0000 (15:09 +0200)
and not only on searcheable subfields

server/sonar-server/src/main/java/org/sonar/server/component/index/ComponentIndexDefinition.java
server/sonar-server/src/main/java/org/sonar/server/es/DefaultIndexSettings.java
server/sonar-server/src/main/java/org/sonar/server/es/NewIndex.java

index 2f77d3a5f5330694f7c79f7d7ea4fe37fc49713d..8cf458879bbc45f8d9e14df48c2ba2ab3fa1371a 100644 (file)
@@ -63,7 +63,7 @@ public class ComponentIndexDefinition implements IndexDefinition {
     mapping.keywordFieldBuilder(FIELD_KEY).addSubFields(SORTABLE_ANALYZER).build();
     mapping.textFieldBuilder(FIELD_NAME)
       .withFieldData()
-      .termVectorWithPositionOffsetsForAllSubfields()
+      .termVectorWithPositionOffsets()
       .addSubFields(NAME_ANALYZERS)
       .build();
 
index baf7959c3b4a76a7ffe41fff0c6fbe595ebe5db0..71d272340258e40ea1daf17763ec77f38fe0e002 100644 (file)
@@ -50,6 +50,7 @@ public class DefaultIndexSettings {
   public static final String FIELD_TYPE_KEYWORD = "keyword";
   public static final String FIELD_FIELDDATA = "fielddata";
   public static final String FIELDDATA_ENABLED = "true";
+  public static final String FIELD_TERM_VECTOR = "term_vector";
   public static final String STANDARD = "standard";
   public static final String PATTERN = "pattern";
   public static final String CUSTOM = "custom";
index cc672e4345ab633d84dcd00cebd5551f9822c5f4..8ac99bc3bb238153300acc9b0a467a32579ed7ff 100644 (file)
@@ -41,6 +41,7 @@ import static java.lang.String.format;
 import static org.sonar.server.es.DefaultIndexSettings.ANALYZER;
 import static org.sonar.server.es.DefaultIndexSettings.FIELDDATA_ENABLED;
 import static org.sonar.server.es.DefaultIndexSettings.FIELD_FIELDDATA;
+import static org.sonar.server.es.DefaultIndexSettings.FIELD_TERM_VECTOR;
 import static org.sonar.server.es.DefaultIndexSettings.FIELD_TYPE_KEYWORD;
 import static org.sonar.server.es.DefaultIndexSettings.FIELD_TYPE_TEXT;
 import static org.sonar.server.es.DefaultIndexSettings.INDEX;
@@ -248,7 +249,7 @@ public class NewIndex {
     /**
      * Position offset term vectors are required for the fast_vector_highlighter (fvh).
      */
-    public StringFieldBuilder termVectorWithPositionOffsetsForAllSubfields() {
+    public StringFieldBuilder termVectorWithPositionOffsets() {
       this.termVectorWithPositionOffsets = true;
       return this;
     }
@@ -289,11 +290,12 @@ public class NewIndex {
             Object subFieldMapping = entry.getValue();
             if (subFieldMapping instanceof Map) {
               entry.setValue(
-                  addFieldToMapping(
-                      (Map<String, String>) subFieldMapping,
-                      "term_vector", "with_positions_offsets"));
+                addFieldToMapping(
+                  (Map<String, String>) subFieldMapping,
+                  FIELD_TERM_VECTOR, "with_positions_offsets"));
             }
           });
+          hash.put(FIELD_TERM_VECTOR, "with_positions_offsets");
         }
         if (getFieldData()) {
           multiFields.entrySet().forEach(entry -> {