Search in sources :

Example 1 with CheckedConsumer

use of org.opensearch.common.CheckedConsumer in project OpenSearch by opensearch-project.

the class BulkItemResponse method fromXContent.

/**
 * Reads a {@link BulkItemResponse} from a {@link XContentParser}.
 *
 * @param parser the {@link XContentParser}
 * @param id the id to assign to the parsed {@link BulkItemResponse}. It is usually the index of
 *           the item in the {@link BulkResponse#getItems} array.
 */
public static BulkItemResponse fromXContent(XContentParser parser, int id) throws IOException {
    ensureExpectedToken(XContentParser.Token.START_OBJECT, parser.currentToken(), parser);
    XContentParser.Token token = parser.nextToken();
    ensureExpectedToken(XContentParser.Token.FIELD_NAME, token, parser);
    String currentFieldName = parser.currentName();
    token = parser.nextToken();
    final OpType opType = OpType.fromString(currentFieldName);
    ensureExpectedToken(XContentParser.Token.START_OBJECT, token, parser);
    DocWriteResponse.Builder builder = null;
    CheckedConsumer<XContentParser, IOException> itemParser = null;
    if (opType == OpType.INDEX || opType == OpType.CREATE) {
        final IndexResponse.Builder indexResponseBuilder = new IndexResponse.Builder();
        builder = indexResponseBuilder;
        itemParser = (indexParser) -> IndexResponse.parseXContentFields(indexParser, indexResponseBuilder);
    } else if (opType == OpType.UPDATE) {
        final UpdateResponse.Builder updateResponseBuilder = new UpdateResponse.Builder();
        builder = updateResponseBuilder;
        itemParser = (updateParser) -> UpdateResponse.parseXContentFields(updateParser, updateResponseBuilder);
    } else if (opType == OpType.DELETE) {
        final DeleteResponse.Builder deleteResponseBuilder = new DeleteResponse.Builder();
        builder = deleteResponseBuilder;
        itemParser = (deleteParser) -> DeleteResponse.parseXContentFields(deleteParser, deleteResponseBuilder);
    } else {
        throwUnknownField(currentFieldName, parser.getTokenLocation());
    }
    RestStatus status = null;
    OpenSearchException exception = null;
    while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
        if (token == XContentParser.Token.FIELD_NAME) {
            currentFieldName = parser.currentName();
        }
        if (ERROR.equals(currentFieldName)) {
            if (token == XContentParser.Token.START_OBJECT) {
                exception = OpenSearchException.fromXContent(parser);
            }
        } else if (STATUS.equals(currentFieldName)) {
            if (token == XContentParser.Token.VALUE_NUMBER) {
                status = RestStatus.fromCode(parser.intValue());
            }
        } else {
            itemParser.accept(parser);
        }
    }
    ensureExpectedToken(XContentParser.Token.END_OBJECT, token, parser);
    token = parser.nextToken();
    ensureExpectedToken(XContentParser.Token.END_OBJECT, token, parser);
    BulkItemResponse bulkItemResponse;
    if (exception != null) {
        Failure failure = new Failure(builder.getShardId().getIndexName(), builder.getId(), exception, status);
        bulkItemResponse = new BulkItemResponse(id, opType, failure);
    } else {
        bulkItemResponse = new BulkItemResponse(id, opType, builder.build());
    }
    return bulkItemResponse;
}
Also used : SequenceNumbers(org.opensearch.index.seqno.SequenceNumbers) ConstructingObjectParser(org.opensearch.common.xcontent.ConstructingObjectParser) ToXContentFragment(org.opensearch.common.xcontent.ToXContentFragment) IndexResponse(org.opensearch.action.index.IndexResponse) UpdateResponse(org.opensearch.action.update.UpdateResponse) CheckedConsumer(org.opensearch.common.CheckedConsumer) Version(org.opensearch.Version) StreamOutput(org.opensearch.common.io.stream.StreamOutput) OpenSearchException(org.opensearch.OpenSearchException) ParseField(org.opensearch.common.ParseField) Writeable(org.opensearch.common.io.stream.Writeable) ConstructingObjectParser.constructorArg(org.opensearch.common.xcontent.ConstructingObjectParser.constructorArg) Strings(org.opensearch.common.Strings) XContentParser(org.opensearch.common.xcontent.XContentParser) MapperService(org.opensearch.index.mapper.MapperService) LegacyESVersion(org.opensearch.LegacyESVersion) DeleteResponse(org.opensearch.action.delete.DeleteResponse) ConstructingObjectParser.optionalConstructorArg(org.opensearch.common.xcontent.ConstructingObjectParser.optionalConstructorArg) StreamInput(org.opensearch.common.io.stream.StreamInput) ExceptionsHelper(org.opensearch.ExceptionsHelper) StatusToXContentObject(org.opensearch.common.xcontent.StatusToXContentObject) IOException(java.io.IOException) XContentParserUtils.ensureExpectedToken(org.opensearch.common.xcontent.XContentParserUtils.ensureExpectedToken) RestStatus(org.opensearch.rest.RestStatus) XContentBuilder(org.opensearch.common.xcontent.XContentBuilder) ShardId(org.opensearch.index.shard.ShardId) OpType(org.opensearch.action.DocWriteRequest.OpType) DocWriteResponse(org.opensearch.action.DocWriteResponse) XContentParserUtils.throwUnknownField(org.opensearch.common.xcontent.XContentParserUtils.throwUnknownField) DocWriteResponse(org.opensearch.action.DocWriteResponse) XContentBuilder(org.opensearch.common.xcontent.XContentBuilder) IOException(java.io.IOException) UpdateResponse(org.opensearch.action.update.UpdateResponse) DeleteResponse(org.opensearch.action.delete.DeleteResponse) RestStatus(org.opensearch.rest.RestStatus) IndexResponse(org.opensearch.action.index.IndexResponse) OpType(org.opensearch.action.DocWriteRequest.OpType) OpenSearchException(org.opensearch.OpenSearchException) XContentParser(org.opensearch.common.xcontent.XContentParser)

