ElasticSearch has the ability to copy values ββto other fields (index time), allowing you to search across multiple fields as if it were a single field ( Kernel Types: copy_to ).
However, there seems to be no way to indicate the order in which these values ββshould be copied. This can be important when matching phrases:
curl -XDELETE 'http://10.11.12.13:9200/helloworld' curl -XPUT 'http://10.11.12.13:9200/helloworld' # copy_to is ordered alphabetically! curl -XPUT 'http://10.11.12.13:9200/helloworld/_mapping/people' -d ' { "people": { "properties": { "last_name": { "type": "string", "copy_to": "full_name" }, "first_name": { "type": "string", "copy_to": "full_name" }, "state": { "type": "string" }, "city": { "type": "string" }, "full_name": { "type": "string" } } } } ' curl -X POST "10.11.12.13:9200/helloworld/people/dork" -d '{"first_name": "Jim", "last_name": "Bob", "state": "California", "city": "San Jose"}' curl -X POST "10.11.12.13:9200/helloworld/people/face" -d '{"first_name": "Bob", "last_name": "Jim", "state": "California", "city": "San Jose"}' curl "http://10.11.12.13:9200/helloworld/people/_search" -d ' { "query": { "match_phrase": { "full_name": { "query": "Jim Bob" } } } } '
Only Jim Bob returns; it seems that the fields are copied in the field name in alphabetical order.
How can I switch copy_to order to return "Jim Bob"?
elasticsearch
Tim harper
source share