Package org.elasticsearch.index.service

Examples of org.elasticsearch.index.service.IndexService


        return new ExistsResponse(exists, shardsResponses.length(), successfulShards, failedShards, shardFailures);
    }

    @Override
    protected ShardExistsResponse shardOperation(ShardExistsRequest request) throws ElasticsearchException {
        IndexService indexService = indicesService.indexServiceSafe(request.shardId().getIndex());
        IndexShard indexShard = indexService.shardSafe(request.shardId().id());

        SearchShardTarget shardTarget = new SearchShardTarget(clusterService.localNode().id(), request.shardId().getIndex(), request.shardId().id());
        SearchContext context = new DefaultSearchContext(0,
                new ShardSearchLocalRequest(request.types(), request.nowInMillis(), request.filteringAliases()),
                shardTarget, indexShard.acquireSearcher("exists"), indexService, indexShard,
                scriptService, pageCacheRecycler, bigArrays, threadPool.estimatedTimeInMillisCounter());
        SearchContext.setCurrent(context);

        try {
            if (request.minScore() != DEFAULT_MIN_SCORE) {
                context.minimumScore(request.minScore());
            }
            BytesReference source = request.querySource();
            if (source != null && source.length() > 0) {
                try {
                    QueryParseContext.setTypes(request.types());
                    context.parsedQuery(indexService.queryParserService().parseQuery(source));
                } finally {
                    QueryParseContext.removeTypes();
                }
            }
            context.preProcess();
View Full Code Here


        }
    }

    @Override
    protected GetResponse shardOperation(GetRequest request, ShardId shardId) throws ElasticsearchException {
        IndexService indexService = indicesService.indexServiceSafe(shardId.getIndex());
        IndexShard indexShard = indexService.shardSafe(shardId.id());

        if (request.refresh() && !request.realtime()) {
            indexShard.refresh(new Engine.Refresh("refresh_flag_get").force(REFRESH_FORCE));
        }
View Full Code Here

        return new ValidateQueryResponse(valid, queryExplanations, shardsResponses.length(), successfulShards, failedShards, shardFailures);
    }

    @Override
    protected ShardValidateQueryResponse shardOperation(ShardValidateQueryRequest request) throws ElasticsearchException {
        IndexService indexService = indicesService.indexServiceSafe(request.shardId().getIndex());
        IndexQueryParserService queryParserService = indexService.queryParserService();
        IndexShard indexShard = indexService.shardSafe(request.shardId().id());

        boolean valid;
        String explanation = null;
        String error = null;
View Full Code Here

    }

    @Override
    protected GetFieldMappingsResponse shardOperation(final GetFieldMappingsIndexRequest request, ShardId shardId) throws ElasticsearchException {
        assert shardId != null;
        IndexService indexService = indicesService.indexServiceSafe(shardId.getIndex());
        Collection<String> typeIntersection;
        if (request.types().length == 0) {
            typeIntersection = indexService.mapperService().types();

        } else {
            typeIntersection = Collections2.filter(indexService.mapperService().types(), new Predicate<String>() {

                @Override
                public boolean apply(String type) {
                    return Regex.simpleMatch(request.types(), type);
                }

            });
            if (typeIntersection.isEmpty()) {
                throw new TypeMissingException(shardId.index(), request.types());
            }
        }

        MapBuilder<String, ImmutableMap<String, FieldMappingMetaData>> typeMappings = new MapBuilder<>();
        for (String type : typeIntersection) {
            DocumentMapper documentMapper = indexService.mapperService().documentMapper(type);
            ImmutableMap<String, FieldMappingMetaData> fieldMapping = findFieldMappingsByType(documentMapper, request);
            if (!fieldMapping.isEmpty()) {
                typeMappings.put(type, fieldMapping);
            }
        }
View Full Code Here

*/
public class IndexAliasesServiceTests extends ElasticsearchSingleNodeTest {

    public IndexAliasesService newIndexAliasesService() {
        Settings settings = ImmutableSettings.builder().put("name", "IndexAliasesServiceTests").build();
        IndexService indexService = createIndex("test", settings);
        return indexService.aliasesService();
    }
View Full Code Here

    private static CodecService createCodecService() {
        return createCodecService(ImmutableSettings.Builder.EMPTY_SETTINGS);
    }

    private static CodecService createCodecService(Settings settings) {
        IndexService indexService = createIndex("test", settings);
        return indexService.injector().getInstance(CodecService.class);
    }
View Full Code Here

    private Injector injector;
    private IndexQueryParserService queryParser;

    @Before
    public void setup() throws IOException {
        IndexService indexService = createIndex("test");
        injector = indexService.injector();

        MapperService mapperService = indexService.mapperService();
        String mapping = copyToStringFromClasspath("/org/elasticsearch/index/query/mapping.json");
        mapperService.merge("person", new CompressedString(mapping), true);
        mapperService.documentMapper("person").parse(new BytesArray(copyToBytesFromClasspath("/org/elasticsearch/index/query/data.json")));
        queryParser = injector.getInstance(IndexQueryParserService.class);
    }
View Full Code Here

*/
public class SimpleMapperTests extends ElasticsearchSingleNodeTest {

    @Test
    public void testSimpleMapper() throws Exception {
        IndexService indexService = createIndex("test");
        Settings settings = indexService.settingsService().getSettings();
        DocumentMapperParser mapperParser = indexService.mapperService().documentMapperParser();
        DocumentMapper docMapper = doc("test", settings,
                rootObject("person")
                        .add(object("name").add(stringField("first").store(true).index(false)))
        ).build(mapperParser);

View Full Code Here

        assertThat((String) builtDocMapper.meta().get("param1"), equalTo("value1"));
    }

    @Test
    public void testNoDocumentSent() throws Exception {
        IndexService indexService = createIndex("test");
        Settings settings = indexService.settingsService().getSettings();
        DocumentMapperParser mapperParser = indexService.mapperService().documentMapperParser();
        DocumentMapper docMapper = doc("test", settings,
                rootObject("person")
                        .add(object("name").add(stringField("first").store(true).index(false)))
        ).build(mapperParser);
View Full Code Here

    public void testDefaultNotAppliedOnUpdate() throws Exception {
        XContentBuilder defaultMapping = XContentFactory.jsonBuilder().startObject().startObject(MapperService.DEFAULT_MAPPING)
                .startObject("_source").array("includes", "default_field_path.").endObject()
                .endObject().endObject();

        IndexService indexService = createIndex("test", ImmutableSettings.EMPTY, MapperService.DEFAULT_MAPPING, defaultMapping);

        String mapping = XContentFactory.jsonBuilder().startObject().startObject("my_type")
                .startObject("_source").array("includes", "custom_field_path.").endObject()
                .endObject().endObject().string();
        client().admin().indices().preparePutMapping("test").setType("my_type").setSource(mapping).get();

        DocumentMapper mapper = indexService.mapperService().documentMapper("my_type");
        assertThat(mapper.type(), equalTo("my_type"));
        assertThat(mapper.sourceMapper().includes().length, equalTo(2));
        List<String> includes = Arrays.asList(mapper.sourceMapper().includes());
        assertThat("default_field_path.", isIn(includes));
        assertThat("custom_field_path.", isIn(includes));

        mapping = XContentFactory.jsonBuilder().startObject().startObject("my_type")
                .startObject("properties").startObject("text").field("type", "string").endObject().endObject()
                .endObject().endObject().string();
        client().admin().indices().preparePutMapping("test").setType("my_type").setSource(mapping).get();

        mapper = indexService.mapperService().documentMapper("my_type");
        assertThat(mapper.type(), equalTo("my_type"));
        includes = Arrays.asList(mapper.sourceMapper().includes());
        assertThat("default_field_path.", isIn(includes));
        assertThat("custom_field_path.", isIn(includes));
        assertThat(mapper.sourceMapper().includes().length, equalTo(2));
View Full Code Here

TOP

Related Classes of org.elasticsearch.index.service.IndexService

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.