【发布时间】:2016-07-08 11:14:36
【问题描述】:
我需要在 Elastic Search 中编写一个非常复杂的查询。
查询存储在一个字符串query中,想法是对字段title和content进行“布尔”匹配,然后对诸如“java”之类的词赋予特殊权重或“蟒蛇”。
我的尝试是
{
"fields": ["title","content","id"],
"query": {
"function_score": {
"query":
{
"bool":
{
"should":
[
{"match": {"title": {"query": query, "boost": 15}}},
{"match": {"content": {"query": query, "boost": 9}}}
]
}
}
},
"functions": [
{
"filter": {
"match": {
"title": "java"
}},
"weight": 2 },
{
"filter": {
"match": {
"title": "python"
}},
"weight": 2 }
],
"boost_mode": "multiply"
}
}
但我收到一条错误消息,指出查询格式错误。如果这是一个幼稚的问题,我很抱歉,但我不知道还能去哪里。
【问题讨论】:
标签: elasticsearch