在Elasticsearch中按多个条件搜索。

huangapple go评论69阅读模式
英文:

Search by multiple criteria in elasticsearch

问题

我是ElasticSearch的新手!我想要最优地设计映射。目前,针对特定变体中分配给特定类别的产品的第一个查询需要很长时间(大约5秒钟,ElasticSearch中大约有40,000个产品,并且对变体进行了广泛的请求)。与第一个查询相比,下一个查询要快得多。

ElasticSearch中的一个示例模式如下:

"id" : 1,
"title" : "product",
"price" : "1100.00",
"categories" : [产品类别的id],
"tags" : [产品标签的id],
"variants" : [嵌套类型,具有属性:名称、定义,将来可能还有可用性日期]

也许有人已经遇到过这样的问题?或者也许有更好的建模方法?
将类别和变体作为单独的索引,通过关联进行链接?

英文:

I'm new in ElasticSearch!
I would like to design the mapping optimally.
Currently, the first query for products assigned to specific categories in a specific variant takes a long time (about 5 seconds for around 40,000 products in elasticsearch with an extensive request for variants). The next query is much faster than the first one.

A sample pattern in elasticsearch looks like:

"id" : 1,
"title" : "product",
"price" : "1100.00",
"categories" : [ the ids of the product's categories],
"tags" : [ the ids of the product's tags ],
"variants" : [ nested type with properties: name, definition, maybe in the future availability dates]

Maybe someone has already encountered such a problem? Or maybe it could be better modeled?
Categories and variants as a separate index linked by a relationship?

答案1

得分: 1

首先,你正在为变体字段使用嵌套数据类型,而嵌套数据类型因其性能较差而闻名。请参考Go-Jek的中间博客,关于嵌套字段引起的问题,看看是否可以应用博客中提到的建议来优化搜索性能。

另外,你的第二个请求速度较快,这是由于Elasticsearch缓存,主要是分片请求缓存,你可以监控并确认这一点。

英文:

First thing first, you are using the nested data type for your variant field and nested data-types are known for their bad performance and please refer to go-jek medium blog on trouble with nested field and see if you can apply the suggestions mentioned in the blog to optimize your search performance.

Also, your second request is faster due to Elasticsearch cache and mostly its shard request cache which you can monitor and confirm.

huangapple
  • 本文由 发表于 2020年10月1日 20:20:33
  • 转载请务必保留本文链接:https://go.coder-hub.com/64155283.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定