gpt4 book ai didi

elasticsearch - 在Kibana演示中完全匹配查询

转载 作者:行者123 更新时间:2023-12-03 01:31:06 24 4
gpt4 key购买 nike

我正在测试Kibana的默认演示:Dashboard [eCommerce] Revenue Dashboard
例如,当我从[eCommerce] Controls过滤时,将类别设置为Men's Accessories时,我在[eCommerce] Sales by Category上看到其他类别。我该如何改变?

我看到查询的构建方式如下:

{
"query": {
"match": {
"category.keyword": {
"query": "Men's Accessories",
"type": "phrase"
}
}
}
}

因此,这转化为:
 "query": {
"bool": {
"must": [
{
"match_phrase": {
"category.keyword": {
"query": "Men's Accessories"
}
}
},

如何更改此演示以准确显示所选的类别?

屏幕示例:
enter image description here

编辑:

我不是在寻找一些愚蠢的解决方案-一次可以工作。
我只想显示一个类别,但只显示一个过滤器,而不是一个过滤器,例如三个否定。如果我将类别更改为另一个类别-简而言之,我选择了“女鞋”,那么我只想显示该类别,即只应用我从仪表板上选择的一个过滤器,而不是通过键入一些单词来定制过滤器。
我想进行可视化处理,使其在显示时将 excatly显示为一个类别,而不是现在的4个类别。

编辑:
我在Kibana Men's TEST_NEW_CATEGORY部分中创建了两个文档(使用全新的 Dev Tools):
POST kibana_sample_data_ecommerce/_doc/
{
"category": [
"Men's TEST_NEW_CATEGORY"
],
"currency": "EUR",
"customer_first_name": "Youssef",
"customer_full_name": "Youssef Jensen",
"customer_gender": "MALE",
"customer_id": 31,
"customer_last_name": "Jensen",
"customer_phone": "",
"day_of_week": "Saturday",
"day_of_week_i": 5,
"email": "youssef@jensen-family.zzz",
"manufacturer": [
"Low Tide Media"
],
"order_date": "2019-05-15T23:45:36+00:00",
"order_id": 592109,
"products": [
{
"base_price": 49.99,
"discount_percentage": 0,
"quantity": 1,
"manufacturer": "Low Tide Media",
"tax_amount": 0,
"product_id": 12202,
"category": "Men's TEST_NEW_CATEGORY",
"sku": "ZO0396603966",
"taxless_price": 49.99,
"unit_discount_amount": 0,
"min_price": 26.49,
"_id": "sold_product_592109_12202",
"discount_amount": 0,
"created_on": "2016-12-31T23:45:36+00:00",
"product_name": "Moccasins - stone",
"price": 49.99,
"taxful_price": 49.99,
"base_unit_price": 49.99
},
{
"base_price": 28.99,
"discount_percentage": 0,
"quantity": 1,
"manufacturer": "Low Tide Media",
"tax_amount": 0,
"product_id": 15017,
"category": "Men's Clothing",
"sku": "ZO0452704527",
"taxless_price": 28.99,
"unit_discount_amount": 0,
"min_price": 13.63,
"_id": "sold_product_592109_15017",
"discount_amount": 0,
"created_on": "2016-12-31T23:45:36+00:00",
"product_name": "Jumper - off-white",
"price": 28.99,
"taxful_price": 28.99,
"base_unit_price": 28.99
}
],
"sku": [
"ZO0396603966",
"ZO0452704527"
],
"taxful_total_price": 78.98,
"taxless_total_price": 78.98,
"total_quantity": 2,
"total_unique_products": 2,
"type": "order",
"user": "youssef",
"geoip": {
"country_iso_code": "US",
"location": {
"lon": -74,
"lat": 40.8
},
"region_name": "New York",
"continent_name": "North America",
"city_name": "New York"
}
}

然后我清楚地看到使用标准过滤器按钮时只有一种类别:

enter image description here

最佳答案

如果要按特定类别进行过滤,则需要使用filter而不是terms。术语汇总将应用于该字段中的所有值。另外,请注意,我禁用了使用切换的术语聚合。我针对您提到的用例仅使用过滤器

您可以按如下所示进行设置:
Filter by One Category

您还可以添加多个过滤器,如下所示:

multiple filters

另一种选择是添加scripted field并在这些脚本字段上可视化,但是这种情况非常简单,即从一个字段开始,因此不是必需的。但是,在整理来自多个字段的数据时-脚本化字段可能很有用。

更新了答案:

该演示是限制性的,您不能更改数据或在分析仪上播放。但是实际上,您可以通过精确匹配过滤出所需的值,然后应用过滤器。

现在,如果您在kibana中使用开发工具过滤数组,您会看到它返回与您的类别匹配的所有文档-它可能有也可能没有额外的类别,但总会找到您想要的东西。

因此,当您添加过滤器时,您仍会在可视化中看到其他类别,因为那是数据的样子。

kibana query

关于elasticsearch - 在Kibana演示中完全匹配查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55917746/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com