简体   繁体   English

ElasticSearch:根据名称和类别退回产品

[英]ElasticSearch: Returning products based on name and categories

im having troubles returning all the product that match a specific condition: 我在退回所有符合特定条件的产品时遇到了麻烦:

My mapping is quite simple 我的映射很简单

i have products, they have names, and they'are in certain categories. 我有产品,有名称,并且属于某些类别。

What i want to do is return all the product that either have a string that i choose in their name, aswell has returning all the product that also are in the category for the same string. 我想做的是返回所有具有我在其名称中选择的字符串的产品,以及返回也属于同一字符串类别的所有产品。

Here's an example: 这是一个例子:

say i type 'Mobile phone', i should get all the products that have 'Mobile Phone' somewhere in the string 'name' (order and such doesn't matter) but it should also return all the product in the 'Mobile Phone' category (whatever the name is) 说我输入“手机”,我应该将所有带有“手机”的产品放在字符串“名称”中(顺序无关紧要),但它还应该在“手机”中返回所有产品类别(无论名称如何)

At the moment, i have a query that gets a lot of garbage because it matchs any of the words in the name, and doesn't get all of the categories. 此刻,我有一个查询,该查询会产生大量垃圾,因为它与名称中的任何单词匹配,并且无法获取所有类别。

BoolQuery {#612 ▼
  #_params: array:2 [▼
    "must" => array:3 [▼
      0 => ProductAvailable {#613 ▶}
      1 => Term {#622 ▶}
      2 => BoolQuery {#623 ▼
        #_params: array:3 [▼
          "minimum_number_should_match" => 1
          "should" => array:2 [▼
            0 => Match {#624 ▼
              #_params: array:1 [▼
                "name" => "Tondeuse à gazon"
              ]
              #_rawParams: []
            }
            1 => Match {#625 ▼
              #_params: array:1 [▼
                "category.name.raw" => "Tondeuse à gazon"
              ]
              #_rawParams: []
            }
          ]
          "boost" => 2
        ]
        #_rawParams: []
      }
    ]
    "minimum_number_should_match" => 1
  ]
  #_rawParams: []
}

The ProductAvailable and Term query aren't relevant since they're used to check if product can be selled etc... ProductAvailable和Term查询无关,因为它们用于检查产品是否可以出售等。

Here the example string is "Tondeuse à gazon" 此处的示例字符串为“ Tondeuseàgazon”

Thanks for the helping <3 感谢您的帮助<3

我自己找到了解决方案,我会将问题标记为已回答

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Laravel - 根据类别显示产品,但无法在刀片文件中显示类别名称 - Laravel - Displaying products based on categories but not able to display category name in blade file 根据 Woocommerce 中的产品类别隐藏运输方式 - Hide shipping methods based on products categories in Woocommerce 根据产品数量从小部件中删除类别 - Remove categories from widget based on number of products 产品类别 - products categories WP-eCommerce:基于两个类别获取产品(返回仅在两个类别中都存在的产品) - WP-eCommerce: Getting products based on two categories (return a products that only exist within both categories) 在Woocommerce中根据产品标签自动将产品分配到类别 - Automatically assign products to categories based on their product tags in Woocommerce 隐藏基于WooCommerce中产品或类别的特定送货选项 - Hide specific shipping options based on products or categories in WooCommerce 基于订购产品类别的有条件的 WooCommerce email 通知页脚 - Conditional WooCommerce email notification footer based on categories of products ordered WooCommerce单品有子品类时按品类展示内容 - Display content on WooCommerce single products based on product categories when they have child categories 根据类别名称woocommerce检查购物车中的产品? - Checking products in cart based on category name woocommerce?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM