public NewIndexType createDateTimeField(String fieldName) { Map<String, String> hash = new TreeMap<>(); hash.put("type", "date"); hash.put("format", "date_time||epoch_second"); return 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); }
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 NewIndexType createShortField(String fieldName) { return setProperty(fieldName, ImmutableMap.of("type", "short")); }
public NewIndexType createIntegerField(String fieldName) { return setProperty(fieldName, ImmutableMap.of("type", "integer")); }
public NewIndexType createUuidPathField(String fieldName) { return setProperty(fieldName, ImmutableSortedMap.of( TYPE, FIELD_TYPE_TEXT, INDEX, DefaultIndexSettings.INDEX_SEARCHABLE, ANALYZER, UUID_MODULE_ANALYZER.getName())); }
public NewIndexType createDateTimeField(String fieldName) { Map<String, String> hash = new TreeMap<>(); hash.put("type", "date"); hash.put("format", "date_time||epoch_second"); return setProperty(fieldName, hash); }
public NewIndexType createBooleanField(String fieldName) { return setProperty(fieldName, ImmutableMap.of("type", "boolean")); }
public NewIndexType build() { checkArgument(!properties.isEmpty(), "At least one sub-field must be declared in nested property '%s'", fieldName); return indexType.setProperty(fieldName, ImmutableSortedMap.of( "type", "nested", "properties", properties)); } }
@Test public void define_fields() { NewIndex index = new NewIndex("issues", defaultSettingsConfiguration); NewIndex.NewIndexType mapping = index.createType("issue"); mapping.setAttribute("dynamic", "true"); mapping.setProperty("foo_field", ImmutableMap.of("type", "keyword")); mapping.createBooleanField("boolean_field"); mapping.createByteField("byte_field"); mapping.createDateTimeField("dt_field"); mapping.createDoubleField("double_field"); mapping.createIntegerField("int_field"); mapping.createLongField("long_field"); mapping.createShortField("short_field"); mapping.createUuidPathField("uuid_path_field"); mapping = index.getTypes().get("issue"); assertThat(mapping).isNotNull(); assertThat(mapping.getAttributes().get("dynamic")).isEqualTo("true"); assertThat(mapping.getProperty("foo_field")).isInstanceOf(Map.class); assertThat((Map) mapping.getProperty("foo_field")).containsEntry("type", "keyword"); assertThat((Map) mapping.getProperty("byte_field")).isNotEmpty(); assertThat((Map) mapping.getProperty("double_field")).isNotEmpty(); assertThat((Map) mapping.getProperty("dt_field")).isNotEmpty(); assertThat((Map) mapping.getProperty("int_field")).containsEntry("type", "integer"); assertThat((Map) mapping.getProperty("long_field")).isNotEmpty(); assertThat((Map) mapping.getProperty("short_field")).isNotEmpty(); assertThat((Map) mapping.getProperty("uuid_path_field")).isNotEmpty(); assertThat((Map) mapping.getProperty("unknown")).isNull(); }
@Override public void define(IndexDefinitionContext context) { NewIndex index = context.create( INDEX_TYPE_TEST.getIndex(), newBuilder(config) .setRefreshInterval(MANUAL_REFRESH_INTERVAL) .setDefaultNbOfShards(5) .build()); NewIndex.NewIndexType mapping = index.createType(INDEX_TYPE_TEST.getType()); mapping.setAttribute("_routing", ImmutableMap.of("required", true)); mapping.keywordFieldBuilder(FIELD_PROJECT_UUID).disableNorms().build(); mapping.keywordFieldBuilder(FIELD_FILE_UUID).disableNorms().build(); mapping.keywordFieldBuilder(FIELD_TEST_UUID).disableNorms().build(); mapping.keywordFieldBuilder(FIELD_NAME).disableNorms().disableSearch().disableSortingAndAggregating().build(); mapping.keywordFieldBuilder(FIELD_STATUS).disableNorms().disableSearch().build(); mapping.createLongField(FIELD_DURATION_IN_MS); mapping.keywordFieldBuilder(FIELD_MESSAGE).disableNorms().disableSearch().disableSortingAndAggregating().build(); mapping.keywordFieldBuilder(FIELD_STACKTRACE).disableNorms().disableSearch().disableSortingAndAggregating().build(); mapping.setProperty(FIELD_COVERED_FILES, ImmutableMap.of("type", "nested", "properties", ImmutableMap.of( FIELD_COVERED_FILE_UUID, ImmutableMap.of("type", FIELD_TYPE_KEYWORD, "index", INDEX_SEARCHABLE), FIELD_COVERED_FILE_LINES, ImmutableMap.of("type", "integer")))); mapping.createDateTimeField(FIELD_UPDATED_AT); } }
public NewIndexType createBooleanField(String fieldName) { return setProperty(fieldName, ImmutableMap.of("type", "boolean")); }
public NewIndexType createLongField(String fieldName) { return setProperty(fieldName, ImmutableMap.of("type", "long")); }
public NewIndexType createIntegerField(String fieldName) { return setProperty(fieldName, ImmutableMap.of("type", "integer")); }
public NewIndexType createShortField(String fieldName) { return setProperty(fieldName, ImmutableMap.of("type", "short")); }
public NewIndexType createByteField(String fieldName) { return setProperty(fieldName, ImmutableMap.of("type", "byte")); }
public NewIndexType createDoubleField(String fieldName) { return setProperty(fieldName, ImmutableMap.of("type", "double")); }
public NewIndexType createUuidPathField(String fieldName) { return setProperty(fieldName, ImmutableSortedMap.of( TYPE, FIELD_TYPE_TEXT, INDEX, DefaultIndexSettings.INDEX_SEARCHABLE, ANALYZER, UUID_MODULE_ANALYZER.getName())); }
public NewIndexType build() { checkArgument(!properties.isEmpty(), "At least one sub-field must be declared in nested property '%s'", fieldName); return indexType.setProperty(fieldName, ImmutableSortedMap.of( "type", "nested", "properties", properties)); } }