Example 2 with CheckedConsumer

use of org.opensearch.common.CheckedConsumer in project OpenSearch by opensearch-project.

the class BootstrapChecksTests method testDiscoveryConfiguredCheck.

public void testDiscoveryConfiguredCheck() throws NodeValidationException {
    final List<BootstrapCheck> checks = Collections.singletonList(new BootstrapChecks.DiscoveryConfiguredCheck());
    final BootstrapContext zen2Context = createTestContext(Settings.builder().put(DiscoveryModule.DISCOVERY_TYPE_SETTING.getKey(), ZEN2_DISCOVERY_TYPE).build(), Metadata.EMPTY_METADATA);
    // not always enforced
    BootstrapChecks.check(zen2Context, false, checks);
    // not enforced for non-zen2 discovery
    BootstrapChecks.check(createTestContext(Settings.builder().put(DiscoveryModule.DISCOVERY_TYPE_SETTING.getKey(), randomFrom("single-node", randomAlphaOfLength(5))).build(), Metadata.EMPTY_METADATA), true, checks);
    final NodeValidationException e = expectThrows(NodeValidationException.class, () -> BootstrapChecks.check(zen2Context, true, checks));
    assertThat(e, hasToString(containsString("the default discovery settings are unsuitable for production use; at least one " + "of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured")));
    CheckedConsumer<Settings.Builder, NodeValidationException> ensureChecksPass = b -> {
        final BootstrapContext context = createTestContext(b.put(DiscoveryModule.DISCOVERY_TYPE_SETTING.getKey(), ZEN2_DISCOVERY_TYPE).build(), Metadata.EMPTY_METADATA);
        BootstrapChecks.check(context, true, checks);
    };
    ensureChecksPass.accept(Settings.builder().putList(ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING.getKey()));
    ensureChecksPass.accept(Settings.builder().putList(DiscoveryModule.DISCOVERY_SEED_PROVIDERS_SETTING.getKey()));
    ensureChecksPass.accept(Settings.builder().putList(SettingsBasedSeedHostsProvider.DISCOVERY_SEED_HOSTS_SETTING.getKey()));
}
Also used : Matchers.hasToString(org.hamcrest.Matchers.hasToString) Arrays(java.util.Arrays) ClusterBootstrapService(org.opensearch.cluster.coordination.ClusterBootstrapService) Metadata(org.opensearch.cluster.metadata.Metadata) CoreMatchers.equalTo(org.hamcrest.CoreMatchers.equalTo) CheckedConsumer(org.opensearch.common.CheckedConsumer) Matchers.not(org.hamcrest.Matchers.not) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) BoundTransportAddress(org.opensearch.common.transport.BoundTransportAddress) ZEN2_DISCOVERY_TYPE(org.opensearch.discovery.DiscoveryModule.ZEN2_DISCOVERY_TYPE) AtomicReference(java.util.concurrent.atomic.AtomicReference) ArrayList(java.util.ArrayList) InetAddress(java.net.InetAddress) CoreMatchers.instanceOf(org.hamcrest.CoreMatchers.instanceOf) Mockito.verifyNoMoreInteractions(org.mockito.Mockito.verifyNoMoreInteractions) Locale(java.util.Locale) JvmInfo(org.opensearch.monitor.jvm.JvmInfo) AbstractBootstrapCheckTestCase(org.opensearch.test.AbstractBootstrapCheckTestCase) CoreMatchers.allOf(org.hamcrest.CoreMatchers.allOf) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Settings(org.opensearch.common.settings.Settings) SettingsBasedSeedHostsProvider(org.opensearch.discovery.SettingsBasedSeedHostsProvider) Mockito.when(org.mockito.Mockito.when) NodeValidationException(org.opensearch.node.NodeValidationException) Mockito.verify(org.mockito.Mockito.verify) TransportAddress(org.opensearch.common.transport.TransportAddress) Consumer(java.util.function.Consumer) AtomicLong(java.util.concurrent.atomic.AtomicLong) List(java.util.List) Logger(org.apache.logging.log4j.Logger) Constants(org.apache.lucene.util.Constants) Matcher(org.hamcrest.Matcher) Collections(java.util.Collections) DiscoveryModule(org.opensearch.discovery.DiscoveryModule) Mockito.mock(org.mockito.Mockito.mock) NodeValidationException(org.opensearch.node.NodeValidationException)

