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;
}
}
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());
}
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);
}
};
}
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;
}
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);
}
Aggregations