Search in sources :

Example 21 with NamedXContentRegistry

use of org.graylog.shaded.elasticsearch7.org.elasticsearch.common.xcontent.NamedXContentRegistry in project elasticsearch by elastic.

the class BasePipelineAggregationTestCase method setUp.

/**
     * Setup for the whole base test class.
     */
@Override
public void setUp() throws Exception {
    super.setUp();
    Settings settings = Settings.builder().put("node.name", AbstractQueryTestCase.class.toString()).put(Environment.PATH_HOME_SETTING.getKey(), createTempDir()).build();
    IndicesModule indicesModule = new IndicesModule(Collections.emptyList());
    SearchModule searchModule = new SearchModule(settings, false, emptyList());
    List<NamedWriteableRegistry.Entry> entries = new ArrayList<>();
    entries.addAll(indicesModule.getNamedWriteables());
    entries.addAll(searchModule.getNamedWriteables());
    namedWriteableRegistry = new NamedWriteableRegistry(entries);
    xContentRegistry = new NamedXContentRegistry(searchModule.getNamedXContents());
    //create some random type with some default field, those types will stick around for all of the subclasses
    currentTypes = new String[randomIntBetween(0, 5)];
    for (int i = 0; i < currentTypes.length; i++) {
        String type = randomAsciiOfLengthBetween(1, 10);
        currentTypes[i] = type;
    }
}
Also used : NamedWriteableRegistry(org.elasticsearch.common.io.stream.NamedWriteableRegistry) IndicesModule(org.elasticsearch.indices.IndicesModule) ArrayList(java.util.ArrayList) SearchModule(org.elasticsearch.search.SearchModule) NamedXContentRegistry(org.elasticsearch.common.xcontent.NamedXContentRegistry) Settings(org.elasticsearch.common.settings.Settings) AbstractQueryTestCase(org.elasticsearch.test.AbstractQueryTestCase)

Example 22 with NamedXContentRegistry

use of org.graylog.shaded.elasticsearch7.org.elasticsearch.common.xcontent.NamedXContentRegistry in project elasticsearch by elastic.

the class AggregatorFactoriesTests method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    // we have to prefer CURRENT since with the range of versions we support
    // it's rather unlikely to get the current actually.
    Settings settings = Settings.builder().put("node.name", AbstractQueryTestCase.class.toString()).put(Environment.PATH_HOME_SETTING.getKey(), createTempDir()).put(ScriptService.SCRIPT_AUTO_RELOAD_ENABLED_SETTING.getKey(), false).build();
    // create some random type with some default field, those types will
    // stick around for all of the subclasses
    currentTypes = new String[randomIntBetween(0, 5)];
    for (int i = 0; i < currentTypes.length; i++) {
        String type = randomAsciiOfLengthBetween(1, 10);
        currentTypes[i] = type;
    }
    xContentRegistry = new NamedXContentRegistry(new SearchModule(settings, false, emptyList()).getNamedXContents());
}
Also used : SearchModule(org.elasticsearch.search.SearchModule) Matchers.containsString(org.hamcrest.Matchers.containsString) NamedXContentRegistry(org.elasticsearch.common.xcontent.NamedXContentRegistry) Settings(org.elasticsearch.common.settings.Settings)

Example 23 with NamedXContentRegistry

use of org.graylog.shaded.elasticsearch7.org.elasticsearch.common.xcontent.NamedXContentRegistry in project calcite by apache.

the class Elasticsearch5Table method find.