Example 3 with CheckedConsumer

use of org.opensearch.common.CheckedConsumer in project OpenSearch by opensearch-project.

the class ActionListenerTests method testOnFailure.

public void testOnFailure() {
    final int numListeners = randomIntBetween(1, 20);
    List<AtomicReference<Boolean>> refList = new ArrayList<>();
    List<AtomicReference<Exception>> excList = new ArrayList<>();
    List<ActionListener<Boolean>> listeners = new ArrayList<>();
    final int listenerToFail = randomBoolean() ? -1 : randomIntBetween(0, numListeners - 1);
    for (int i = 0; i < numListeners; i++) {
        AtomicReference<Boolean> reference = new AtomicReference<>();
        AtomicReference<Exception> exReference = new AtomicReference<>();
        refList.add(reference);
        excList.add(exReference);
        boolean fail = i == listenerToFail;
        CheckedConsumer<Boolean, ? extends Exception> handler = (o) -> {
            reference.set(o);
        };
        listeners.add(ActionListener.wrap(handler, (e) -> {
            exReference.set(e);
            if (fail) {
                throw new RuntimeException("double boom");
            }
        }));
    }
    try {
        ActionListener.onFailure(listeners, new Exception("booom"));
        assertTrue("unexpected succces listener to fail: " + listenerToFail, listenerToFail == -1);
    } catch (RuntimeException ex) {
        assertTrue("listener to fail: " + listenerToFail, listenerToFail >= 0);
        assertNotNull(ex.getCause());
        assertEquals("double boom", ex.getCause().getMessage());
    }
    for (int i = 0; i < numListeners; i++) {
        assertNull("listener index " + i, refList.get(i).get());
    }
    for (int i = 0; i < numListeners; i++) {
        assertEquals("listener index " + i, "booom", excList.get(i).get().getMessage());
    }
}
Also used : ExecutionException(java.util.concurrent.ExecutionException) Matchers.instanceOf(org.hamcrest.Matchers.instanceOf) List(java.util.List) PlainActionFuture(org.opensearch.action.support.PlainActionFuture) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) OpenSearchTestCase(org.opensearch.test.OpenSearchTestCase) Matchers.equalTo(org.hamcrest.Matchers.equalTo) CheckedConsumer(org.opensearch.common.CheckedConsumer) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) IOException(java.io.IOException) AtomicReference(java.util.concurrent.atomic.AtomicReference) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) AtomicReference(java.util.concurrent.atomic.AtomicReference) ExecutionException(java.util.concurrent.ExecutionException) IOException(java.io.IOException) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean)

