ElasticSearch Java API搜索错误
每个searchRequest.toString()
和每个错误信息
我想如果你在查看搜索正文和错误之前看到底部的摘要,应该会更容易理解我的问题
搜索正文
{
"from" : 0,
"size" : 12,
"query" : {
"custom_filters_score" : {
"query" : {
"bool" : {
"must" : {
"term" : {
"2474" : [ "20", "17" ]
}
},
"should" : {
"term" : {
"productName" : {
"value" : "xxx",
"boost" : 3.0
}
}
}
}
},
"filters" : [ {
"filter" : {
"terms" : {
"availableStock" : [ 0 ]
}
},
"boost" : -10.0
} ]
}
},
"filter" : {
"bool" : {
"must_not" : {
"term" : {
"ecPrice" : -1
}
}
}
},
"sort" : [ {
"_score" : {
"order" : "desc"
}
} ],
"facets" : {
"productBrandName" : {
"terms" : {
"field" : "productBrandName",
"size" : 10
}
}
},
"highlight" : {
"pre_tags" : [ "<font style='color:red'>" ],
"post_tags" : [ "</font>" ],
"fields" : {
"productName" : { },
"drugTreatment" : { }
}
}
}
错误:
QueryParsingException[[hy_index] [bool] query does not support [must]];
搜索正文
{
"from" : 0,
"size" : 12,
"query" : {
"custom_filters_score" : {
"query" : {
"bool" : {
"should" : {
"term" : {
"2474" : [ "20", "17" ]
}
}
}
},
"filters" : [ ]
}
},
"filter" : {
"bool" : {
"must_not" : {
"term" : {
"ecPrice" : -1
}
}
}
},
"sort" : [ {
"_score" : {
"order" : "desc"
}
} ],
"facets" : {
"productBrandName" : {
"terms" : {
"field" : "productBrandName",
"size" : 10
}
}
},
"highlight" : {
"pre_tags" : [ "<font style='color:red'>" ],
"post_tags" : [ "</font>" ],
"fields" : {
"productName" : { },
"drugTreatment" : { }
}
}
}
错误
QueryParsingException[[hy_index] [bool] query does not support [should]]
搜索正文
{
"from" : 0,
"size" : 12,
"query" : {
"custom_filters_score" : {
"query" : {
"bool" : {
"should" : [ {
"term" : {
"productName" : {
"value" : "xxx",
"boost" : 3.0
}
}
}, {
"term" : {
"2474" : [ "20", "17" ]
}
} ]
}
},
"filters" : [ {
"filter" : {
"terms" : {
"availableStock" : [ 0 ]
}
},
"boost" : -10.0
} ]
}
},
"filter" : {
"bool" : {
"must_not" : {
"term" : {
"ecPrice" : -1
}
}
}
},
"sort" : [ {
"_score" : {
"order" : "desc"
}
} ],
"facets" : {
"productBrandName" : {
"terms" : {
"field" : "productBrandName",
"size" : 10
}
}
},
"highlight" : {
"pre_tags" : [ "<font style='color:red'>" ],
"post_tags" : [ "</font>" ],
"fields" : {
"productName" : { },
"drugTreatment" : { }
}
}
}
错误
QueryParsingException[[hy_index] [_na] query malformed, must start with start_object];
搜索正文
{
"from" : 0,
"size" : 12,
"query" : {
"custom_filters_score" : {
"query" : {
"bool" : {
"should" : {
"term" : {
"productName" : {
"value" : "撒",
"boost" : 3.0
}
}
}
}
},
"filters" : [ {
"filter" : {
"terms" : {
"availableStock" : [ 0 ]
}
},
"boost" : -10.0
} ]
}
},
"filter" : {
"bool" : {
"must_not" : {
"term" : {
"ecPrice" : -1
}
}
}
},
"sort" : [ {
"_score" : {
"order" : "desc"
}
} ],
"facets" : {
"productBrandName" : {
"terms" : {
"field" : "productBrandName",
"size" : 10
}
}
},
"highlight" : {
"pre_tags" : [ "<font style='color:red'>" ],
"post_tags" : [ "</font>" ],
"fields" : {
"productName" : { },
"drugTreatment" : { }
}
}
}
这个没有错误
现在,总结一下
无论我在"term" : {"2474" : [ "20", "17" ]}
使用should
还是must
当我在查询体中设置"term" : {"2474" : [ "20", "17" ]}
时,它总是出错
一旦我从查询体中删除"term" : {"2474" : [ "20", "17" ]}
,它就可以正常工作了
为什么
共 (0) 个答案