我有這個查詢:
"query": {
"bool": {
"must": [
{
"query_string": {
"query": "query",
"fields": [
"some.field"
],
"lenient": true,
"default_operator": "OR"
}
}
],
"filter": [
{"term": {
"test.name.enum": {
"value":"filterTerm"
}
}}
]
“test.name”的映射如下:
"test" : {
"type" : "nested",
"properties" : {
"name" : {
"type" : "text",
"fields" : {
"delimiter" : {
"type" : "text",
"index_options" : "freqs",
"analyzer" : "iq_text_delimiter"
},
"enum" : {
"type" : "keyword",
"ignore_above" : 2048
},
"joined" : {
"type" : "text",
"index_options" : "freqs",
"analyzer" : "i_text_bigram",
"search_analyzer" : "q_text_bigram"
},
"prefix" : {
"type" : "text",
"index_options" : "docs",
"analyzer" : "i_prefix",
"search_analyzer" : "q_prefix"
},
"sear_as_type" : {
"type" : "search_as_you_type",
"doc_values" : false,
"max_shingle_size" : 3
},
"stem" : {
"type" : "text",
"analyzer" : "iq_text_stem"
},
"synonym" : {
"type" : "text",
"analyzer" : "synonym_analyzer"
}
},
"index_options" : "freqs",
"analyzer" : "iq_text_base"
}
}
但是,當我嘗試過濾時,它不會回傳任何結果,盡管確保該過濾器確實存在結果并回傳 0 個命中,這里的列舉具有 type 關鍵字,我認為您應該如何過濾?我是 elasticsearch 的新手,所以任何幫助表示贊賞
uj5u.com熱心網友回復:
由于testis 宣告nested,您的過濾器還需要包含一個nested查詢:
...
"filter": [
{
"nested": {
"path": "test",
"query": {
"term": {
"test.name.enum": {
"value": "filterTerm"
}
}
}
}
}
]
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/363504.html
標籤:弹性搜索
