Percolating unknown document fields, using copy_to as work around


(auto) #1

I've been experimenting with percolator, but it seems I can't add queries for fields that have no mappings. This would be really useful for me. I was wondering if it would be possible to use copy_to to in a dynamic template to copy the path AND the value for any string fields. For an example, I could have a known mapped nested type field that contains 2 properties: path and value. Then I could dynamically copy string field values into the value property, and the path that the string field was found in to the path property.

Is there anyway for me to write a percolator query for a field that the index has no mapping for even though we dynamically map these?


(Martijn Van Groningen) #2

The percolator field mapping needs to know field mapping of fields in the query, otherwise it doesn't know how to parse the query correctly. For example you may have custom text analysis, but if the field hasn't been defined, it doesn't know analyzers to use.

There is an option that allows unmapped fields to be handled as default text fields: https://www.elastic.co/guide/en/elasticsearch/reference/6.6/percolator.html#_forcing_unmapped_fields_to_be_handled_as_stringse

Maybe that helps in your case. However it is recommended to define the mapping prior to indexing the percolator if possible.