簡體   English   中英

從Elasticsearch中的多個嵌套級別字段中搜索

[英]Search from multiple nested level fields in elasticsearch

我想從多個嵌套級別字段中搜索。 查詢一樣。

select * from product where brand='brand1' and category='category1'.

在Elasticsearch中,我有兩個嵌套的級別映射,一個是類別 ,另一個是品牌

如果我品牌或類別,它會返回完美的結果,但是如何在以下查詢中同時寫兩個呢?

    $params = [
                'index' => 'my_index',
                'type' => 'product',
                'body' =>  [
                "query"=>[
                   "filtered"=>[
                      "filter"=>[
                         "bool"=>[
                            "must"=>[
                               "bool"=>[
                                  "must"=>[
                                     [
                                        "query"=>[
                                           "match"=>[
                                              "brand"=>[
                                                 "query"=>"brand1",
                                                 "type"=>"phrase"
                                              ]
                                           ]
                                        ]
                                     ],
                                     [
                                        "query"=>[
                                           "match"=>[
                                              "category"=>[
                                                 "query"=>"category1",
                                                 "type"=>"phrase"
                                              ]
                                           ]
                                        ]
                                     ]
                                  ]
                               ]
                            ]
                         ]
                      ]
                   ]
                ]
            ]      

       ];

通過上面的查詢我得到0個結果

您可以在下面的查詢中嘗試它,這將幫助您獲得尊敬的答案:

GET / product / ur_type / _search {“ from”:0,“ size”:200,“ query”:{“ filtered”:{“ filter”:{“ bool”:{“ must”:{“ bool”:{ “必須”:[{“查詢”:{“匹配”:{“品牌”:{“查詢”:“品牌1”,“類型”:“短語”}}}}},{“查詢”:{“匹配” :{“ category”:{“ query”:“ category1”,“ type”:“短語”}}}}}}}}}}}}}}

暫無
暫無

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

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