我有一组过滤器数据,如下格式
filters = [
{key : colour, values: [red,blue,green,yellow,........]},
{key:website, values:[myntra, jabong, voonik,...........]},
{key:shape,values:[fit, maxi,bodycon, skater...................]}
,........................
,........................]
我的 Elasticsearch 数据库结构是
{
"_index": "products_data",
"_type": "dresses",
"_id": "1",
"_score": 0,
"_source": {
"product_filter":{
"dress_shape": "sheath",
"pattern_type": "solid",
"discount_price": 1347,
"knit_or_woven": "knit",
"year": "2015",
"age_group": "adults-women",
"broad_category": "dress",
"fabric": "polyester",
"lining": "has a lining",
"surface_styling_or_features": "other",
"usage": "casual",
"sleeves_type": "sleeveless",
"brand": "deal jeans",
"website": "myntra",
"season": "fall",
"price": 2695,
"discount_percent": 50,
"product_line": "dresses",
"neck": "round neck",
"sleeve": "sleeveless",
"gender": "women",
"colour": "black",
"occasion": "casual",
"dress_length": "mini",
"display_name": "deal jeans black sheath dress",
"hemline": "curved",
"fabric_type": "lace or crochet"
}
}
}
我需要找到每个过滤器的数量,像这样image 。 目前,我正在使用每个过滤器并生成如下格式的 Elasticsearch 查询,并将该查询发送到 Elasticsearch 计数 api 以获取计数。
{ "query": { "bool": { "filter":{ "term": { "product_filter.brand": "109f" } } } } }
output : 109f brand --> 2132
每个过滤器列表中都有更多数据。计算 500 个过滤器的数量大约需要 6 秒。
我尝试了多搜索api(msearch api),但它也花费了很多时间。我的数据大小是 19787033681 字节,它有 5 个分片。
任何人都可以用 Node js 代码帮我解决这个问题...
最佳答案
我给您的建议是将分片数量从 5 个减少到 1 个。除非您有多台机器处理相同的数据或希望使用集群,否则您应该只使用一个分片。
{
"settings":{
"number_of_shards":1,
"number_of_replicas":0
}
}
当拥有多个服务器/计算机用于插入/搜索/删除操作和冗余目的时,使用多个分片和副本非常高效。
关于node.js - 如何在node js中以更少的时间获得以下 Elasticsearch 数据库结构的结果?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44634125/