From 81449fc91291b09f545873f331495b82fab4ff5b Mon Sep 17 00:00:00 2001 From: Martijn van Groningen Date: Tue, 19 Apr 2016 15:59:09 +0200 Subject: [PATCH] percolator: renamed `percolator` query to `percolate` query --- .../action/percolate/PercolateResponse.java | 2 +- .../percolate/TransportPercolateAction.java | 11 ++--- .../PercolatorHighlightSubFetchPhase.java | 24 +++++----- .../percolator/PercolatorQueryCache.java | 4 +- ...rcolatorQuery.java => PercolateQuery.java} | 25 +++++----- ...uilder.java => PercolateQueryBuilder.java} | 38 +++++++-------- .../index/query/QueryBuilders.java | 21 ++++---- .../elasticsearch/search/SearchModule.java | 4 +- ...PercolatorHighlightSubFetchPhaseTests.java | 20 ++++---- .../percolator/PercolatorQueryCacheTests.java | 10 ++-- ...s.java => PercolateQueryBuilderTests.java} | 48 +++++++++---------- ...eryTests.java => PercolateQueryTests.java} | 13 +++-- .../search/SearchModuleTests.java | 2 +- .../percolator/PercolatorQuerySearchIT.java | 25 +++++----- ...uery.asciidoc => percolate-query.asciidoc} | 17 ++++--- .../query-dsl/special-queries.asciidoc | 2 +- docs/reference/cat/thread_pool.asciidoc | 1 - .../reference/docs/multi-termvectors.asciidoc | 3 +- docs/reference/docs/termvectors.asciidoc | 3 +- .../mapping/types/percolator.asciidoc | 4 +- .../migration/migrate_5_0/percolator.asciidoc | 13 ++--- ...uery.asciidoc => percolate-query.asciidoc} | 38 +++++++-------- .../query-dsl/special-queries.asciidoc | 4 +- docs/reference/search/percolate.asciidoc | 4 +- 24 files changed, 162 insertions(+), 174 deletions(-) rename core/src/main/java/org/elasticsearch/index/query/{PercolatorQuery.java => PercolateQuery.java} (92%) rename core/src/main/java/org/elasticsearch/index/query/{PercolatorQueryBuilder.java => PercolateQueryBuilder.java} (92%) rename core/src/test/java/org/elasticsearch/index/query/{PercolatorQueryBuilderTests.java => PercolateQueryBuilderTests.java} (80%) rename core/src/test/java/org/elasticsearch/index/query/{PercolatorQueryTests.java => PercolateQueryTests.java} (97%) rename docs/java-api/query-dsl/{percolator-query.asciidoc => percolate-query.asciidoc} (72%) rename docs/reference/query-dsl/{percolator-query.asciidoc => percolate-query.asciidoc} (88%) diff --git a/core/src/main/java/org/elasticsearch/action/percolate/PercolateResponse.java b/core/src/main/java/org/elasticsearch/action/percolate/PercolateResponse.java index 1ebf1cad3ec..110ed37342f 100644 --- a/core/src/main/java/org/elasticsearch/action/percolate/PercolateResponse.java +++ b/core/src/main/java/org/elasticsearch/action/percolate/PercolateResponse.java @@ -45,7 +45,7 @@ import java.util.Map; public class PercolateResponse extends BroadcastResponse implements Iterable, ToXContent { public static final Match[] EMPTY = new Match[0]; - // PercolatorQuery emits this score if no 'query' is defined in the percolate request + // PercolateQuery emits this score if no 'query' is defined in the percolate request public final static float NO_SCORE = 0.0f; private long tookInMillis; diff --git a/core/src/main/java/org/elasticsearch/action/percolate/TransportPercolateAction.java b/core/src/main/java/org/elasticsearch/action/percolate/TransportPercolateAction.java index ec587a2b33b..5c8b20b1f92 100644 --- a/core/src/main/java/org/elasticsearch/action/percolate/TransportPercolateAction.java +++ b/core/src/main/java/org/elasticsearch/action/percolate/TransportPercolateAction.java @@ -42,7 +42,7 @@ import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.XContentType; import org.elasticsearch.index.query.BoolQueryBuilder; import org.elasticsearch.index.query.ConstantScoreQueryBuilder; -import org.elasticsearch.index.query.PercolatorQueryBuilder; +import org.elasticsearch.index.query.PercolateQueryBuilder; import org.elasticsearch.index.query.QueryBuilder; import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.index.query.QueryParseContext; @@ -57,7 +57,6 @@ import org.elasticsearch.transport.TransportService; import java.io.IOException; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; public class TransportPercolateAction extends HandledTransportAction { @@ -199,22 +198,22 @@ public class TransportPercolateAction extends HandledTransportAction queryBuilder = queryParseContext.parseInnerQueryBuilder(); BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery(); boolQueryBuilder.must(queryBuilder); - boolQueryBuilder.filter(percolatorQueryBuilder); + boolQueryBuilder.filter(percolateQueryBuilder); searchSource.field("query", boolQueryBuilder); } } else { // wrapping in a constant score query with boost 0 for bwc reason. // percolator api didn't emit scores before and never included scores // for how well percolator queries matched with the document being percolated - searchSource.field("query", new ConstantScoreQueryBuilder(percolatorQueryBuilder).boost(0f)); + searchSource.field("query", new ConstantScoreQueryBuilder(percolateQueryBuilder).boost(0f)); } searchSource.endObject(); diff --git a/core/src/main/java/org/elasticsearch/index/percolator/PercolatorHighlightSubFetchPhase.java b/core/src/main/java/org/elasticsearch/index/percolator/PercolatorHighlightSubFetchPhase.java index 71cf282d83f..9fb6934cca4 100644 --- a/core/src/main/java/org/elasticsearch/index/percolator/PercolatorHighlightSubFetchPhase.java +++ b/core/src/main/java/org/elasticsearch/index/percolator/PercolatorHighlightSubFetchPhase.java @@ -31,7 +31,7 @@ import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.text.Text; import org.elasticsearch.index.query.ParsedQuery; -import org.elasticsearch.index.query.PercolatorQuery; +import org.elasticsearch.index.query.PercolateQuery; import org.elasticsearch.search.SearchParseElement; import org.elasticsearch.search.fetch.FetchSubPhase; import org.elasticsearch.search.highlight.HighlightPhase; @@ -44,8 +44,8 @@ import java.util.Collections; import java.util.List; import java.util.Map; -// Highlighting in the case of the percolator query is a bit different, because the PercolatorQuery itself doesn't get highlighted, -// but the source of the PercolatorQuery gets highlighted by each hit with type '.percolator' (percolator queries). +// Highlighting in the case of the percolate query is a bit different, because the PercolateQuery itself doesn't get highlighted, +// but the source of the PercolateQuery gets highlighted by each hit with type '.percolator' (percolator queries). public class PercolatorHighlightSubFetchPhase implements FetchSubPhase { private final HighlightPhase highlightPhase; @@ -62,20 +62,20 @@ public class PercolatorHighlightSubFetchPhase implements FetchSubPhase { @Override public void hitsExecute(SearchContext context, InternalSearchHit[] hits) { - PercolatorQuery percolatorQuery = locatePercolatorQuery(context.query()); - if (percolatorQuery == null) { + PercolateQuery percolateQuery = locatePercolatorQuery(context.query()); + if (percolateQuery == null) { // shouldn't happen as we checked for the existence of a percolator query in hitsExecutionNeeded(...) throw new IllegalStateException("couldn't locate percolator query"); } List ctxs = context.searcher().getIndexReader().leaves(); PercolatorQueryCache queriesRegistry = context.percolatorQueryCache(); - IndexSearcher percolatorIndexSearcher = percolatorQuery.getPercolatorIndexSearcher(); + IndexSearcher percolatorIndexSearcher = percolateQuery.getPercolatorIndexSearcher(); LeafReaderContext percolatorLeafReaderContext = percolatorIndexSearcher.getIndexReader().leaves().get(0); FetchSubPhase.HitContext hitContext = new FetchSubPhase.HitContext(); SubSearchContext subSearchContext = - createSubSearchContext(context, percolatorLeafReaderContext, percolatorQuery.getDocumentSource()); + createSubSearchContext(context, percolatorLeafReaderContext, percolateQuery.getDocumentSource()); for (InternalSearchHit hit : hits) { LeafReaderContext ctx = ctxs.get(ReaderUtil.subIndex(hit.docId(), ctxs)); @@ -84,7 +84,7 @@ public class PercolatorHighlightSubFetchPhase implements FetchSubPhase { if (query != null) { subSearchContext.parsedQuery(new ParsedQuery(query)); hitContext.reset( - new InternalSearchHit(0, "unknown", new Text(percolatorQuery.getDocumentType()), Collections.emptyMap()), + new InternalSearchHit(0, "unknown", new Text(percolateQuery.getDocumentType()), Collections.emptyMap()), percolatorLeafReaderContext, 0, percolatorIndexSearcher ); hitContext.cache().clear(); @@ -108,12 +108,12 @@ public class PercolatorHighlightSubFetchPhase implements FetchSubPhase { public void hitExecute(SearchContext context, HitContext hitContext) { } - static PercolatorQuery locatePercolatorQuery(Query query) { - if (query instanceof PercolatorQuery) { - return (PercolatorQuery) query; + static PercolateQuery locatePercolatorQuery(Query query) { + if (query instanceof PercolateQuery) { + return (PercolateQuery) query; } else if (query instanceof BooleanQuery) { for (BooleanClause clause : ((BooleanQuery) query).clauses()) { - PercolatorQuery result = locatePercolatorQuery(clause.getQuery()); + PercolateQuery result = locatePercolatorQuery(clause.getQuery()); if (result != null) { return result; } diff --git a/core/src/main/java/org/elasticsearch/index/percolator/PercolatorQueryCache.java b/core/src/main/java/org/elasticsearch/index/percolator/PercolatorQueryCache.java index 2d6f65d4e0b..e7ca6c3d427 100644 --- a/core/src/main/java/org/elasticsearch/index/percolator/PercolatorQueryCache.java +++ b/core/src/main/java/org/elasticsearch/index/percolator/PercolatorQueryCache.java @@ -55,7 +55,7 @@ import org.elasticsearch.index.mapper.FieldMapper; import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.mapper.internal.SourceFieldMapper; import org.elasticsearch.index.mapper.internal.TypeFieldMapper; -import org.elasticsearch.index.query.PercolatorQuery; +import org.elasticsearch.index.query.PercolateQuery; import org.elasticsearch.index.query.QueryShardContext; import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.index.shard.ShardId; @@ -73,7 +73,7 @@ import static org.elasticsearch.index.percolator.PercolatorFieldMapper.Percolato import static org.elasticsearch.index.percolator.PercolatorFieldMapper.parseQuery; public final class PercolatorQueryCache extends AbstractIndexComponent - implements Closeable, LeafReader.CoreClosedListener, PercolatorQuery.QueryRegistry { + implements Closeable, LeafReader.CoreClosedListener, PercolateQuery.QueryRegistry { public final static Setting INDEX_MAP_UNMAPPED_FIELDS_AS_STRING_SETTING = Setting.boolSetting("index.percolator.map_unmapped_fields_as_string", false, Setting.Property.IndexScope); diff --git a/core/src/main/java/org/elasticsearch/index/query/PercolatorQuery.java b/core/src/main/java/org/elasticsearch/index/query/PercolateQuery.java similarity index 92% rename from core/src/main/java/org/elasticsearch/index/query/PercolatorQuery.java rename to core/src/main/java/org/elasticsearch/index/query/PercolateQuery.java index 70648663515..e99687422db 100644 --- a/core/src/main/java/org/elasticsearch/index/query/PercolatorQuery.java +++ b/core/src/main/java/org/elasticsearch/index/query/PercolateQuery.java @@ -23,14 +23,11 @@ import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.LeafReaderContext; import org.apache.lucene.index.Term; import org.apache.lucene.search.BooleanQuery; -import org.apache.lucene.search.ConstantScoreQuery; import org.apache.lucene.search.DocIdSetIterator; import org.apache.lucene.search.Explanation; import org.apache.lucene.search.IndexSearcher; -import org.apache.lucene.search.MatchAllDocsQuery; import org.apache.lucene.search.Query; import org.apache.lucene.search.Scorer; -import org.apache.lucene.search.SimpleCollector; import org.apache.lucene.search.TopDocs; import org.apache.lucene.search.TwoPhaseIterator; import org.apache.lucene.search.Weight; @@ -45,7 +42,7 @@ import java.util.Set; import static org.apache.lucene.search.BooleanClause.Occur.FILTER; -public final class PercolatorQuery extends Query implements Accountable { +public final class PercolateQuery extends Query implements Accountable { // cost of matching the query against the document, arbitrary as it would be really complex to estimate public static final float MATCH_COST = 1000; @@ -93,7 +90,7 @@ public final class PercolatorQuery extends Query implements Accountable { this.percolateTypeQuery = Objects.requireNonNull(percolateTypeQuery); } - public PercolatorQuery build() { + public PercolateQuery build() { if (percolateTypeQuery != null && queriesMetaDataQuery != null) { throw new IllegalStateException("Either filter by deprecated percolator type or by query metadata"); } @@ -107,7 +104,7 @@ public final class PercolatorQuery extends Query implements Accountable { builder.add(queriesMetaDataQuery, FILTER); } - return new PercolatorQuery(docType, queryRegistry, documentSource, builder.build(), percolatorIndexSearcher); + return new PercolateQuery(docType, queryRegistry, documentSource, builder.build(), percolatorIndexSearcher); } } @@ -118,8 +115,8 @@ public final class PercolatorQuery extends Query implements Accountable { private final Query percolatorQueriesQuery; private final IndexSearcher percolatorIndexSearcher; - private PercolatorQuery(String documentType, QueryRegistry queryRegistry, BytesReference documentSource, - Query percolatorQueriesQuery, IndexSearcher percolatorIndexSearcher) { + private PercolateQuery(String documentType, QueryRegistry queryRegistry, BytesReference documentSource, + Query percolatorQueriesQuery, IndexSearcher percolatorIndexSearcher) { this.documentType = documentType; this.documentSource = documentSource; this.percolatorQueriesQuery = percolatorQueriesQuery; @@ -131,7 +128,7 @@ public final class PercolatorQuery extends Query implements Accountable { public Query rewrite(IndexReader reader) throws IOException { Query rewritten = percolatorQueriesQuery.rewrite(reader); if (rewritten != percolatorQueriesQuery) { - return new PercolatorQuery(documentType, queryRegistry, documentSource, rewritten, percolatorIndexSearcher); + return new PercolateQuery(documentType, queryRegistry, documentSource, rewritten, percolatorIndexSearcher); } else { return this; } @@ -157,14 +154,14 @@ public final class PercolatorQuery extends Query implements Accountable { QueryRegistry.Leaf percolatorQueries = queryRegistry.getQueries(leafReaderContext); Query query = percolatorQueries.getQuery(docId); Explanation detail = percolatorIndexSearcher.explain(query, 0); - return Explanation.match(scorer.score(), "PercolatorQuery", detail); + return Explanation.match(scorer.score(), "PercolateQuery", detail); } else { - return Explanation.match(scorer.score(), "PercolatorQuery"); + return Explanation.match(scorer.score(), "PercolateQuery"); } } } } - return Explanation.noMatch("PercolatorQuery"); + return Explanation.noMatch("PercolateQuery"); } @Override @@ -247,7 +244,7 @@ public final class PercolatorQuery extends Query implements Accountable { if (o == null || getClass() != o.getClass()) return false; if (!super.equals(o)) return false; - PercolatorQuery that = (PercolatorQuery) o; + PercolateQuery that = (PercolateQuery) o; if (!documentType.equals(that.documentType)) return false; return documentSource.equals(that.documentSource); @@ -264,7 +261,7 @@ public final class PercolatorQuery extends Query implements Accountable { @Override public String toString(String s) { - return "PercolatorQuery{document_type={" + documentType + "},document_source={" + documentSource.toUtf8() + + return "PercolateQuery{document_type={" + documentType + "},document_source={" + documentSource.toUtf8() + "},inner={" + percolatorQueriesQuery.toString(s) + "}}"; } diff --git a/core/src/main/java/org/elasticsearch/index/query/PercolatorQueryBuilder.java b/core/src/main/java/org/elasticsearch/index/query/PercolateQueryBuilder.java similarity index 92% rename from core/src/main/java/org/elasticsearch/index/query/PercolatorQueryBuilder.java rename to core/src/main/java/org/elasticsearch/index/query/PercolateQueryBuilder.java index a459131560f..257460964d3 100644 --- a/core/src/main/java/org/elasticsearch/index/query/PercolatorQueryBuilder.java +++ b/core/src/main/java/org/elasticsearch/index/query/PercolateQueryBuilder.java @@ -67,9 +67,9 @@ import java.util.Objects; import static org.elasticsearch.index.mapper.SourceToParse.source; -public class PercolatorQueryBuilder extends AbstractQueryBuilder { +public class PercolateQueryBuilder extends AbstractQueryBuilder { - public static final String NAME = "percolator"; + public static final String NAME = "percolate"; public static final ParseField QUERY_NAME_FIELD = new ParseField(NAME); static final ParseField DOCUMENT_FIELD = new ParseField("document"); @@ -93,7 +93,7 @@ public class PercolatorQueryBuilder extends AbstractQueryBuilder null, new BytesArray("{}"), + PercolateQuery percolateQuery = new PercolateQuery.Builder("", ctx -> null, new BytesArray("{}"), Mockito.mock(IndexSearcher.class)) .build(); @@ -55,12 +55,12 @@ public class PercolatorHighlightSubFetchPhaseTests extends ESTestCase { () -> subFetchPhase.hitsExecute(searchContext, null)); assertThat(exception.getMessage(), equalTo("couldn't locate percolator query")); - Mockito.when(searchContext.query()).thenReturn(percolatorQuery); + Mockito.when(searchContext.query()).thenReturn(percolateQuery); assertThat(subFetchPhase.hitsExecutionNeeded(searchContext), is(true)); } public void testLocatePercolatorQuery() { - PercolatorQuery percolatorQuery = new PercolatorQuery.Builder("", ctx -> null, new BytesArray("{}"), + PercolateQuery percolateQuery = new PercolateQuery.Builder("", ctx -> null, new BytesArray("{}"), Mockito.mock(IndexSearcher.class)) .build(); @@ -68,18 +68,18 @@ public class PercolatorHighlightSubFetchPhaseTests extends ESTestCase { BooleanQuery.Builder bq = new BooleanQuery.Builder(); bq.add(new MatchAllDocsQuery(), BooleanClause.Occur.FILTER); assertThat(PercolatorHighlightSubFetchPhase.locatePercolatorQuery(bq.build()), nullValue()); - bq.add(percolatorQuery, BooleanClause.Occur.FILTER); - assertThat(PercolatorHighlightSubFetchPhase.locatePercolatorQuery(bq.build()), sameInstance(percolatorQuery)); + bq.add(percolateQuery, BooleanClause.Occur.FILTER); + assertThat(PercolatorHighlightSubFetchPhase.locatePercolatorQuery(bq.build()), sameInstance(percolateQuery)); ConstantScoreQuery constantScoreQuery = new ConstantScoreQuery(new MatchAllDocsQuery()); assertThat(PercolatorHighlightSubFetchPhase.locatePercolatorQuery(constantScoreQuery), nullValue()); - constantScoreQuery = new ConstantScoreQuery(percolatorQuery); - assertThat(PercolatorHighlightSubFetchPhase.locatePercolatorQuery(constantScoreQuery), sameInstance(percolatorQuery)); + constantScoreQuery = new ConstantScoreQuery(percolateQuery); + assertThat(PercolatorHighlightSubFetchPhase.locatePercolatorQuery(constantScoreQuery), sameInstance(percolateQuery)); BoostQuery boostQuery = new BoostQuery(new MatchAllDocsQuery(), 1f); assertThat(PercolatorHighlightSubFetchPhase.locatePercolatorQuery(boostQuery), nullValue()); - boostQuery = new BoostQuery(percolatorQuery, 1f); - assertThat(PercolatorHighlightSubFetchPhase.locatePercolatorQuery(boostQuery), sameInstance(percolatorQuery)); + boostQuery = new BoostQuery(percolateQuery, 1f); + assertThat(PercolatorHighlightSubFetchPhase.locatePercolatorQuery(boostQuery), sameInstance(percolateQuery)); } } diff --git a/core/src/test/java/org/elasticsearch/index/percolator/PercolatorQueryCacheTests.java b/core/src/test/java/org/elasticsearch/index/percolator/PercolatorQueryCacheTests.java index 4f9dbeb5296..bf7570f1007 100644 --- a/core/src/test/java/org/elasticsearch/index/percolator/PercolatorQueryCacheTests.java +++ b/core/src/test/java/org/elasticsearch/index/percolator/PercolatorQueryCacheTests.java @@ -45,9 +45,7 @@ import org.elasticsearch.Version; import org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.IndexMetaData; -import org.elasticsearch.common.ParseField; import org.elasticsearch.common.bytes.BytesReference; -import org.elasticsearch.common.collect.Tuple; import org.elasticsearch.common.compress.CompressedXContent; import org.elasticsearch.common.lucene.index.ElasticsearchDirectoryReader; import org.elasticsearch.common.settings.Settings; @@ -65,7 +63,7 @@ import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.mapper.internal.SourceFieldMapper; import org.elasticsearch.index.mapper.internal.TypeFieldMapper; import org.elasticsearch.index.query.BoolQueryBuilder; -import org.elasticsearch.index.query.PercolatorQuery; +import org.elasticsearch.index.query.PercolateQuery; import org.elasticsearch.index.query.QueryBuilder; import org.elasticsearch.index.query.QueryParser; import org.elasticsearch.index.query.QueryShardContext; @@ -84,8 +82,6 @@ import org.elasticsearch.threadpool.ThreadPool; import java.io.IOException; import java.util.Collections; -import java.util.HashMap; -import java.util.Map; import static org.elasticsearch.index.query.QueryBuilders.boolQuery; import static org.elasticsearch.index.query.QueryBuilders.termQuery; @@ -224,7 +220,7 @@ public class PercolatorQueryCacheTests extends ESTestCase { PercolatorQueryCacheStats stats = cache.getStats(shardId); assertThat(stats.getNumQueries(), equalTo(9L)); - PercolatorQuery.QueryRegistry.Leaf leaf = cache.getQueries(indexReader.leaves().get(0)); + PercolateQuery.QueryRegistry.Leaf leaf = cache.getQueries(indexReader.leaves().get(0)); assertThat(leaf.getQuery(0), equalTo(new TermQuery(new Term("a", "0")))); assertThat(leaf.getQuery(1), equalTo(new TermQuery(new Term("a", "1")))); assertThat(leaf.getQuery(2), equalTo(new TermQuery(new Term("a", "2")))); @@ -270,7 +266,7 @@ public class PercolatorQueryCacheTests extends ESTestCase { listener.warmReader(indexShard, new Engine.Searcher("test", new IndexSearcher(indexReader))); assertThat(cache.getStats(shardId).getNumQueries(), equalTo(3L)); - PercolatorQuery.QueryRegistry.Leaf leaf = cache.getQueries(indexReader.leaves().get(0)); + PercolateQuery.QueryRegistry.Leaf leaf = cache.getQueries(indexReader.leaves().get(0)); assertThat(leaf.getQuery(0), equalTo(new TermQuery(new Term("a", "0")))); leaf = cache.getQueries(indexReader.leaves().get(1)); diff --git a/core/src/test/java/org/elasticsearch/index/query/PercolatorQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/PercolateQueryBuilderTests.java similarity index 80% rename from core/src/test/java/org/elasticsearch/index/query/PercolatorQueryBuilderTests.java rename to core/src/test/java/org/elasticsearch/index/query/PercolateQueryBuilderTests.java index 976fb6fbfae..59d79378caa 100644 --- a/core/src/test/java/org/elasticsearch/index/query/PercolatorQueryBuilderTests.java +++ b/core/src/test/java/org/elasticsearch/index/query/PercolateQueryBuilderTests.java @@ -47,10 +47,10 @@ import java.util.Set; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.equalTo; -public class PercolatorQueryBuilderTests extends AbstractQueryTestCase { +public class PercolateQueryBuilderTests extends AbstractQueryTestCase { private static final Set SHUFFLE_PROTECTED_FIELDS = - Collections.singleton(PercolatorQueryBuilder.DOCUMENT_FIELD.getPreferredName()); + Collections.singleton(PercolateQueryBuilder.DOCUMENT_FIELD.getPreferredName()); private static String queryField; private static String docType; @@ -79,11 +79,11 @@ public class PercolatorQueryBuilderTests extends AbstractQueryTestCase pqb.toQuery(createShardContext())); assertThat(e.getMessage(), equalTo("query builder must be rewritten first")); QueryBuilder rewrite = pqb.rewrite(createShardContext()); - PercolatorQueryBuilder geoShapeQueryBuilder = new PercolatorQueryBuilder(pqb.getField(), pqb.getDocumentType(), documentSource); + PercolateQueryBuilder geoShapeQueryBuilder = new PercolateQueryBuilder(pqb.getField(), pqb.getDocumentType(), documentSource); assertEquals(geoShapeQueryBuilder, rewrite); } public void testIndexedDocumentDoesNotExist() throws IOException { indexedDocumentExists = false; - PercolatorQueryBuilder pqb = doCreateTestQueryBuilder(true); + PercolateQueryBuilder pqb = doCreateTestQueryBuilder(true); ResourceNotFoundException e = expectThrows(ResourceNotFoundException.class, () -> pqb.rewrite(createShardContext())); String expectedString = "indexed document [" + indexedDocumentIndex + "/" + indexedDocumentType + "/" + indexedDocumentId + "] couldn't be found"; @@ -185,46 +185,46 @@ public class PercolatorQueryBuilderTests extends AbstractQueryTestCase { - QueryBuilders.percolatorQuery(null, null, new BytesArray("{}")); + QueryBuilders.percolateQuery(null, null, new BytesArray("{}")); }); assertThat(e.getMessage(), equalTo("[field] is a required argument")); - e = expectThrows(IllegalArgumentException.class, () -> QueryBuilders.percolatorQuery("_field", null, new BytesArray("{}"))); + e = expectThrows(IllegalArgumentException.class, () -> QueryBuilders.percolateQuery("_field", null, new BytesArray("{}"))); assertThat(e.getMessage(), equalTo("[document_type] is a required argument")); - e = expectThrows(IllegalArgumentException.class, () -> QueryBuilders.percolatorQuery("_field", "_document_type", null)); + e = expectThrows(IllegalArgumentException.class, () -> QueryBuilders.percolateQuery("_field", "_document_type", null)); assertThat(e.getMessage(), equalTo("[document] is a required argument")); e = expectThrows(IllegalArgumentException.class, () -> { - QueryBuilders.percolatorQuery(null, null, "_index", "_type", "_id", null, null, null); + QueryBuilders.percolateQuery(null, null, "_index", "_type", "_id", null, null, null); }); assertThat(e.getMessage(), equalTo("[field] is a required argument")); e = expectThrows(IllegalArgumentException.class, () -> { - QueryBuilders.percolatorQuery("_field", null, "_index", "_type", "_id", null, null, null); + QueryBuilders.percolateQuery("_field", null, "_index", "_type", "_id", null, null, null); }); assertThat(e.getMessage(), equalTo("[document_type] is a required argument")); e = expectThrows(IllegalArgumentException.class, () -> { - QueryBuilders.percolatorQuery("_field", "_document_type", null, "_type", "_id", null, null, null); + QueryBuilders.percolateQuery("_field", "_document_type", null, "_type", "_id", null, null, null); }); assertThat(e.getMessage(), equalTo("[index] is a required argument")); e = expectThrows(IllegalArgumentException.class, () -> { - QueryBuilders.percolatorQuery("_field", "_document_type", "_index", null, "_id", null, null, null); + QueryBuilders.percolateQuery("_field", "_document_type", "_index", null, "_id", null, null, null); }); assertThat(e.getMessage(), equalTo("[type] is a required argument")); e = expectThrows(IllegalArgumentException.class, () -> { - QueryBuilders.percolatorQuery("_field", "_document_type", "_index", "_type", null, null, null, null); + QueryBuilders.percolateQuery("_field", "_document_type", "_index", "_type", null, null, null, null); }); assertThat(e.getMessage(), equalTo("[id] is a required argument")); } public void testFromJsonNoDocumentType() throws IOException { IllegalArgumentException e = expectThrows(IllegalArgumentException.class, - () -> parseQuery("{\"percolator\" : { \"document\": {}}")); - assertThat(e.getMessage(), equalTo("[percolator] query is missing required [document_type] parameter")); + () -> parseQuery("{\"percolate\" : { \"document\": {}}")); + assertThat(e.getMessage(), equalTo("[percolate] query is missing required [document_type] parameter")); } private static BytesReference randomSource() { diff --git a/core/src/test/java/org/elasticsearch/index/query/PercolatorQueryTests.java b/core/src/test/java/org/elasticsearch/index/query/PercolateQueryTests.java similarity index 97% rename from core/src/test/java/org/elasticsearch/index/query/PercolatorQueryTests.java rename to core/src/test/java/org/elasticsearch/index/query/PercolateQueryTests.java index 7ed947c7db0..acb4917b421 100644 --- a/core/src/test/java/org/elasticsearch/index/query/PercolatorQueryTests.java +++ b/core/src/test/java/org/elasticsearch/index/query/PercolateQueryTests.java @@ -54,7 +54,6 @@ import org.apache.lucene.store.Directory; import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.index.mapper.ParseContext; import org.elasticsearch.index.mapper.Uid; -import org.elasticsearch.index.mapper.internal.TypeFieldMapper; import org.elasticsearch.index.mapper.internal.UidFieldMapper; import org.elasticsearch.index.percolator.ExtractQueryTermsService; import org.elasticsearch.index.percolator.PercolatorFieldMapper; @@ -70,7 +69,7 @@ import static org.hamcrest.Matchers.arrayWithSize; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.is; -public class PercolatorQueryTests extends ESTestCase { +public class PercolateQueryTests extends ESTestCase { public final static String EXTRACTED_TERMS_FIELD_NAME = "extracted_terms"; public final static String UNKNOWN_QUERY_FIELD_NAME = "unknown_query"; @@ -85,7 +84,7 @@ public class PercolatorQueryTests extends ESTestCase { private Directory directory; private IndexWriter indexWriter; private Map queries; - private PercolatorQuery.QueryRegistry queryRegistry; + private PercolateQuery.QueryRegistry queryRegistry; private DirectoryReader directoryReader; @Before @@ -144,7 +143,7 @@ public class PercolatorQueryTests extends ESTestCase { memoryIndex.addField("field", "the quick brown fox jumps over the lazy dog", new WhitespaceAnalyzer()); IndexSearcher percolateSearcher = memoryIndex.createSearcher(); - PercolatorQuery.Builder builder = new PercolatorQuery.Builder( + PercolateQuery.Builder builder = new PercolateQuery.Builder( "docType", queryRegistry, new BytesArray("{}"), @@ -218,7 +217,7 @@ public class PercolatorQueryTests extends ESTestCase { memoryIndex.addField("field", "the quick brown fox jumps over the lazy dog", new WhitespaceAnalyzer()); IndexSearcher percolateSearcher = memoryIndex.createSearcher(); - PercolatorQuery.Builder builder = new PercolatorQuery.Builder( + PercolateQuery.Builder builder = new PercolateQuery.Builder( "docType", queryRegistry, new BytesArray("{}"), @@ -335,7 +334,7 @@ public class PercolatorQueryTests extends ESTestCase { private void duelRun(MemoryIndex memoryIndex, IndexSearcher shardSearcher) throws IOException { IndexSearcher percolateSearcher = memoryIndex.createSearcher(); - PercolatorQuery.Builder builder1 = new PercolatorQuery.Builder( + PercolateQuery.Builder builder1 = new PercolateQuery.Builder( "docType", queryRegistry, new BytesArray("{}"), @@ -345,7 +344,7 @@ public class PercolatorQueryTests extends ESTestCase { builder1.extractQueryTermsQuery(EXTRACTED_TERMS_FIELD_NAME, UNKNOWN_QUERY_FIELD_NAME); TopDocs topDocs1 = shardSearcher.search(builder1.build(), 10); - PercolatorQuery.Builder builder2 = new PercolatorQuery.Builder( + PercolateQuery.Builder builder2 = new PercolateQuery.Builder( "docType", queryRegistry, new BytesArray("{}"), diff --git a/core/src/test/java/org/elasticsearch/search/SearchModuleTests.java b/core/src/test/java/org/elasticsearch/search/SearchModuleTests.java index 393321e8e06..47f6e2ca3bc 100644 --- a/core/src/test/java/org/elasticsearch/search/SearchModuleTests.java +++ b/core/src/test/java/org/elasticsearch/search/SearchModuleTests.java @@ -164,7 +164,7 @@ public class SearchModuleTests extends ModuleTestCase { "nested", "parentId", "parent_id", - "percolator", + "percolate", "prefix", "queryString", "query_string", diff --git a/core/src/test/java/org/elasticsearch/search/percolator/PercolatorQuerySearchIT.java b/core/src/test/java/org/elasticsearch/search/percolator/PercolatorQuerySearchIT.java index b5c43c3c19c..0065e46875a 100644 --- a/core/src/test/java/org/elasticsearch/search/percolator/PercolatorQuerySearchIT.java +++ b/core/src/test/java/org/elasticsearch/search/percolator/PercolatorQuerySearchIT.java @@ -24,7 +24,6 @@ import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.index.query.MatchPhraseQueryBuilder; import org.elasticsearch.index.mapper.MapperParsingException; import org.elasticsearch.index.query.MultiMatchQueryBuilder; -import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.search.highlight.HighlightBuilder; import org.elasticsearch.search.sort.SortOrder; import org.elasticsearch.test.ESSingleNodeTestCase; @@ -35,7 +34,7 @@ import static org.elasticsearch.index.query.QueryBuilders.commonTermsQuery; import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; import static org.elasticsearch.index.query.QueryBuilders.matchQuery; import static org.elasticsearch.index.query.QueryBuilders.multiMatchQuery; -import static org.elasticsearch.index.query.QueryBuilders.percolatorQuery; +import static org.elasticsearch.index.query.QueryBuilders.percolateQuery; import static org.elasticsearch.index.query.QueryBuilders.spanNearQuery; import static org.elasticsearch.index.query.QueryBuilders.spanNotQuery; import static org.elasticsearch.index.query.QueryBuilders.spanTermQuery; @@ -69,7 +68,7 @@ public class PercolatorQuerySearchIT extends ESSingleNodeTestCase { BytesReference source = jsonBuilder().startObject().endObject().bytes(); logger.info("percolating empty doc"); SearchResponse response = client().prepareSearch() - .setQuery(percolatorQuery("query", "type", source)) + .setQuery(percolateQuery("query", "type", source)) .get(); assertHitCount(response, 1); assertThat(response.getHits().getAt(0).getId(), equalTo("1")); @@ -77,7 +76,7 @@ public class PercolatorQuerySearchIT extends ESSingleNodeTestCase { source = jsonBuilder().startObject().field("field1", "value").endObject().bytes(); logger.info("percolating doc with 1 field"); response = client().prepareSearch() - .setQuery(percolatorQuery("query", "type", source)) + .setQuery(percolateQuery("query", "type", source)) .addSort("_uid", SortOrder.ASC) .get(); assertHitCount(response, 2); @@ -87,7 +86,7 @@ public class PercolatorQuerySearchIT extends ESSingleNodeTestCase { source = jsonBuilder().startObject().field("field1", "value").field("field2", "value").endObject().bytes(); logger.info("percolating doc with 2 fields"); response = client().prepareSearch() - .setQuery(percolatorQuery("query", "type", source)) + .setQuery(percolateQuery("query", "type", source)) .addSort("_uid", SortOrder.ASC) .get(); assertHitCount(response, 3); @@ -121,14 +120,14 @@ public class PercolatorQuerySearchIT extends ESSingleNodeTestCase { logger.info("percolating empty doc"); SearchResponse response = client().prepareSearch() - .setQuery(percolatorQuery("query", "type", "test", "type", "1")) + .setQuery(percolateQuery("query", "type", "test", "type", "1")) .get(); assertHitCount(response, 1); assertThat(response.getHits().getAt(0).getId(), equalTo("1")); logger.info("percolating doc with 1 field"); response = client().prepareSearch() - .setQuery(percolatorQuery("query", "type", "test", "type", "2")) + .setQuery(percolateQuery("query", "type", "test", "type", "2")) .addSort("_uid", SortOrder.ASC) .get(); assertHitCount(response, 2); @@ -137,7 +136,7 @@ public class PercolatorQuerySearchIT extends ESSingleNodeTestCase { logger.info("percolating doc with 2 fields"); response = client().prepareSearch() - .setQuery(percolatorQuery("query", "type", "test", "type", "3")) + .setQuery(percolateQuery("query", "type", "test", "type", "3")) .addSort("_uid", SortOrder.ASC) .get(); assertHitCount(response, 3); @@ -204,7 +203,7 @@ public class PercolatorQuerySearchIT extends ESSingleNodeTestCase { .field("field2", "the quick brown fox falls down into the well") .endObject().bytes(); SearchResponse response = client().prepareSearch() - .setQuery(percolatorQuery("query", "type", source)) + .setQuery(percolateQuery("query", "type", source)) .addSort("_uid", SortOrder.ASC) .get(); assertHitCount(response, 4); @@ -251,7 +250,7 @@ public class PercolatorQuerySearchIT extends ESSingleNodeTestCase { .field("field1", "The quick brown fox jumps over the lazy dog") .endObject().bytes(); SearchResponse searchResponse = client().prepareSearch() - .setQuery(percolatorQuery("query", "type", document)) + .setQuery(percolateQuery("query", "type", document)) .highlighter(new HighlightBuilder().field("field1")) .addSort("_uid", SortOrder.ASC) .get(); @@ -285,7 +284,7 @@ public class PercolatorQuerySearchIT extends ESSingleNodeTestCase { client().admin().indices().prepareRefresh().get(); SearchResponse response = client().prepareSearch().setQuery( - QueryBuilders.percolatorQuery("query", "type", new BytesArray("{\"field\" : [\"brown\", \"fox\"]}")) + percolateQuery("query", "type", new BytesArray("{\"field\" : [\"brown\", \"fox\"]}")) ).get(); assertHitCount(response, 1); assertThat(response.getHits().getAt(0).getId(), equalTo("2")); @@ -347,7 +346,7 @@ public class PercolatorQuerySearchIT extends ESSingleNodeTestCase { BytesReference source = jsonBuilder().startObject().field("field", "value").endObject().bytes(); SearchResponse response = client().prepareSearch() - .setQuery(percolatorQuery(queryFieldName, "doc_type", source)) + .setQuery(percolateQuery(queryFieldName, "doc_type", source)) .setIndices("test1") .get(); assertHitCount(response, 1); @@ -356,7 +355,7 @@ public class PercolatorQuerySearchIT extends ESSingleNodeTestCase { assertThat(response.getHits().getAt(0).index(), equalTo("test1")); response = client().prepareSearch() - .setQuery(percolatorQuery("object_field." + queryFieldName, "doc_type", source)) + .setQuery(percolateQuery("object_field." + queryFieldName, "doc_type", source)) .setIndices("test2") .get(); assertHitCount(response, 1); diff --git a/docs/java-api/query-dsl/percolator-query.asciidoc b/docs/java-api/query-dsl/percolate-query.asciidoc similarity index 72% rename from docs/java-api/query-dsl/percolator-query.asciidoc rename to docs/java-api/query-dsl/percolate-query.asciidoc index 04f3ba9cb8d..60e03e9f32e 100644 --- a/docs/java-api/query-dsl/percolator-query.asciidoc +++ b/docs/java-api/query-dsl/percolate-query.asciidoc @@ -1,22 +1,27 @@ -[[java-query-percolator-query]] -==== Percolator query +[[java-query-percolate-query]] +==== Percolate query See: - * {ref}/query-dsl-percolator-query.html[Percolator Query] + * {ref}/query-dsl-percolate-query.html[Percolate Query] [source,java] -------------------------------------------------- +// create an index with a percolator field with the name 'query': +client.admin().indices().prepareCreate("myIndexName") + .addMapping("query", "query", "type=percolator") + .get(); + //This is the query we're registering in the percolator QueryBuilder qb = termQuery("content", "amazing"); //Index the query = register it in the percolator -client.prepareIndex("myIndexName", ".percolator", "myDesignatedQueryName") +client.prepareIndex("myIndexName", "query", "myDesignatedQueryName") .setSource(jsonBuilder() .startObject() .field("query", qb) // Register the query .endObject()) .setRefresh(true) // Needed when the query shall be available immediately - .execute().actionGet(); + .get(); -------------------------------------------------- This indexes the above term query under the name @@ -35,7 +40,7 @@ docBuilder.endObject(); //End of the doc field docBuilder.endObject(); //End of the JSON root object // Percolate, by executing the percolator query in the query dsl: SearchResponse response = client().prepareSearch("myIndexName") - .setQuery(QueryBuilders.percolatorQuery("myDocumentType", docBuilder.bytes())) + .setQuery(QueryBuilders.percolateQuery("query", ""myDocumentType", docBuilder.bytes())) .get(); //Iterate over the results for(SearchHit hit : response.getHits()) { diff --git a/docs/java-api/query-dsl/special-queries.asciidoc b/docs/java-api/query-dsl/special-queries.asciidoc index d5c9db07391..64645685ca5 100644 --- a/docs/java-api/query-dsl/special-queries.asciidoc +++ b/docs/java-api/query-dsl/special-queries.asciidoc @@ -27,5 +27,5 @@ include::template-query.asciidoc[] include::script-query.asciidoc[] -include::percolator-query.asciidoc[] +include::percolate-query.asciidoc[] diff --git a/docs/reference/cat/thread_pool.asciidoc b/docs/reference/cat/thread_pool.asciidoc index eb566f20fee..1d01989a429 100644 --- a/docs/reference/cat/thread_pool.asciidoc +++ b/docs/reference/cat/thread_pool.asciidoc @@ -58,7 +58,6 @@ Currently available <>: |`index` |`i` |Thread pool used for <>/<> operations |`management` |`ma` |Thread pool used for management of Elasticsearch (e.g. cluster management) |`force_merge` |`fm` |Thread pool used for <> operations -|`percolate` |`p` |Thread pool used for <> operations |`refresh` |`r` |Thread pool used for <> operations |`search` |`s` |Thread pool used for <>/<> operations |`snapshot` |`sn` |Thread pool used for <> operations diff --git a/docs/reference/docs/multi-termvectors.asciidoc b/docs/reference/docs/multi-termvectors.asciidoc index 4e987294254..1c0ff7f9bb7 100644 --- a/docs/reference/docs/multi-termvectors.asciidoc +++ b/docs/reference/docs/multi-termvectors.asciidoc @@ -93,8 +93,7 @@ curl 'localhost:9200/testidx/test/_mtermvectors' -d '{ -------------------------------------------------- Additionally, just like for the <> -API, term vectors could be generated for user provided documents. The syntax -is similar to the <> API. The mapping used is +API, term vectors could be generated for user provided documents. The mapping used is determined by `_index` and `_type`. [source,js] diff --git a/docs/reference/docs/termvectors.asciidoc b/docs/reference/docs/termvectors.asciidoc index c0265603029..586f40432b3 100644 --- a/docs/reference/docs/termvectors.asciidoc +++ b/docs/reference/docs/termvectors.asciidoc @@ -284,8 +284,7 @@ curl -XGET 'http://localhost:9200/twitter/tweet/1/_termvectors?pretty=true' -d ' -- Term vectors can also be generated for artificial documents, -that is for documents not present in the index. The syntax is similar to the -<> API. For example, the following request would +that is for documents not present in the index. For example, the following request would return the same results as in example 1. The mapping used is determined by the `index` and `type`. diff --git a/docs/reference/mapping/types/percolator.asciidoc b/docs/reference/mapping/types/percolator.asciidoc index d972e5efe68..d430f40f1d0 100644 --- a/docs/reference/mapping/types/percolator.asciidoc +++ b/docs/reference/mapping/types/percolator.asciidoc @@ -2,7 +2,7 @@ === Percolator type The `percolator` field type parses a json structure into a native query and -stores that query, so that the <> +stores that query, so that the <> can use it to match provided documents. Any field that contains a json object can be configured to be a percolator @@ -73,7 +73,7 @@ fail. [float] ==== Important Notes -Because the percolator query is processing one document at a time, it doesn't support queries and filters that run +Because the `percolate` query is processing one document at a time, it doesn't support queries and filters that run against child documents such as `has_child` and `has_parent`. There are a number of queries that fetch data via a get call during query parsing. For example the `terms` query when diff --git a/docs/reference/migration/migrate_5_0/percolator.asciidoc b/docs/reference/migration/migrate_5_0/percolator.asciidoc index 0d8e46917f9..7a3fa97fe92 100644 --- a/docs/reference/migration/migrate_5_0/percolator.asciidoc +++ b/docs/reference/migration/migrate_5_0/percolator.asciidoc @@ -4,7 +4,7 @@ ==== Percolator is near-real time Previously percolators were activated in real-time, i.e. as soon as they were -indexed. Now, changes to the percolator query are visible in near-real time, +indexed. Now, changes to the `percolate` query are visible in near-real time, as soon as the index has been refreshed. This change was required because, in indices created from 5.0 onwards, the terms used in a percolator query are automatically indexed to allow for more efficient query selection during @@ -13,7 +13,7 @@ percolation. ==== Percolate and multi percolator APIs Percolator and multi percolate APIs have been deprecated and will be removed in the next major release. These APIs have -been replaced by the `percolator` query that can be used in the search and multi search APIs. +been replaced by the `percolate` query that can be used in the search and multi search APIs. ==== Percolator field mapping @@ -26,10 +26,7 @@ but new indices no longer accept the `.percolator` type. ==== Percolate document mapping -The `percolator` query can no longer accept documents that reference fields -that don't already exist in the mapping. Before the percolate API allowed this. - -The `percolator` query no longer modifies the mappings. Before the percolate API +The `percolate` query no longer modifies the mappings. Before the percolate API could be used to dynamically introduce new fields to the mappings based on the fields in the document being percolated. This no longer works, because these unmapped fields are not persisted in the mapping. @@ -44,9 +41,9 @@ document and are returned by search requests. ==== Percolating existing document When percolating an existing document then also specifying a document as source in the -`percolator` query is not allowed any more. Before the percolate API allowed and ignored +`percolate` query is not allowed any more. Before the percolate API allowed and ignored the existing document. ==== Percolate Stats -Percolate stats have been replaced with percolator query cache stats in nodes stats and cluster stats APIs. \ No newline at end of file +Percolate stats have been replaced with `percolate` query cache stats in nodes stats and cluster stats APIs. \ No newline at end of file diff --git a/docs/reference/query-dsl/percolator-query.asciidoc b/docs/reference/query-dsl/percolate-query.asciidoc similarity index 88% rename from docs/reference/query-dsl/percolator-query.asciidoc rename to docs/reference/query-dsl/percolate-query.asciidoc index e358c82a590..267647c9dbb 100644 --- a/docs/reference/query-dsl/percolator-query.asciidoc +++ b/docs/reference/query-dsl/percolate-query.asciidoc @@ -1,8 +1,8 @@ -[[query-dsl-percolator-query]] -=== Percolator Query +[[query-dsl-percolate-query]] +=== Percolate Query -The `percolator` query can be used to match queries -stored in an index. The `percolator` query itself +The `percolate` query can be used to match queries +stored in an index. The `percolate` query itself contains the document that will be used as query to match with the stored queries. @@ -44,7 +44,7 @@ object that represents an actual Elasticsearch query. The `query` field has been configured to use the <>. This field type understands the query dsl and stored the query in such a way that it -can be used later on to match documents defined on the `percolator` query. +can be used later on to match documents defined on the `percolate` query. Register a query in the percolator: @@ -65,7 +65,7 @@ Match a document to the registered percolator queries: -------------------------------------------------- curl -XGET 'localhost:9200/my-index/_search' -d '{ "query" : { - "percolator" : { + "percolate" : { "field" : "query", "document_type" : "doctype", "document" : { @@ -110,7 +110,7 @@ The above request will yield the following response: } -------------------------------------------------- -<1> The percolate query with id `1` matches our document. +<1> The query with id `1` matches our document. [float] ==== Parameters @@ -123,7 +123,7 @@ The following parameters are required when percolating a document: `document`:: The source of the document being percolated. Instead of specifying a the source of the document being percolated, the source can also be retrieved from an already -stored document. The `percolator` query will then internally execute a get request to fetch that document. +stored document. The `percolate` query will then internally execute a get request to fetch that document. In that case the `document` parameter can be substituted with the following parameters: @@ -138,7 +138,7 @@ In that case the `document` parameter can be substituted with the following para [float] ==== Percolating an Existing Document -In order to percolate a newly indexed document, the `percolator` query can be used. Based on the response +In order to percolate a newly indexed document, the `percolate` query can be used. Based on the response from an index request, the `_id` and other meta information can be used to immediately percolate the newly added document. @@ -182,7 +182,7 @@ Percolating an existing document, using the index response as basis to build to curl -XGET "http://localhost:9200/my-index/_search" -d' { "query" : { - "percolator" : { + "percolate" : { "field": "query", "document_type" : "doctype", "index" : "my-index", @@ -201,10 +201,10 @@ case the then the search request would fail with a version conflict error. The search response returned is identical as in the previous example. [float] -==== Percolator and highlighting +==== Percolate query and highlighting -The percolator query is handled in a special way when it comes to highlighting. The percolator queries hits are used -to highlight the document that is provided in the `percolator` query. Whereas with regular highlighting the query in +The `percolate` query is handled in a special way when it comes to highlighting. The queries hits are used +to highlight the document that is provided in the `percolate` query. Whereas with regular highlighting the query in the search request is used to highlight the hits. [float] @@ -212,7 +212,7 @@ the search request is used to highlight the hits. This example is based on the mapping of the first example. -Add a percolator query: +Save a query: [source,js] -------------------------------------------------- @@ -226,7 +226,7 @@ curl -XPUT "http://localhost:9200/my-index/queries/1" -d' }' -------------------------------------------------- -Add another percolator query: +Save another query: [source,js] -------------------------------------------------- @@ -240,14 +240,14 @@ curl -XPUT "http://localhost:9200/my-index/queries/2" -d' }' -------------------------------------------------- -Execute a search request with the `percolator` query and highlighting enabled: +Execute a search request with the `percolate` query and highlighting enabled: [source,js] -------------------------------------------------- curl -XGET "http://localhost:9200/my-index/_search" -d' { "query" : { - "percolator" : { + "percolate" : { "field": "query", "document_type" : "doctype", "document" : { @@ -320,8 +320,8 @@ This will yield the following response. } -------------------------------------------------- -<1> Instead of the query in the search request highlighting the percolator hits, the percolator queries are highlighting - the document defined in the `percolator` query. +Instead of the query in the search request highlighting the percolator hits, the percolator queries are highlighting +the document defined in the `percolate` query. [float] ==== How it Works Under the Hood diff --git a/docs/reference/query-dsl/special-queries.asciidoc b/docs/reference/query-dsl/special-queries.asciidoc index 16d0020bf10..b705f01c6fc 100644 --- a/docs/reference/query-dsl/special-queries.asciidoc +++ b/docs/reference/query-dsl/special-queries.asciidoc @@ -20,7 +20,7 @@ final query to execute. This query allows a script to act as a filter. Also see the <>. -<>:: +<>:: This query finds queries that are stored as documents that match with the specified document. @@ -31,5 +31,5 @@ include::template-query.asciidoc[] include::script-query.asciidoc[] -include::percolator-query.asciidoc[] +include::percolate-query.asciidoc[] diff --git a/docs/reference/search/percolate.asciidoc b/docs/reference/search/percolate.asciidoc index 700c4ed392c..60e3e7e8cad 100644 --- a/docs/reference/search/percolate.asciidoc +++ b/docs/reference/search/percolate.asciidoc @@ -1,8 +1,8 @@ [[search-percolate]] == Percolator -deprecated[5.0.0,Percolate and multi percolate APIs are deprecated and have been replaced by the new <>] +deprecated[5.0.0,Percolate and multi percolate APIs are deprecated and have been replaced by the new <>] -added[5.0.0,Percolator query modifications only become visible after a refresh has occurred. Previously, they became visible immediately] +added[5.0.0,Percolate query modifications only become visible after a refresh has occurred. Previously, they became visible immediately] added[5.0.0,For indices created on or after version 5.0.0-alpha1 the percolator automatically indexes the query terms with the percolator queries. This allows the percolator to percolate documents more quickly. It is advisable to reindex any pre 5.0.0 indices to take advantage of this new optimization]