percolator: Replace percolate api with the new percolator query

Also replaced the PercolatorQueryRegistry with the new PercolatorQueryCache.

The PercolatorFieldMapper stores the rewritten form of each percolator query's xcontext
in a binary doc values field. This make sure that the query rewrite happens only during
indexing (some queries for example fetch shapes, terms in remote indices) and
the speed up the loading of the queries in the percolator query cache.

Because the percolator now works inside the search infrastructure a number of features
(sorting fields, pagination, fetch features) are available out of the box.

The following feature requests are automatically implemented via this refactoring:

Closes #10741
Closes #7297
Closes #13176
Closes #13978
Closes #11264
Closes #10741
Closes #4317
This commit is contained in:
Martijn van Groningen 2016-03-15 15:07:53 +01:00
parent 032678f0c3
commit e3b7e5d75a
97 changed files with 3089 additions and 5628 deletions

View file

@ -142,8 +142,6 @@ include::search.asciidoc[]
include::aggs.asciidoc[]
include::percolate.asciidoc[]
include::query-dsl.asciidoc[]
include::indexed-scripts.asciidoc[]

View file

@ -1,12 +1,8 @@
[[percolate]]
== Percolate API
[[java-query-percolator-query]]
==== Percolator query
The percolator allows one to register queries against an index, and then
send `percolate` requests which include a doc, getting back the
queries that match on that doc out of the set of registered queries.
Read the main {ref}/search-percolate.html[percolate]
documentation before reading this guide.
See:
* {ref}/query-percolator-query.html[Percolator Query]
[source,java]
--------------------------------------------------
@ -37,14 +33,12 @@ docBuilder.field("doc").startObject(); //This is needed to designate the documen
docBuilder.field("content", "This is amazing!");
docBuilder.endObject(); //End of the doc field
docBuilder.endObject(); //End of the JSON root object
//Percolate
PercolateResponse response = client.preparePercolate()
.setIndices("myIndexName")
.setDocumentType("myDocumentType")
.setSource(docBuilder).execute().actionGet();
// Percolate, by executing the percolator query in the query dsl:
SearchResponse response = client().prepareSearch("myIndexName")
.setQuery(QueryBuilders.percolatorQuery("myDocumentType", docBuilder.bytes()))
.get();
//Iterate over the results
for(PercolateResponse.Match match : response) {
//Handle the result which is the name of
//the query in the percolator
for(SearchHit hit : response.getHits()) {
// Percolator queries as hit
}
--------------------------------------------------

View file

@ -27,3 +27,5 @@ include::template-query.asciidoc[]
include::script-query.asciidoc[]
include::percolator-query.asciidoc[]