![](/img/trans.png)
[英]I need to run a elastic search query where at-least one of few terms in few fields are mandatory and one other term in a field is mandatory
[英]Elastic : search two terms, one on _all, other one on a field
我想將對整個文檔的搜索(例如“開發人員”)與對某個字段的另一個術語的搜索(例如“ php”)混合在一起。 我可以分別進行每個搜索,但不能混合使用。
這是我的示例(簡化為僅顯示我的問題):
{
"query": {
"function_score": {
"query": {
"match": {
"_all": "developer"
},
"multi_match": {
"query": "php",
"fields": [
"skills.description",
"skills.description",
"skills.details"
],
"operator": "or",
"type": "most_fields"
}
}
}
}
如果我運行此示例,則會出現錯誤:
Parse Failure [Failed to parse source
有沒有辦法用兩個詞同時搜索_all和特定字段?
謝謝。
是的,您快到了,您需要將它們合並為bool/must
查詢:
{
"query": {
"function_score": {
"query": {
"bool": {
"must": [
{
"match": {
"_all": "developer"
}
},
{
"multi_match": {
"query": "php",
"fields": [
"skills.description",
"skills.description",
"skills.details"
],
"operator": "or",
"type": "most_fields"
}
}
]
}
}
}
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.