Example 4 with CheckedConsumer

use of org.opensearch.common.CheckedConsumer in project OpenSearch by opensearch-project.

the class RemoveCorruptedShardDataCommand method findAndProcessShardPath.

protected void findAndProcessShardPath(OptionSet options, Environment environment, Path[] dataPaths, int nodeLockId, ClusterState clusterState, CheckedConsumer<ShardPath, IOException> consumer) throws IOException {
    final Settings settings = environment.settings();
    final IndexMetadata indexMetadata;
    final int shardId;
    final int fromNodeId;
    final int toNodeId;
    if (options.has(folderOption)) {
        final Path path = getPath(folderOption.value(options)).getParent();
        final Path shardParent = path.getParent();
        final Path shardParentParent = shardParent.getParent();
        final Path indexPath = path.resolve(ShardPath.INDEX_FOLDER_NAME);
        if (Files.exists(indexPath) == false || Files.isDirectory(indexPath) == false) {
            throw new OpenSearchException("index directory [" + indexPath + "], must exist and be a directory");
        }
        final String shardIdFileName = path.getFileName().toString();
        final String nodeIdFileName = shardParentParent.getParent().getFileName().toString();
        final String indexUUIDFolderName = shardParent.getFileName().toString();
        if (Files.isDirectory(path) && // SHARD-ID path element check
        shardIdFileName.chars().allMatch(Character::isDigit) && // `indices` check
        NodeEnvironment.INDICES_FOLDER.equals(shardParentParent.getFileName().toString()) && // NODE-ID check
        nodeIdFileName.chars().allMatch(Character::isDigit) && // `nodes` check
        NodeEnvironment.NODES_FOLDER.equals(shardParentParent.getParent().getParent().getFileName().toString())) {
            shardId = Integer.parseInt(shardIdFileName);
            fromNodeId = Integer.parseInt(nodeIdFileName);
            toNodeId = fromNodeId + 1;
            indexMetadata = StreamSupport.stream(clusterState.metadata().indices().values().spliterator(), false).map(imd -> imd.value).filter(imd -> imd.getIndexUUID().equals(indexUUIDFolderName)).findFirst().orElse(null);
        } else {
            throw new OpenSearchException("Unable to resolve shard id. Wrong folder structure at [ " + path.toString() + " ], expected .../nodes/[NODE-ID]/indices/[INDEX-UUID]/[SHARD-ID]");
        }
    } else {
        // otherwise resolve shardPath based on the index name and shard id
        String indexName = Objects.requireNonNull(indexNameOption.value(options), "Index name is required");
        shardId = Objects.requireNonNull(shardIdOption.value(options), "Shard ID is required");
        indexMetadata = clusterState.metadata().index(indexName);
    }
    if (indexMetadata == null) {
        throw new OpenSearchException("Unable to find index in cluster state");
    }
    final IndexSettings indexSettings = new IndexSettings(indexMetadata, settings);
    final Index index = indexMetadata.getIndex();
    final ShardId shId = new ShardId(index, shardId);
    for (Path dataPath : dataPaths) {
        final Path shardPathLocation = dataPath.resolve(NodeEnvironment.INDICES_FOLDER).resolve(index.getUUID()).resolve(Integer.toString(shId.id()));
        if (Files.exists(shardPathLocation)) {
            final ShardPath shardPath = ShardPath.loadShardPath(logger, shId, indexSettings.customDataPath(), new Path[] { shardPathLocation }, nodeLockId, dataPath);
            if (shardPath != null) {
                consumer.accept(shardPath);
                return;
            }
        }
    }
    throw new OpenSearchException("Unable to resolve shard path for index [" + indexMetadata.getIndex().getName() + "] and shard id [" + shardId + "]");
}
Also used : Path(java.nio.file.Path) NoMergePolicy(org.apache.lucene.index.NoMergePolicy) SequenceNumbers(org.opensearch.index.seqno.SequenceNumbers) Arrays(java.util.Arrays) OpenSearchException(org.opensearch.OpenSearchException) AllocateStalePrimaryAllocationCommand(org.opensearch.cluster.routing.allocation.command.AllocateStalePrimaryAllocationCommand) Strings(org.opensearch.common.Strings) NodeMetadata(org.opensearch.env.NodeMetadata) Directory(org.apache.lucene.store.Directory) Map(java.util.Map) OptionParser(joptsimple.OptionParser) Lucene(org.opensearch.common.lucene.Lucene) Path(java.nio.file.Path) OptionSet(joptsimple.OptionSet) OptionSpec(joptsimple.OptionSpec) NodeEnvironment(org.opensearch.env.NodeEnvironment) PrintWriter(java.io.PrintWriter) SuppressForbidden(org.opensearch.common.SuppressForbidden) Index(org.opensearch.index.Index) TruncateTranslogAction(org.opensearch.index.translog.TruncateTranslogAction) Settings(org.opensearch.common.settings.Settings) Store(org.opensearch.index.store.Store) OpenSearchNodeCommand(org.opensearch.cluster.coordination.OpenSearchNodeCommand) Tuple(org.opensearch.common.collect.Tuple) Engine(org.opensearch.index.engine.Engine) Objects(java.util.Objects) IndexWriter(org.apache.lucene.index.IndexWriter) Logger(org.apache.logging.log4j.Logger) IndexSettings(org.opensearch.index.IndexSettings) IndexWriterConfig(org.apache.lucene.index.IndexWriterConfig) AllocateEmptyPrimaryAllocationCommand(org.opensearch.cluster.routing.allocation.command.AllocateEmptyPrimaryAllocationCommand) PathUtils(org.opensearch.common.io.PathUtils) IndexMetadata(org.opensearch.cluster.metadata.IndexMetadata) LockObtainFailedException(org.apache.lucene.store.LockObtainFailedException) CheckedConsumer(org.opensearch.common.CheckedConsumer) NativeFSLockFactory(org.apache.lucene.store.NativeFSLockFactory) HashMap(java.util.HashMap) PersistedClusterStateService(org.opensearch.gateway.PersistedClusterStateService) ClusterState(org.opensearch.cluster.ClusterState) Lock(org.apache.lucene.store.Lock) StreamSupport(java.util.stream.StreamSupport) UUIDs(org.opensearch.common.UUIDs) FSDirectory(org.apache.lucene.store.FSDirectory) Environment(org.opensearch.env.Environment) OutputStream(java.io.OutputStream) PrintStream(java.io.PrintStream) Terminal(org.opensearch.cli.Terminal) AllocationCommands(org.opensearch.cluster.routing.allocation.command.AllocationCommands) Files(java.nio.file.Files) AllocationId(org.opensearch.cluster.routing.AllocationId) IOException(java.io.IOException) LogManager(org.apache.logging.log4j.LogManager) IndexSettings(org.opensearch.index.IndexSettings) OpenSearchException(org.opensearch.OpenSearchException) Index(org.opensearch.index.Index) IndexMetadata(org.opensearch.cluster.metadata.IndexMetadata) Settings(org.opensearch.common.settings.Settings) IndexSettings(org.opensearch.index.IndexSettings)

