簡體   English   中英

在彈性搜索中匹配精確短語

[英]Matching exact phrase in elastic search

所以我有這樣的查詢:

{  
   "from":0,
   "size":20,
   "sort":{  
      "prices_count":"desc"
   },
   "query":{  
      "bool":{  
         "must":[  
            {  
               "terms":{  
                  "category_ids":[  
                     "3"
                  ]
               }
            },     
            {  
               "nested":{  
                  "path":"specs",
                  "query":{  
                     "bool":{  
                        "must":[  
                           {  
                              "match_phrase":{  
                                 "specs.model":"iphone-6s"
                              }
                           }
                        ]
                     }
                  }
               }
            }
         ]
      }
   }
}

我的問題在於嵌套查詢部分。 specs.model查詢不僅匹配模型為iphone-6s文檔,而且還匹配模型為iphone-6s-plus文檔,我也嘗試了term匹配,但后來卻沒有結果。 有任何想法嗎?

根據文檔

not_analyzed:

對該字段進行索引,以便可以搜索,但完全按指定的值索引。 不要分析它。

設置model: not_analyzed映射如下:

{
  "model": {
    "type":     "string",
    "index":    "not_analyzed"
  }
}

然后查詢term

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM