Search in sources :

Example 6 with IndicesModule

use of org.elasticsearch.indices.IndicesModule in project crate by crate.

the class LuceneQueryBuilderTest method createMapperService.

private MapperService createMapperService(Index index, Settings indexSettings, AnalysisService analysisService) {
    DynamicArrayFieldMapperBuilderFactoryProvider arrayMapperProvider = new DynamicArrayFieldMapperBuilderFactoryProvider();
    arrayMapperProvider.dynamicArrayFieldMapperBuilderFactory = new ArrayMapper.BuilderFactory();
    IndicesModule indicesModule = new IndicesModule();
    indicesModule.registerMapper(ArrayMapper.CONTENT_TYPE, new ArrayMapper.TypeParser());
    return new MapperService(index, indexSettings, analysisService, new SimilarityLookupService(index, indexSettings), null, indicesModule.getMapperRegistry(), arrayMapperProvider);
}
Also used : DynamicArrayFieldMapperBuilderFactoryProvider(org.elasticsearch.index.mapper.array.DynamicArrayFieldMapperBuilderFactoryProvider) IndicesModule(org.elasticsearch.indices.IndicesModule) SimilarityLookupService(org.elasticsearch.index.similarity.SimilarityLookupService) ArrayMapper(org.elasticsearch.index.mapper.ArrayMapper) MapperService(org.elasticsearch.index.mapper.MapperService)

Example 7 with IndicesModule

use of org.elasticsearch.indices.IndicesModule 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)

Example 8 with IndicesModule

use of org.elasticsearch.indices.IndicesModule 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 9 with IndicesModule

use of org.elasticsearch.indices.IndicesModule in project elasticsearch by elastic.

the class FieldNamesFieldMapperTests method testSeesFieldsFromPlugins.

public void testSeesFieldsFromPlugins() throws IOException {
    IndexService indexService = createIndex("test");
    IndicesModule indicesModule = newTestIndicesModule(Collections.emptyMap(), Collections.singletonMap("_dummy", new DummyMetadataFieldMapper.TypeParser()));
    final MapperRegistry mapperRegistry = indicesModule.getMapperRegistry();
    Supplier<QueryShardContext> queryShardContext = () -> {
        return indexService.newQueryShardContext(0, null, () -> {
            throw new UnsupportedOperationException();
        });
    };
    MapperService mapperService = new MapperService(indexService.getIndexSettings(), indexService.getIndexAnalyzers(), indexService.xContentRegistry(), indexService.similarityService(), mapperRegistry, queryShardContext);
    DocumentMapperParser parser = new DocumentMapperParser(indexService.getIndexSettings(), mapperService, indexService.getIndexAnalyzers(), indexService.xContentRegistry(), indexService.similarityService(), mapperRegistry, queryShardContext);
    String mapping = XContentFactory.jsonBuilder().startObject().startObject("type").endObject().endObject().string();
    DocumentMapper mapper = parser.parse("type", new CompressedXContent(mapping));
    ParsedDocument parsedDocument = mapper.parse("index", "type", "id", new BytesArray("{}"));
    IndexableField[] fields = parsedDocument.rootDoc().getFields(FieldNamesFieldMapper.NAME);
    boolean found = false;
    for (IndexableField f : fields) {
        if ("_dummy".equals(f.stringValue())) {
            found = true;
            break;
        }
    }
    assertTrue("Could not find the dummy field among " + Arrays.toString(fields), found);
}
Also used : IndicesModule(org.elasticsearch.indices.IndicesModule) BytesArray(org.elasticsearch.common.bytes.BytesArray) IndexService(org.elasticsearch.index.IndexService) IndexableField(org.apache.lucene.index.IndexableField) MapperRegistry(org.elasticsearch.indices.mapper.MapperRegistry) CompressedXContent(org.elasticsearch.common.compress.CompressedXContent) QueryShardContext(org.elasticsearch.index.query.QueryShardContext)

Aggregations

IndicesModule (org.elasticsearch.indices.IndicesModule)9 ArrayList (java.util.ArrayList)5 NamedWriteableRegistry (org.elasticsearch.common.io.stream.NamedWriteableRegistry)5 SearchModule (org.elasticsearch.search.SearchModule)4 NamedXContentRegistry (org.elasticsearch.common.xcontent.NamedXContentRegistry)3 CompressedXContent (org.elasticsearch.common.compress.CompressedXContent)2 Settings (org.elasticsearch.common.settings.Settings)2 AbstractQueryTestCase (org.elasticsearch.test.AbstractQueryTestCase)2 HashSet (java.util.HashSet)1 StandardAnalyzer (org.apache.lucene.analysis.standard.StandardAnalyzer)1 IndexableField (org.apache.lucene.index.IndexableField)1 BytesArray (org.elasticsearch.common.bytes.BytesArray)1 BigArrays (org.elasticsearch.common.util.BigArrays)1 XContentBuilder (org.elasticsearch.common.xcontent.XContentBuilder)1 Environment (org.elasticsearch.env.Environment)1 NodeEnvironment (org.elasticsearch.env.NodeEnvironment)1 Index (org.elasticsearch.index.Index)1 IndexService (org.elasticsearch.index.IndexService)1 IndexSettings (org.elasticsearch.index.IndexSettings)1 IndexAnalyzers (org.elasticsearch.index.analysis.IndexAnalyzers)1