@Test public void of() { IndexDefinition.Index indexV1 = new IndexDefinition.Index(createIndex()); String hashV1 = IndexDefinitionHash.of(indexV1); assertThat(hashV1).isNotEmpty(); // always the same assertThat(hashV1).isEqualTo(IndexDefinitionHash.of(indexV1)); NewIndex newIndexV2 = createIndex(); newIndexV2.getTypes().get("fake").createIntegerField("max"); String hashV2 = IndexDefinitionHash.of(new IndexDefinition.Index(newIndexV2)); assertThat(hashV2).isNotEmpty().isNotEqualTo(hashV1); }
@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, newBuilder(new MapSettings().asConfig()).build()); index.getSettings().put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, replicas); index.getSettings().put("index.refresh_interval", "-1"); NewIndex.NewIndexType type = index.createType(INDEX_TYPE_FAKE.getType()); type.createIntegerField(INT_FIELD); }
type.keywordFieldBuilder(FIELD_ISSUE_KEY).disableNorms().addSubFields(SORTABLE_ANALYZER).build(); type.keywordFieldBuilder(FIELD_ISSUE_LANGUAGE).disableNorms().build(); type.createIntegerField(FIELD_ISSUE_LINE); type.keywordFieldBuilder(FIELD_ISSUE_MODULE_UUID).disableNorms().build(); type.createUuidPathField(FIELD_ISSUE_MODULE_PATH);
type.keywordFieldBuilder(FIELD_ISSUE_KEY).disableNorms().addSubFields(SORTABLE_ANALYZER).build(); type.keywordFieldBuilder(FIELD_ISSUE_LANGUAGE).disableNorms().build(); type.createIntegerField(FIELD_ISSUE_LINE); type.keywordFieldBuilder(FIELD_ISSUE_MODULE_UUID).disableNorms().build(); type.createUuidPathField(FIELD_ISSUE_MODULE_PATH);
@Override public void define(IndexDefinitionContext context) { NewIndex index = context.create("fakes", SETTINGS_CONFIGURATION); NewIndex.NewIndexType mapping = index.createType("fake"); mapping.keywordFieldBuilder("key").build(); mapping.createDateTimeField("updatedAt"); mapping.createIntegerField("newField"); } }