Example 5 with CheckedConsumer

use of org.opensearch.common.CheckedConsumer in project OpenSearch by opensearch-project.

the class GeoGridAggregatorTestCase method testAsSubAgg.

public void testAsSubAgg() throws IOException {
    int precision = randomPrecision();
    Map<String, Map<String, Long>> expectedCountPerTPerGeoHash = new TreeMap<>();
    List<List<IndexableField>> docs = new ArrayList<>();
    for (int i = 0; i < 30; i++) {
        String t = randomAlphaOfLength(1);
        double[] latLng = randomLatLng();
        List<IndexableField> doc = new ArrayList<>();
        docs.add(doc);
        doc.add(new LatLonDocValuesField(FIELD_NAME, latLng[0], latLng[1]));
        doc.add(new SortedSetDocValuesField("t", new BytesRef(t)));
        String hash = hashAsString(latLng[1], latLng[0], precision);
        Map<String, Long> expectedCountPerGeoHash = expectedCountPerTPerGeoHash.get(t);
        if (expectedCountPerGeoHash == null) {
            expectedCountPerGeoHash = new TreeMap<>();
            expectedCountPerTPerGeoHash.put(t, expectedCountPerGeoHash);
        }
        expectedCountPerGeoHash.put(hash, expectedCountPerGeoHash.getOrDefault(hash, 0L) + 1);
    }
    CheckedConsumer<RandomIndexWriter, IOException> buildIndex = iw -> iw.addDocuments(docs);
    TermsAggregationBuilder aggregationBuilder = new TermsAggregationBuilder("t").field("t").size(expectedCountPerTPerGeoHash.size()).subAggregation(createBuilder("gg").field(FIELD_NAME).precision(precision));
    Consumer<StringTerms> verify = (terms) -> {
        Map<String, Map<String, Long>> actual = new TreeMap<>();
        for (StringTerms.Bucket tb : terms.getBuckets()) {
            InternalGeoGrid<?> gg = tb.getAggregations().get("gg");
            Map<String, Long> sub = new TreeMap<>();
            for (InternalGeoGridBucket<?> ggb : gg.getBuckets()) {
                sub.put(ggb.getKeyAsString(), ggb.getDocCount());
            }
            actual.put(tb.getKeyAsString(), sub);
        }
        assertThat(actual, equalTo(expectedCountPerTPerGeoHash));
    };
    testCase(aggregationBuilder, new MatchAllDocsQuery(), buildIndex, verify, keywordField("t"), geoPointField(FIELD_NAME));
}
Also used : Query(org.apache.lucene.search.Query) Aggregation(org.opensearch.search.aggregations.Aggregation) LatLonDocValuesField(org.apache.lucene.document.LatLonDocValuesField) StringTerms(org.opensearch.search.aggregations.bucket.terms.StringTerms) IndexableField(org.apache.lucene.index.IndexableField) CheckedConsumer(org.opensearch.common.CheckedConsumer) GeoEncodingUtils(org.apache.lucene.geo.GeoEncodingUtils) GeoBoundingBox(org.opensearch.common.geo.GeoBoundingBox) HashMap(java.util.HashMap) Function(java.util.function.Function) ArrayList(java.util.ArrayList) GeoUtils(org.opensearch.common.geo.GeoUtils) HashSet(java.util.HashSet) GeoPointFieldMapper(org.opensearch.index.mapper.GeoPointFieldMapper) Directory(org.apache.lucene.store.Directory) Map(java.util.Map) AggregationInspectionHelper(org.opensearch.search.aggregations.support.AggregationInspectionHelper) SortedSetDocValuesField(org.apache.lucene.document.SortedSetDocValuesField) AggregatorTestCase(org.opensearch.search.aggregations.AggregatorTestCase) BytesRef(org.apache.lucene.util.BytesRef) MappedFieldType(org.opensearch.index.mapper.MappedFieldType) DirectoryReader(org.apache.lucene.index.DirectoryReader) Set(java.util.Set) IOException(java.io.IOException) MatchAllDocsQuery(org.apache.lucene.search.MatchAllDocsQuery) GeoBoundingBoxTests(org.opensearch.common.geo.GeoBoundingBoxTests) Consumer(java.util.function.Consumer) List(java.util.List) TreeMap(java.util.TreeMap) TermsAggregationBuilder(org.opensearch.search.aggregations.bucket.terms.TermsAggregationBuilder) Matchers.equalTo(org.hamcrest.Matchers.equalTo) Aggregator(org.opensearch.search.aggregations.Aggregator) RandomIndexWriter(org.apache.lucene.index.RandomIndexWriter) MultiBucketConsumerService(org.opensearch.search.aggregations.MultiBucketConsumerService) Collections(java.util.Collections) IndexReader(org.apache.lucene.index.IndexReader) IndexSearcher(org.apache.lucene.search.IndexSearcher) ArrayList(java.util.ArrayList) StringTerms(org.opensearch.search.aggregations.bucket.terms.StringTerms) ArrayList(java.util.ArrayList) List(java.util.List) BytesRef(org.apache.lucene.util.BytesRef) LatLonDocValuesField(org.apache.lucene.document.LatLonDocValuesField) IOException(java.io.IOException) TreeMap(java.util.TreeMap) MatchAllDocsQuery(org.apache.lucene.search.MatchAllDocsQuery) IndexableField(org.apache.lucene.index.IndexableField) TermsAggregationBuilder(org.opensearch.search.aggregations.bucket.terms.TermsAggregationBuilder) SortedSetDocValuesField(org.apache.lucene.document.SortedSetDocValuesField) HashMap(java.util.HashMap) Map(java.util.Map) TreeMap(java.util.TreeMap) RandomIndexWriter(org.apache.lucene.index.RandomIndexWriter)

