Reputation: 339
I am very new at elasticsearch so am having a hard time to figure this out.
So the thing is I am trying to search content having tags, and these tags will have weights, which will be like,
{
tag: "tag name",
weight: 1
}
right now I am trying this query
{
"query": {
"bool": {
"should": [
{
"multi_match": {
"query": "do",
"fields": [
"name",
"tags.tag"
],
"type": "phrase_prefix"
}
}
]
}
}
}
But I don't know how to modify the search such that, the search results give the tag weight priorty.
Thanks.
Upvotes: 2
Views: 75
Reputation: 4535
Not sure if I understood you question correctly... do you want get the tag weight and affect search result score with it? If yes, please take a look at script score. According to documentation you can do something like this:
{
"query": {
"function_score": {
"query": {
"match": { "message": "elasticsearch" }
},
"script_score" : {
"script" : {
"source": "Math.log(2 + doc['likes'].value)"
}
}
}
}
}
Upvotes: 1