Search in sources :

Example 6 with SearchModule

use of org.opensearch.search.SearchModule in project OpenSearch by opensearch-project.

the class NestedSortBuilderTests method init.

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

Example 7 with SearchModule

use of org.opensearch.search.SearchModule in project OpenSearch by opensearch-project.

the class AggregatorTestCase method initValuesSourceRegistry.

// Make this @Before instead of @BeforeClass so it can call the non-static getSearchPlugins method
@Before
public void initValuesSourceRegistry() {
    List<SearchPlugin> plugins = new ArrayList<>(getSearchPlugins());
    plugins.add(new AggCardinalityPlugin());
    SearchModule searchModule = new SearchModule(Settings.EMPTY, plugins);
    valuesSourceRegistry = searchModule.getValuesSourceRegistry();
}
Also used : SearchPlugin(org.opensearch.plugins.SearchPlugin) ArrayList(java.util.ArrayList) SearchModule(org.opensearch.search.SearchModule) Before(org.junit.Before)

Example 8 with SearchModule

use of org.opensearch.search.SearchModule in project OpenSearch by opensearch-project.

the class InternalAggregationTestCase method getNamedWriteables.

/**
 * Implementors can override this if they want to provide a custom list of namedWriteables.  If the implementor
 * _just_ wants to register in namedWriteables provided by a plugin, prefer overriding
 * {@link InternalAggregationTestCase#registerPlugin()} instead because that route handles the automatic
 * conversion of AggSpecs into namedWriteables.
 */
protected List<NamedWriteableRegistry.Entry> getNamedWriteables() {
    SearchPlugin plugin = registerPlugin();
    SearchModule searchModule = new SearchModule(Settings.EMPTY, plugin == null ? emptyList() : Collections.singletonList(plugin));
    List<NamedWriteableRegistry.Entry> entries = new ArrayList<>(searchModule.getNamedWriteables());
    // Modules/plugins may have extra namedwriteables that are not added by agg specs
    if (plugin != null) {
        entries.addAll(((Plugin) plugin).getNamedWriteables());
    }
    return entries;
}
Also used : SearchPlugin(org.opensearch.plugins.SearchPlugin) ArrayList(java.util.ArrayList) SearchModule(org.opensearch.search.SearchModule)

Example 9 with SearchModule

use of org.opensearch.search.SearchModule in project OpenSearch by opensearch-project.

the class ShardValidateQueryRequestTests method setUp.

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

Example 10 with SearchModule

use of org.opensearch.search.SearchModule in project anomaly-detection by opensearch-project.

the class TestHelpers method randomFeatureQuery.

public static SearchSourceBuilder randomFeatureQuery() throws IOException {
    String query = "{\"query\":{\"match\":{\"user\":{\"query\":\"kimchy\",\"operator\":\"OR\",\"prefix_length\":0," + "\"max_expansions\":50,\"fuzzy_transpositions\":true,\"lenient\":false,\"zero_terms_query\":\"NONE\"," + "\"auto_generate_synonyms_phrase_query\":true,\"boost\":1}}}}";
    SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
    SearchModule searchModule = new SearchModule(Settings.EMPTY, false, Collections.emptyList());
    XContentParser parser = XContentType.JSON.xContent().createParser(new NamedXContentRegistry(searchModule.getNamedXContents()), LoggingDeprecationHandler.INSTANCE, query);
    searchSourceBuilder.parseXContent(parser);
    return searchSourceBuilder;
}
Also used : SearchModule(org.opensearch.search.SearchModule) NamedXContentRegistry(org.opensearch.common.xcontent.NamedXContentRegistry) XContentParser(org.opensearch.common.xcontent.XContentParser) SearchSourceBuilder(org.opensearch.search.builder.SearchSourceBuilder)

Aggregations

SearchModule (org.opensearch.search.SearchModule)27 NamedWriteableRegistry (org.opensearch.common.io.stream.NamedWriteableRegistry)19 NamedXContentRegistry (org.opensearch.common.xcontent.NamedXContentRegistry)16 BeforeClass (org.junit.BeforeClass)9 ArrayList (java.util.ArrayList)6 NamedWriteableAwareStreamInput (org.opensearch.common.io.stream.NamedWriteableAwareStreamInput)5 StreamInput (org.opensearch.common.io.stream.StreamInput)4 Test (org.junit.Test)3 Version (org.opensearch.Version)3 BytesStreamOutput (org.opensearch.common.io.stream.BytesStreamOutput)3 Settings (org.opensearch.common.settings.Settings)3 XContentBuilder (org.opensearch.common.xcontent.XContentBuilder)3 XContentParser (org.opensearch.common.xcontent.XContentParser)3 IndicesModule (org.opensearch.indices.IndicesModule)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 Before (org.junit.Before)2 InputStreamStreamInput (org.opensearch.common.io.stream.InputStreamStreamInput)2 User (org.opensearch.commons.authuser.User)2 SearchPlugin (org.opensearch.plugins.SearchPlugin)2 AsynchronousSearchContextId (org.opensearch.search.asynchronous.context.AsynchronousSearchContextId)2