Aggregations

CheckedConsumer (org.opensearch.common.CheckedConsumer)12 IOException (java.io.IOException)11 List (java.util.List)10 Matchers.equalTo (org.hamcrest.Matchers.equalTo)9 ArrayList (java.util.ArrayList)8 Consumer (java.util.function.Consumer)8 Directory (org.apache.lucene.store.Directory)8 IndexReader (org.apache.lucene.index.IndexReader)7 RandomIndexWriter (org.apache.lucene.index.RandomIndexWriter)7 IndexSearcher (org.apache.lucene.search.IndexSearcher)7 MatchAllDocsQuery (org.apache.lucene.search.MatchAllDocsQuery)7 AggregatorTestCase (org.opensearch.search.aggregations.AggregatorTestCase)7 Arrays (java.util.Arrays)6 SortedNumericDocValuesField (org.apache.lucene.document.SortedNumericDocValuesField)6 MappedFieldType (org.opensearch.index.mapper.MappedFieldType)6 AggregationBuilder (org.opensearch.search.aggregations.AggregationBuilder)6 Collections (java.util.Collections)5 DirectoryReader (org.apache.lucene.index.DirectoryReader)5 Query (org.apache.lucene.search.Query)5 BytesRef (org.apache.lucene.util.BytesRef)5