Search in sources :

Example 11 with SearchModule

use of org.elasticsearch.search.SearchModule in project elasticsearch by elastic.

the class InnerHitBuilderTests method init.

@BeforeClass
public static void init() {
    SearchModule searchModule = new SearchModule(Settings.EMPTY, false, emptyList());
    namedWriteableRegistry = new NamedWriteableRegistry(searchModule.getNamedWriteables());
    xContentRegistry = new NamedXContentRegistry(searchModule.getNamedXContents());
}
Also used : NamedWriteableRegistry(org.elasticsearch.common.io.stream.NamedWriteableRegistry) SearchModule(org.elasticsearch.search.SearchModule) NamedXContentRegistry(org.elasticsearch.common.xcontent.NamedXContentRegistry) BeforeClass(org.junit.BeforeClass)

Example 12 with SearchModule

use of org.elasticsearch.search.SearchModule in project elasticsearch by elastic.

the class SignificanceHeuristicTests method testStreamResponse.

// test that stream output can actually be read - does not replace bwc test
public void testStreamResponse() throws Exception {
    Version version = randomVersion(random());
    InternalMappedSignificantTerms<?, ?> sigTerms = getRandomSignificantTerms(getRandomSignificanceheuristic());
    // write
    ByteArrayOutputStream outBuffer = new ByteArrayOutputStream();
    OutputStreamStreamOutput out = new OutputStreamStreamOutput(outBuffer);
    out.setVersion(version);
    out.writeNamedWriteable(sigTerms);
    // read
    ByteArrayInputStream inBuffer = new ByteArrayInputStream(outBuffer.toByteArray());
    StreamInput in = new InputStreamStreamInput(inBuffer);
    // populates the registry through side effects
    SearchModule searchModule = new SearchModule(Settings.EMPTY, false, emptyList());
    NamedWriteableRegistry registry = new NamedWriteableRegistry(searchModule.getNamedWriteables());
    in = new NamedWriteableAwareStreamInput(in, registry);
    in.setVersion(version);
    InternalMappedSignificantTerms<?, ?> read = (InternalMappedSignificantTerms<?, ?>) in.readNamedWriteable(InternalAggregation.class);
    assertEquals(sigTerms.significanceHeuristic, read.significanceHeuristic);
    SignificantTerms.Bucket originalBucket = sigTerms.getBuckets().get(0);
    SignificantTerms.Bucket streamedBucket = read.getBuckets().get(0);
    assertThat(originalBucket.getKeyAsString(), equalTo(streamedBucket.getKeyAsString()));
    assertThat(originalBucket.getSupersetDf(), equalTo(streamedBucket.getSupersetDf()));
    assertThat(originalBucket.getSubsetDf(), equalTo(streamedBucket.getSubsetDf()));
    assertThat(streamedBucket.getSubsetSize(), equalTo(10L));
    assertThat(streamedBucket.getSupersetSize(), equalTo(20L));
}
Also used : NamedWriteableRegistry(org.elasticsearch.common.io.stream.NamedWriteableRegistry) ByteArrayOutputStream(java.io.ByteArrayOutputStream) InternalAggregation(org.elasticsearch.search.aggregations.InternalAggregation) OutputStreamStreamOutput(org.elasticsearch.common.io.stream.OutputStreamStreamOutput) Version(org.elasticsearch.Version) VersionUtils.randomVersion(org.elasticsearch.test.VersionUtils.randomVersion) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStreamStreamInput(org.elasticsearch.common.io.stream.InputStreamStreamInput) NamedWriteableAwareStreamInput(org.elasticsearch.common.io.stream.NamedWriteableAwareStreamInput) StreamInput(org.elasticsearch.common.io.stream.StreamInput) SearchModule(org.elasticsearch.search.SearchModule) NamedWriteableAwareStreamInput(org.elasticsearch.common.io.stream.NamedWriteableAwareStreamInput) InputStreamStreamInput(org.elasticsearch.common.io.stream.InputStreamStreamInput)

Example 13 with SearchModule

use of org.elasticsearch.search.SearchModule in project elasticsearch by elastic.

the class AbstractSuggestionBuilderTestCase method init.

/**
     * setup for the whole base test class
     */
@BeforeClass
public static void init() throws IOException {
    SearchModule searchModule = new SearchModule(Settings.EMPTY, false, emptyList());
    namedWriteableRegistry = new NamedWriteableRegistry(searchModule.getNamedWriteables());
    xContentRegistry = new NamedXContentRegistry(searchModule.getNamedXContents());
}
Also used : NamedWriteableRegistry(org.elasticsearch.common.io.stream.NamedWriteableRegistry) SearchModule(org.elasticsearch.search.SearchModule) NamedXContentRegistry(org.elasticsearch.common.xcontent.NamedXContentRegistry) BeforeClass(org.junit.BeforeClass)

Example 14 with SearchModule

use of org.elasticsearch.search.SearchModule in project elasticsearch by elastic.

the class SortBuilderTests method init.

@BeforeClass
public static void init() {
    SearchModule searchModule = new SearchModule(Settings.EMPTY, false, emptyList());
    xContentRegistry = new NamedXContentRegistry(searchModule.getNamedXContents());
}
Also used : SearchModule(org.elasticsearch.search.SearchModule) NamedXContentRegistry(org.elasticsearch.common.xcontent.NamedXContentRegistry) BeforeClass(org.junit.BeforeClass)

Example 15 with SearchModule

use of org.elasticsearch.search.SearchModule in project elasticsearch by elastic.

the class ShardValidateQueryRequestTests method setUp.

public void setUp() throws Exception {
    super.setUp();
    IndicesModule indicesModule = new IndicesModule(Collections.emptyList());
    SearchModule searchModule = new SearchModule(Settings.EMPTY, false, Collections.emptyList());
    List<NamedWriteableRegistry.Entry> entries = new ArrayList<>();
    entries.addAll(indicesModule.getNamedWriteables());
    entries.addAll(searchModule.getNamedWriteables());
    namedWriteableRegistry = new NamedWriteableRegistry(entries);
}
Also used : NamedWriteableRegistry(org.elasticsearch.common.io.stream.NamedWriteableRegistry) IndicesModule(org.elasticsearch.indices.IndicesModule) ArrayList(java.util.ArrayList) SearchModule(org.elasticsearch.search.SearchModule)

Aggregations

SearchModule (org.elasticsearch.search.SearchModule)18 NamedWriteableRegistry (org.elasticsearch.common.io.stream.NamedWriteableRegistry)15 NamedXContentRegistry (org.elasticsearch.common.xcontent.NamedXContentRegistry)12 BeforeClass (org.junit.BeforeClass)8 ArrayList (java.util.ArrayList)6 Settings (org.elasticsearch.common.settings.Settings)5 IndicesModule (org.elasticsearch.indices.IndicesModule)4 Version (org.elasticsearch.Version)2 DiscoveryNode (org.elasticsearch.cluster.node.DiscoveryNode)2 NamedWriteableAwareStreamInput (org.elasticsearch.common.io.stream.NamedWriteableAwareStreamInput)2 StreamInput (org.elasticsearch.common.io.stream.StreamInput)2 TransportAddress (org.elasticsearch.common.transport.TransportAddress)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 Closeable (java.io.Closeable)1 Path (java.nio.file.Path)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1