elasticsearch - Boost rank for special type of document -
i have index 2 types of document: district
, street
. boost rank of district
documents.
is there way without script
option?
you can use custom_filters_score
boost documents matching filter, , filter can type
-filter.
here's runnable example can play with: https://www.found.no/play/gist/8744808
#!/bin/bash export elasticsearch_endpoint="http://localhost:9200" # index documents curl -xpost "$elasticsearch_endpoint/_bulk?refresh=true" -d ' {"index":{"_index":"play","_type":"district"}} {"title":"there"} {"index":{"_index":"play","_type":"street"}} {"title":"there"} ' # searches curl -xpost "$elasticsearch_endpoint/_search?pretty" -d ' { "query": { "custom_filters_score": { "query": { "match": { "title": { "query": "there" } } }, "filters": [ { "boost": 2, "filter": { "type": { "value": "district" } } } ] } } } '
Comments
Post a Comment