@Override
protected Enumerable<Object> find(String index, List<String> ops, List<Map.Entry<String, Class>> fields) {
    final String dbName = index;
    final SearchSourceBuilder searchSourceBuilder;
    if (ops.isEmpty()) {
        searchSourceBuilder = new SearchSourceBuilder();
    } else {
        String queryString = "{" + Util.toString(ops, "", ", ", "") + "}";
        NamedXContentRegistry xContentRegistry = NamedXContentRegistry.EMPTY;
        XContent xContent = JsonXContent.jsonXContent;
        try (XContentParser parser = xContent.createParser(xContentRegistry, queryString)) {
            final QueryParseContext queryParseContext = new QueryParseContext(parser);
            searchSourceBuilder = SearchSourceBuilder.fromXContent(queryParseContext);
        } catch (IOException ex) {
            throw new RuntimeException(ex);
        }
    }
    final Function1<SearchHit, Object> getter = Elasticsearch5Enumerator.getter(fields);
    return new AbstractEnumerable<Object>() {

        public Enumerator<Object> enumerator() {
            final Iterator<SearchHit> cursor = client.prepareSearch(dbName).setTypes(typeName).setSource(searchSourceBuilder).execute().actionGet().getHits().iterator();
            return new Elasticsearch5Enumerator(cursor, getter);
        }
    };
}
Also used : SearchHit(org.elasticsearch.search.SearchHit) IOException(java.io.IOException) SearchSourceBuilder(org.elasticsearch.search.builder.SearchSourceBuilder) QueryParseContext(org.elasticsearch.index.query.QueryParseContext) XContent(org.elasticsearch.common.xcontent.XContent) JsonXContent(org.elasticsearch.common.xcontent.json.JsonXContent) AbstractEnumerable(org.apache.calcite.linq4j.AbstractEnumerable) NamedXContentRegistry(org.elasticsearch.common.xcontent.NamedXContentRegistry) XContentParser(org.elasticsearch.common.xcontent.XContentParser)

Example 24 with NamedXContentRegistry

use of org.graylog.shaded.elasticsearch7.org.elasticsearch.common.xcontent.NamedXContentRegistry in project crate by crate.

the class EngineTestCase method createMapperService.

public static MapperService createMapperService(String type) throws IOException {
    IndexMetadata indexMetadata = IndexMetadata.builder("test").settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT).put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1).put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1)).putMapping(type, "{\"properties\": {}}").build();
    MapperService mapperService = MapperTestUtils.newMapperService(new NamedXContentRegistry(ClusterModule.getNamedXWriteables()), createTempDir(), Settings.EMPTY, "test");
    mapperService.merge(indexMetadata, MapperService.MergeReason.MAPPING_UPDATE);
    return mapperService;
}
Also used : IndexMetadata(org.elasticsearch.cluster.metadata.IndexMetadata) NamedXContentRegistry(org.elasticsearch.common.xcontent.NamedXContentRegistry) MapperService(org.elasticsearch.index.mapper.MapperService)

Example 25 with NamedXContentRegistry

use of org.graylog.shaded.elasticsearch7.org.elasticsearch.common.xcontent.NamedXContentRegistry in project graylog2-server by Graylog2.

the class TestMultisearchResponse method resultFor.

private static MultiSearchResponse resultFor(InputStream result) throws IOException {
    final NamedXContentRegistry registry = new NamedXContentRegistry(getDefaultNamedXContents());
    final XContentParser parser = JsonXContent.jsonXContent.createParser(registry, LoggingDeprecationHandler.INSTANCE, result);
    return MultiSearchResponse.fromXContext(parser);
}
Also used : NamedXContentRegistry(org.graylog.shaded.elasticsearch7.org.elasticsearch.common.xcontent.NamedXContentRegistry) XContentParser(org.graylog.shaded.elasticsearch7.org.elasticsearch.common.xcontent.XContentParser)

Aggregations

NamedXContentRegistry (org.elasticsearch.common.xcontent.NamedXContentRegistry)24 NamedWriteableRegistry (org.elasticsearch.common.io.stream.NamedWriteableRegistry)14 Settings (org.elasticsearch.common.settings.Settings)12 SearchModule (org.elasticsearch.search.SearchModule)12 BeforeClass (org.junit.BeforeClass)8 ArrayList (java.util.ArrayList)4 BigArrays (org.elasticsearch.common.util.BigArrays)4 CircuitBreakerService (org.elasticsearch.indices.breaker.CircuitBreakerService)4 NetworkPlugin (org.elasticsearch.plugins.NetworkPlugin)4 HashMap (java.util.HashMap)3 Map (java.util.Map)3 Environment (org.elasticsearch.env.Environment)3 HttpServerTransport (org.elasticsearch.http.HttpServerTransport)3 ThreadPool (org.elasticsearch.threadpool.ThreadPool)3 Path (java.nio.file.Path)2 RepositoryMetaData (org.elasticsearch.cluster.metadata.RepositoryMetaData)2 IndicesModule (org.elasticsearch.indices.IndicesModule)2 TestThreadPool (org.elasticsearch.threadpool.TestThreadPool)2 Transport (org.elasticsearch.transport.Transport)2 UserDefinedFunctionsMetadata (io.crate.expression.udf.UserDefinedFunctionsMetadata)1