Percolator in Elasticsearch 6

I'm currently upgrading some code using a very old version of the Elasticsearch percolator. I'm trying to understand percolators in Es6. I understand the percolator type and have read the documentation. What I'm having trouble understanding is this. If I have an index containing a mapping for a document. Would I put a percolator field on this mapping and then save both documents and percolator queries in the same index? I understand that I would normally not have different document types in a single index. But since all fields referenced in a percolator query needs to be present on the mapping containing the percolator field, I would have two almost identical mappings if I store documents in one index and percolators in another.

You can't mix regular documents and percolators in the same index, because for the percolator index the type must be "percolator".

The way we're doing percolation in ES 6.2 is to index the percolator queries in their own index (actually several indices) and then percolate new documents from a regular Elasticsearch index through that, to find the matching docs.

Yes, the Index Mapping will be very similar so what we have done is extract all the fields into a global ("order": 0) mapping for all indices in that cluster, which means we apply it both to documents in the regular index and to the percolator queries. In addition we have a small, dedicated mapping ("order": 1) that only matches the percolator index name(s) and where we define "type": "percolator".

That way you only need to define your mapping in one json-file (and the percolator in another).

Thanks. Makes total sense. When thinking about it, if I store both documents and percolators in the same index (they would share the same mapping why it would be totally possible), all percolators would be returned from a match_all query for documents and more troubles like that.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.