简体   繁体   中英

Weighted keywords on elasticsearch document

I want to create an index in elasticsearch that has a field of weighted keywords list, so when I search by term in this keywords - it will give better scores to those documents that has this key with higher weight?

For instance:

Doc1

"id" : "111" "keywords" : "house"(20), "dog"(2)

Doc2

"id" : "222" "keywords" : "house"(3), "dog"(40)

I want when searching "dog" to get doc2 with higher score.

How would you build the mapping and the query?

Note that it's different than searching with regular boost, as the boost per each term is different per document.

What about Elasticsearch payloads? See DrTech's answer with the delimited payload token filter to a separate unrelated question which might help you out. But, what you are describing seems to very much lend itself to the use of payloads and using script scoring to access these payloads and influence the scoring. Take note of the performance cost he mentions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM