public void define(IndexDefinitionContext context) { NewIndex index = context.create( INDEX_TYPE_METADATA.getIndex(), newBuilder(configuration) .setRefreshInterval(MANUAL_REFRESH_INTERVAL) .setDefaultNbOfShards(DEFAULT_NUMBER_OF_SHARDS) .build()); NewIndex.NewIndexType mapping = index.createType(INDEX_TYPE_METADATA.getType()); mapping.keywordFieldBuilder(FIELD_VALUE).disableSearch().store().build(); } }
@Override public void define(IndexDefinitionContext context) { NewIndex index = context.create( INDEX_TYPE_VIEW.getIndex(), newBuilder(config) .setDefaultNbOfShards(5) .build()); // type "view" NewIndex.NewIndexType mapping = index.createType(INDEX_TYPE_VIEW.getType()); mapping.keywordFieldBuilder(FIELD_UUID).disableNorms().build(); mapping.keywordFieldBuilder(FIELD_PROJECTS).disableNorms().build(); } }
@Override protected void configureModule() { add(new EsClientProvider()); add(EsClientStopper.class); } }
@Override public void define(IndexDefinitionContext context) { NewIndex index = context.create(FOO_INDEX, newBuilder(new MapSettings().asConfig()).setRefreshInterval(MANUAL_REFRESH_INTERVAL).build()); NewIndex.NewIndexType type = index.createType(FOO_TYPE) .requireProjectAuthorization(); type.keywordFieldBuilder(FIELD_NAME).build(); type.keywordFieldBuilder(FIELD_PROJECT_UUID).build(); } }
private NewIndex createIndex() { NewIndex newIndex = new NewIndex("fakes", newBuilder(new MapSettings().asConfig()).build()); NewIndex.NewIndexType mapping = newIndex.createType("fake"); mapping.setAttribute("list_attr", Arrays.asList("foo", "bar")); mapping.keywordFieldBuilder("key").build(); mapping.createDateTimeField("updatedAt"); return newIndex; }
@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"); } }
@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); }
/** * Delete all the documents matching the given search request. This method is blocking. * Index is refreshed, so docs are not searchable as soon as method is executed. * <p> * Note that the parameter indexType could be removed if progress logs are not needed. */ public static IndexingResult delete(EsClient client, IndexType indexType, SearchRequestBuilder searchRequest) { BulkIndexer bulk = new BulkIndexer(client, indexType, Size.REGULAR); bulk.start(); bulk.addDeletion(searchRequest); return bulk.stop(); }
@Override public void define(IndexDefinitionContext context) { NewIndex index = context.create(indexName, newBuilder(new MapSettings().asConfig()).build()); index.getSettings().put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0); index.getSettings().put("index.refresh_interval", "-1"); } }
@Test public void unsupported_types_are_kept_in_queue_for_manual_fix_operation() { insertItem(FOO_TYPE, "f1"); ResilientIndexer indexer = new SuccessfulFakeIndexer(new IndexType("bars", "bar")); advanceInTime(); underTest = newRecoveryIndexer(indexer); underTest.recover(); assertThatQueueHasSize(1); assertThatLogsContain(ERROR, "Elasticsearch recovery - ignore 1 items with unsupported type [foos/foo]"); }
public long countDocuments(String index, String type) { return countDocuments(new IndexType(index, type)); }
public void putDocuments(String index, String type, BaseDoc... docs) { putDocuments(new IndexType(index, type), docs); }
public Date getFieldAsDate(String key) { Object value = getField(key); if (value instanceof Date) { return (Date)value; } if (value instanceof Number) { return epochSecondsToDate((Number) value); } return EsUtils.parseDateTime((String)value); }
private IndexCreator startNewCreator(IndexDefinition... definitions) { IndexDefinitions defs = new IndexDefinitions(definitions, new MapSettings().asConfig()); defs.start(); IndexCreator creator = new IndexCreator(es.client(), defs, metadataIndexDefinition, metadataIndex, esDbCompatibility, settings.asConfig()); creator.start(); return creator; }
public void start() { result.clear(); sizeHandler.beforeStart(this); }
private static String refreshInterval(SettingsConfiguration settingsConfiguration) { int refreshInterval = settingsConfiguration.getRefreshInterval(); if (refreshInterval == -1) { return "-1"; } return refreshInterval + "s"; }
@Override public void stop() { esClient.close(); } }
/** * 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(); }
@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"); } }