添加multi_match到Elastic Search功能评分查询
Add multi_match to Elastic Search Function Score Query
目前,我只是查询存储在弹性搜索中的网页的 "content" 以进行关键字匹配。我想为该等式添加标题。我正在使用顶部代码(在 "MARRY THIS" 下)并想以某种方式插入底部代码("WITH THIS")但似乎找不到如何插入的解释。
MARRY THIS
{
"query": {
"function_score": {
"query": {
"match": {
"content": "keyword"
}
},
"functions": [{
"field_value_factor": {
"field": "obls",
"factor": 0.5,
"modifier": "ln2p"
}
}]
}
},
"from": "0",
"size": "100"
}
WITH THIS
{
"multi_match" : {
"query": "keyword",
"fields": [ "title^3", "content" ]
}
}
提前致谢!
经过反复试验我弄明白了,它看起来像这样:
{
"query": {
"function_score": {
"query": {
"multi_match": {
"query": "baseball",
"fields": ["content", "title"]
}
},
"functions": [{
"field_value_factor": {
"field": "obls",
"factor": 0.5,
"modifier": "ln2p"
}
}]
}
},
"from": "10",
"size": "100"
}
目前,我只是查询存储在弹性搜索中的网页的 "content" 以进行关键字匹配。我想为该等式添加标题。我正在使用顶部代码(在 "MARRY THIS" 下)并想以某种方式插入底部代码("WITH THIS")但似乎找不到如何插入的解释。
MARRY THIS
{
"query": {
"function_score": {
"query": {
"match": {
"content": "keyword"
}
},
"functions": [{
"field_value_factor": {
"field": "obls",
"factor": 0.5,
"modifier": "ln2p"
}
}]
}
},
"from": "0",
"size": "100"
}
WITH THIS
{
"multi_match" : {
"query": "keyword",
"fields": [ "title^3", "content" ]
}
}
提前致谢!
经过反复试验我弄明白了,它看起来像这样:
{
"query": {
"function_score": {
"query": {
"multi_match": {
"query": "baseball",
"fields": ["content", "title"]
}
},
"functions": [{
"field_value_factor": {
"field": "obls",
"factor": 0.5,
"modifier": "ln2p"
}
}]
}
},
"from": "10",
"size": "100"
}