我想寫一個2部分的Elasticsearch布爾查詢。 我需要兩個條件「must」和兩個「should」。問題是我只想得到「應該」的分數。我嘗試了「過濾器」,但沒有成功。Elasticsearch布爾查詢與篩選器
更具體地講,我做了查詢是在這裏:
{
"query": {
"bool": {
"must": [
{
"match": {
"attr1": "on"
}
},
{
"match": {
"category": "7eb84c804a8c824fd608e05f78d42f10"
}
}
],
"should": [
{
"term": {
"attr2": "on"
}
},
{
"term": {
"attr3": "on"
}
}
],
"minimum_should_match": "10%"
}
}
}
UPDATE 這裏是失敗的查詢,我想找到的錯誤!:
{
"query": {
"bool": {
"filter": [
{
"term": {
"attr1": "on"
}
},
{
"term": {
"category": "7eb84c804a8c824fd608e05f78d42f10"
}
}
],
"should": [
{
"term": {
"attr2": "on"
}
},
{
"term": {
"attr3": "on"
}
}
],
"minimum_should_match": "10%"
}
}
}
如何可以按照以下順序重新編寫該查詢: 1)獲取attr1和類別完全相同的所有行 2)然後用should查詢這些結果
有什麼想法嗎?
你有什麼使用過濾器? –
嵌套:QueryParsingException [[dev1] [bool]查詢不支持[filter]]; –
我根據您的答案更新我的問題並提供詳細信息! –