【问题标题】:Search from multiple nested level fields in elasticsearch在 elasticsearch 中从多个嵌套级别字段中搜索
【发布时间】:2016-03-04 21:29:40
【问题描述】:

我想从多个嵌套级别字段中进行搜索。查询喜欢。

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

在 elasticsearch 中,我有 两个嵌套级别映射,一个是 category,另一个是 brand

如果我写了仅品牌或类别它返回完美结果如何在以下查询中同时写?

    $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 个结果

【问题讨论】:

  • 我不知道如何编写该查询?

标签: laravel elasticsearch


【解决方案1】:

您可以尝试以下查询,它将帮助您获得尊重的答案:

GET /product/ur_type/_search { “来自”:0, “大小”:200, “询问”: { “过滤”:{ “筛选”: { “布尔”:{ “必须”: { “布尔”:{ “必须”: [ { “询问”: { “匹配”: { “牌”: { “查询”:“品牌1”, “类型”:“短语” } } } }, { “询问”: { “匹配”: { “类别”: { “查询”:“类别1”, “类型”:“短语” } } } } ] } } } } } } }

【讨论】:

  • 请告诉我它到底给了你什么输出??
  • GuzzleConnection.php 第 277 行中的 BadRequest400Exception:和 looonngg 错误,例如:{"error":"SearchPhaseExecutionException[Failed to execute phase [query], all shards failed; shardFailures....... ......
  • 你能和我分享你的问题吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-07-08
相关资源
最近更新 更多