The percolator needs to deleted percolator documents into account when running in near realtime mode.
This bug only occurs in non-realtime mode when query, filter, facet or aggs is used. Closes #5843 Closes #5840
This commit is contained in:
parent
c00120b818
commit
0efeeff49a
|
@ -47,6 +47,7 @@ import org.elasticsearch.common.lucene.HashedBytesRef;
|
|||
import org.elasticsearch.common.lucene.Lucene;
|
||||
import org.elasticsearch.common.lucene.search.XCollector;
|
||||
import org.elasticsearch.common.lucene.search.XConstantScoreQuery;
|
||||
import org.elasticsearch.common.lucene.search.XFilteredQuery;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.text.BytesText;
|
||||
import org.elasticsearch.common.text.StringText;
|
||||
|
@ -781,7 +782,7 @@ public class PercolatorService extends AbstractComponent {
|
|||
private void queryBasedPercolating(Engine.Searcher percolatorSearcher, PercolateContext context, QueryCollector percolateCollector) throws IOException {
|
||||
Filter percolatorTypeFilter = context.indexService().mapperService().documentMapper(TYPE_NAME).typeFilter();
|
||||
percolatorTypeFilter = context.indexService().cache().filter().cache(percolatorTypeFilter);
|
||||
FilteredQuery query = new FilteredQuery(context.percolateQuery(), percolatorTypeFilter);
|
||||
XFilteredQuery query = new XFilteredQuery(context.percolateQuery(), percolatorTypeFilter);
|
||||
percolatorSearcher.searcher().search(query, percolateCollector);
|
||||
|
||||
for (Collector queryCollector : percolateCollector.facetAndAggregatorCollector) {
|
||||
|
|
|
@ -1774,6 +1774,29 @@ public class PercolatorTests extends ElasticsearchIntegrationTest {
|
|||
assertThat(((Map<String, String>) properties.get("field2")).get("type"), equalTo("string"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDontReportDeletedPercolatorDocs() throws Exception {
|
||||
client().admin().indices().prepareCreate("test").execute().actionGet();
|
||||
ensureGreen();
|
||||
|
||||
client().prepareIndex("test", PercolatorService.TYPE_NAME, "1")
|
||||
.setSource(jsonBuilder().startObject().field("query", matchAllQuery()).endObject())
|
||||
.get();
|
||||
client().prepareIndex("test", PercolatorService.TYPE_NAME, "1")
|
||||
.setSource(jsonBuilder().startObject().field("query", matchAllQuery()).endObject())
|
||||
.get();
|
||||
refresh();
|
||||
|
||||
PercolateResponse response = client().preparePercolate()
|
||||
.setIndices("test").setDocumentType("type")
|
||||
.setPercolateDoc(docBuilder().setDoc(jsonBuilder().startObject().field("field", "value").endObject()))
|
||||
.setPercolateFilter(FilterBuilders.matchAllFilter())
|
||||
.get();
|
||||
assertMatchCount(response, 1l);
|
||||
assertThat(response.getMatches(), arrayWithSize(1));
|
||||
assertThat(convertFromTextArray(response.getMatches(), "test"), arrayContainingInAnyOrder("1"));
|
||||
}
|
||||
|
||||
void initNestedIndexAndPercolation() throws IOException {
|
||||
XContentBuilder mapping = XContentFactory.jsonBuilder();
|
||||
mapping.startObject().startObject("properties").startObject("companyname").field("type", "string").endObject()
|
||||
|
|
Loading…
Reference in New Issue