public static final String TYPE = "type";
public static final String INDEX = "index";
- public static final String ANALYZED = "analyzed";
+ public static final String INDEX_SEARCHABLE_FOR_TEXT = "analyzed"; // ES 5: remove this constant and replace usages with INDEX_SEARCHABLE
+ public static final String INDEX_SEARCHABLE_FOR_KEYWORD = "not_analyzed"; // ES 5: change to true and rename to INDEX_SEARCHABLE
+ public static final String INDEX_NOT_SEARCHABLE = "no"; // ES 5: change to false
public static final String FIELD_TYPE_TEXT = "string"; // ES 5: change to text
public static final String FIELD_TYPE_KEYWORD = "string"; // ES 5: change to keyword
public static final String STANDARD = "standard";
import org.elasticsearch.common.settings.Settings.Builder;
import static org.sonar.server.es.DefaultIndexSettings.ANALYSIS;
-import static org.sonar.server.es.DefaultIndexSettings.ANALYZED;
import static org.sonar.server.es.DefaultIndexSettings.ANALYZER;
import static org.sonar.server.es.DefaultIndexSettings.ASCIIFOLDING;
import static org.sonar.server.es.DefaultIndexSettings.DELIMITER;
import static org.sonar.server.es.DefaultIndexSettings.FIELD_TYPE_TEXT;
import static org.sonar.server.es.DefaultIndexSettings.FILTER;
import static org.sonar.server.es.DefaultIndexSettings.INDEX;
+import static org.sonar.server.es.DefaultIndexSettings.INDEX_SEARCHABLE_FOR_TEXT;
import static org.sonar.server.es.DefaultIndexSettings.KEYWORD;
import static org.sonar.server.es.DefaultIndexSettings.LOWERCASE;
import static org.sonar.server.es.DefaultIndexSettings.MAXIMUM_NGRAM_LENGTH;
public SortedMap<String, String> fieldMapping() {
return ImmutableSortedMap.of(
TYPE, FIELD_TYPE_TEXT,
- INDEX, ANALYZED,
+ INDEX, INDEX_SEARCHABLE_FOR_TEXT,
ANALYZER, getName());
}
},
public SortedMap<String, String> fieldMapping() {
return ImmutableSortedMap.of(
TYPE, FIELD_TYPE_TEXT,
- INDEX, ANALYZED,
+ INDEX, INDEX_SEARCHABLE_FOR_TEXT,
ANALYZER, INDEX_GRAMS_ANALYZER.getName(),
SEARCH_ANALYZER, getName());
}
public SortedMap<String, String> fieldMapping() {
return ImmutableSortedMap.of(
TYPE, FIELD_TYPE_TEXT,
- INDEX, ANALYZED,
+ INDEX, INDEX_SEARCHABLE_FOR_TEXT,
ANALYZER, INDEX_PREFIX_ANALYZER.getName(),
SEARCH_ANALYZER, getName());
}
public SortedMap<String, String> fieldMapping() {
return ImmutableSortedMap.of(
TYPE, FIELD_TYPE_TEXT,
- INDEX, ANALYZED,
+ INDEX, INDEX_SEARCHABLE_FOR_TEXT,
ANALYZER, INDEX_PREFIX_CASE_INSENSITIVE_ANALYZER.getName(),
SEARCH_ANALYZER, getName());
}
public SortedMap<String, String> fieldMapping() {
return ImmutableSortedMap.of(
TYPE, FIELD_TYPE_TEXT,
- INDEX, ANALYZED,
+ INDEX, INDEX_SEARCHABLE_FOR_TEXT,
ANALYZER, USER_INDEX_GRAMS_ANALYZER.getName(),
SEARCH_ANALYZER, getName());
}
public SortedMap<String, String> fieldMapping() {
return ImmutableSortedMap.of(
TYPE, FIELD_TYPE_TEXT,
- INDEX, ANALYZED,
+ INDEX, INDEX_SEARCHABLE_FOR_TEXT,
ANALYZER, INDEX_WORDS_ANALYZER.getName(),
SEARCH_ANALYZER, getName());
}
import static com.google.common.base.Preconditions.checkArgument;
import static java.lang.String.format;
-import static org.sonar.server.es.DefaultIndexSettings.ANALYZED;
import static org.sonar.server.es.DefaultIndexSettings.ANALYZER;
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;
+import static org.sonar.server.es.DefaultIndexSettings.INDEX_NOT_SEARCHABLE;
+import static org.sonar.server.es.DefaultIndexSettings.INDEX_SEARCHABLE_FOR_KEYWORD;
+import static org.sonar.server.es.DefaultIndexSettings.INDEX_SEARCHABLE_FOR_TEXT;
import static org.sonar.server.es.DefaultIndexSettings.TYPE;
import static org.sonar.server.es.DefaultIndexSettingsElement.UUID_MODULE_ANALYZER;
public NewIndexType createUuidPathField(String fieldName) {
return setProperty(fieldName, ImmutableSortedMap.of(
TYPE, FIELD_TYPE_TEXT,
- INDEX, ANALYZED,
+ INDEX, INDEX_SEARCHABLE_FOR_TEXT,
ANALYZER, UUID_MODULE_ANALYZER.getName()));
}
* By default field is "not_analyzed": it is searchable, but index the value exactly
* as specified.
*/
+ // ES 5: update javadoc to:
+ /*
+ * "index: false" -> Make this field not searchable.
+ * By default field is "true": it is searchable, but index the value exactly
+ * as specified.
+ */
public KeywordFieldBuilder disableSearch() {
this.disableSearch = true;
return this;
if (subFields.isEmpty()) {
hash.putAll(ImmutableMap.of(
"type", FIELD_TYPE_KEYWORD,
- "index", disableSearch ? "no" : "not_analyzed", // ES 5: change to false and true
+ "index", disableSearch ? INDEX_NOT_SEARCHABLE : INDEX_SEARCHABLE_FOR_KEYWORD,
"norms", ImmutableMap.of("enabled", String.valueOf(!disableNorms))));
} else {
hash.put("type", "multi_field");
multiFields.put(fieldName, ImmutableMap.of(
"type", FIELD_TYPE_KEYWORD,
- "index", "not_analyzed", // ES 5: change to true
+ "index", INDEX_SEARCHABLE_FOR_KEYWORD,
"term_vector", termVectorWithPositionOffsets ? "with_positions_offsets" : "no",
"norms", ImmutableMap.of("enabled", "false")));
public NestedFieldBuilder addKeywordField(String fieldName) {
return setProperty(fieldName, ImmutableMap.of(
"type", FIELD_TYPE_KEYWORD,
- "index", "not_analyzed"));
+ "index", INDEX_SEARCHABLE_FOR_KEYWORD));
}
public NestedFieldBuilder addDoubleField(String fieldName) {
ruleMapping.keywordFieldBuilder(FIELD_RULE_NAME).addSubFields(SORTABLE_ANALYZER, SEARCH_WORDS_ANALYZER).build();
ruleMapping.setProperty(FIELD_RULE_HTML_DESCRIPTION, ImmutableSortedMap.of(
DefaultIndexSettings.TYPE, DefaultIndexSettings.FIELD_TYPE_TEXT,
- DefaultIndexSettings.INDEX, DefaultIndexSettings.ANALYZED,
+ DefaultIndexSettings.INDEX, DefaultIndexSettings.INDEX_SEARCHABLE_FOR_TEXT,
DefaultIndexSettings.ANALYZER, ENGLISH_HTML_ANALYZER.getName(),
DefaultIndexSettings.SEARCH_ANALYZER, ENGLISH_HTML_ANALYZER.getName()));
ruleMapping.keywordFieldBuilder(FIELD_RULE_SEVERITY).disableNorms().build();
import org.sonar.server.es.NewIndex;
import static org.sonar.server.es.DefaultIndexSettings.FIELD_TYPE_KEYWORD;
+import static org.sonar.server.es.DefaultIndexSettings.INDEX_SEARCHABLE_FOR_KEYWORD;
public class TestIndexDefinition implements IndexDefinition {
mapping.keywordFieldBuilder(FIELD_MESSAGE).disableNorms().disableSearch().build();
mapping.keywordFieldBuilder(FIELD_STACKTRACE).disableNorms().disableSearch().build();
mapping.setProperty(FIELD_COVERED_FILES, ImmutableMap.of("type", "nested", "properties", ImmutableMap.of(
- FIELD_COVERED_FILE_UUID, ImmutableMap.of("type", FIELD_TYPE_KEYWORD, "index", "not_analyzed"),
+ FIELD_COVERED_FILE_UUID, ImmutableMap.of("type", FIELD_TYPE_KEYWORD, "index", INDEX_SEARCHABLE_FOR_KEYWORD),
FIELD_COVERED_FILE_LINES, ImmutableMap.of("type", "integer"))));
mapping.createDateTimeField(FIELD_UPDATED_AT);
}
Map<String, Object> props = (Map) mapping.getProperty("basic_field");
assertThat(props.get("type")).isEqualTo("string");// ES 5: change to keyword
- assertThat(props.get("index")).isEqualTo("not_analyzed");
+ assertThat(props.get("index")).isEqualTo("not_analyzed");// ES 5: change to true
assertThat(props.get("fields")).isNull();
props = (Map) mapping.getProperty("not_searchable_field");
assertThat(props.get("type")).isEqualTo("string");// ES 5: change to keyword
- assertThat(props.get("index")).isEqualTo("no");
+ assertThat(props.get("index")).isEqualTo("no");// ES 5: change to false
assertThat(props.get("fields")).isNull();
props = (Map) mapping.getProperty("all_capabilities_field");