/** * Add subfields, one for each analyzer. */ public T addSubFields(DefaultIndexSettingsElement... analyzers) { Arrays.stream(analyzers) .forEach(analyzer -> addSubField(analyzer.getSubFieldSuffix(), analyzer.fieldMapping())); return castThis(); }
public NewIndexType build() { if (subFields.isEmpty()) { return buildWithoutSubfields(); } return buildWithSubfields(); }
private Map<String, Object> configureSubFields() { Map<String, Object> multiFields = new TreeMap<>(subFields); // apply this fields configuration to all subfields multiFields.entrySet().forEach(entry -> { Object subFieldMapping = entry.getValue(); if (subFieldMapping instanceof Map) { entry.setValue(configureSubField((Map<String, String>) subFieldMapping)); } }); return multiFields; }
@Override public void define(IndexDefinitionContext context) { NewIndex index = context.create( INDEX_TYPE_COMPONENT.getIndex(), newBuilder(config) .setRefreshInterval(MANUAL_REFRESH_INTERVAL) .setDefaultNbOfShards(DEFAULT_NUMBER_OF_SHARDS) .build()); NewIndex.NewIndexType mapping = index.createType(INDEX_TYPE_COMPONENT.getType()) .requireProjectAuthorization(); mapping.keywordFieldBuilder(FIELD_UUID).disableNorms().build(); mapping.keywordFieldBuilder(FIELD_PROJECT_UUID).disableNorms().build(); mapping.keywordFieldBuilder(FIELD_KEY).addSubFields(SORTABLE_ANALYZER).build(); mapping.textFieldBuilder(FIELD_NAME) .withFieldData() .termVectorWithPositionOffsets() .addSubFields(NAME_ANALYZERS) .build(); mapping.keywordFieldBuilder(FIELD_QUALIFIER).build(); mapping.keywordFieldBuilder(FIELD_LANGUAGE).disableNorms().build(); mapping.keywordFieldBuilder(FIELD_ORGANIZATION_UUID).disableNorms().build(); } }
private NewIndexType buildWithSubfields() { Map<String, Object> hash = new TreeMap<>(); hash.put("type", getFieldType()); hash.put(INDEX, disableSearch ? INDEX_NOT_SEARCHABLE : INDEX_SEARCHABLE); hash.put(NORMS, "false"); hash.put(STORE, valueOf(store)); if (FIELD_TYPE_KEYWORD.equals(getFieldType())) { hash.put("doc_values", valueOf(!disabledDocValues)); } if (getFieldData()) { hash.put(FIELD_FIELDDATA, FIELDDATA_ENABLED); } if (termVectorWithPositionOffsets) { hash.put(FIELD_TERM_VECTOR, "with_positions_offsets"); } hash.put("fields", configureSubFields()); return indexType.setProperty(fieldName, hash); }
private NewIndexType buildWithoutSubfields() { Map<String, Object> hash = new TreeMap<>(); hash.put("type", getFieldType()); hash.put(INDEX, disableSearch ? INDEX_NOT_SEARCHABLE : INDEX_SEARCHABLE); hash.put(NORMS, valueOf(!disableNorms)); hash.put(STORE, valueOf(store)); if (FIELD_TYPE_KEYWORD.equals(getFieldType())) { hash.put("doc_values", valueOf(!disabledDocValues)); } if (getFieldData()) { hash.put(FIELD_FIELDDATA, FIELDDATA_ENABLED); } return indexType.setProperty(fieldName, hash); }
public T store() { this.store = true; return castThis(); }
/** * Position offset term vectors are required for the fast_vector_highlighter (fvh). */ public T termVectorWithPositionOffsets() { this.termVectorWithPositionOffsets = true; return castThis(); }
/** * Norms consume useless memory if string field is used for filtering or aggregations. * * https://www.elastic.co/guide/en/elasticsearch/reference/2.3/norms.html * https://www.elastic.co/guide/en/elasticsearch/guide/current/scoring-theory.html#field-norm */ public T disableNorms() { this.disableNorms = true; return castThis(); }
/** * "index: false" -> Make this field not searchable. * By default field is "true": it is searchable, but index the value exactly * as specified. */ public T disableSearch() { this.disableSearch = true; return castThis(); }
/** * Add subfields, one for each analyzer. */ public T addSubFields(DefaultIndexSettingsElement... analyzers) { Arrays.stream(analyzers) .forEach(analyzer -> addSubField(analyzer.getSubFieldSuffix(), analyzer.fieldMapping())); return castThis(); }
private Map<String, Object> configureSubFields() { Map<String, Object> multiFields = new TreeMap<>(subFields); // apply this fields configuration to all subfields multiFields.entrySet().forEach(entry -> { Object subFieldMapping = entry.getValue(); if (subFieldMapping instanceof Map) { entry.setValue(configureSubField((Map<String, String>) subFieldMapping)); } }); return multiFields; }
/** * Add a sub-field. A {@code SortedMap} is required for consistency of the index settings hash. * @see IndexDefinitionHash */ private T addSubField(String fieldName, SortedMap<String, String> fieldDefinition) { subFields.put(fieldName, fieldDefinition); return castThis(); }
public NewIndexType build() { if (subFields.isEmpty()) { return buildWithoutSubfields(); } return buildWithSubfields(); }
@Override public void define(IndexDefinitionContext context) { NewIndex index = context.create( INDEX_TYPE_COMPONENT.getIndex(), newBuilder(config) .setRefreshInterval(MANUAL_REFRESH_INTERVAL) .setDefaultNbOfShards(DEFAULT_NUMBER_OF_SHARDS) .build()); NewIndex.NewIndexType mapping = index.createType(INDEX_TYPE_COMPONENT.getType()) .requireProjectAuthorization(); mapping.keywordFieldBuilder(FIELD_UUID).disableNorms().build(); mapping.keywordFieldBuilder(FIELD_PROJECT_UUID).disableNorms().build(); mapping.keywordFieldBuilder(FIELD_KEY).addSubFields(SORTABLE_ANALYZER).build(); mapping.textFieldBuilder(FIELD_NAME) .withFieldData() .termVectorWithPositionOffsets() .addSubFields(NAME_ANALYZERS) .build(); mapping.keywordFieldBuilder(FIELD_QUALIFIER).build(); mapping.keywordFieldBuilder(FIELD_LANGUAGE).disableNorms().build(); mapping.keywordFieldBuilder(FIELD_ORGANIZATION_UUID).disableNorms().build(); } }
private NewIndexType buildWithSubfields() { Map<String, Object> hash = new TreeMap<>(); hash.put("type", getFieldType()); hash.put(INDEX, disableSearch ? INDEX_NOT_SEARCHABLE : INDEX_SEARCHABLE); hash.put(NORMS, "false"); hash.put(STORE, valueOf(store)); if (FIELD_TYPE_KEYWORD.equals(getFieldType())) { hash.put("doc_values", valueOf(!disabledDocValues)); } if (getFieldData()) { hash.put(FIELD_FIELDDATA, FIELDDATA_ENABLED); } if (termVectorWithPositionOffsets) { hash.put(FIELD_TERM_VECTOR, "with_positions_offsets"); } hash.put("fields", configureSubFields()); return indexType.setProperty(fieldName, hash); }
private NewIndexType buildWithoutSubfields() { Map<String, Object> hash = new TreeMap<>(); hash.put("type", getFieldType()); hash.put(INDEX, disableSearch ? INDEX_NOT_SEARCHABLE : INDEX_SEARCHABLE); hash.put(NORMS, valueOf(!disableNorms)); hash.put(STORE, valueOf(store)); if (FIELD_TYPE_KEYWORD.equals(getFieldType())) { hash.put("doc_values", valueOf(!disabledDocValues)); } if (getFieldData()) { hash.put(FIELD_FIELDDATA, FIELDDATA_ENABLED); } return indexType.setProperty(fieldName, hash); }
public T store() { this.store = true; return castThis(); }
/** * "index: false" -> Make this field not searchable. * By default field is "true": it is searchable, but index the value exactly * as specified. */ public T disableSearch() { this.disableSearch = true; return castThis(); }
/** * Position offset term vectors are required for the fast_vector_highlighter (fvh). */ public T termVectorWithPositionOffsets() { this.termVectorWithPositionOffsets = true; return castThis(); }