在Elasticsearch中按多个条件搜索

问题描述

我是ElasticSearch的新手! 我想以最佳方式设计映射。 当前,首​​次查询分配给特定变体中特定类别的产品需要很长时间(在Elasticsearch中,大约有40,000个产品需要大量变体,大约需要5秒)。下一个查询比第一个查询快得多。

elasticsearch中的样本模式如下:

"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]

也许有人已经遇到过这样的问题?还是可以更好地建模? 类别和变体是通过关系链接的单独索引?

解决方法

首先,您正在使用nested data typ e作为变量字段,并且嵌套数据类型因其性能不佳而闻名,请参阅go-jek medium blog on trouble with nested field,看看您是否可以应用上述建议在博客中优化搜索效果。

除嵌套字段外,还可以通过遵循these 10 short tips来提高搜索性能。

此外,由于有Elasticsearch缓存以及您可以监控和确认的shard request cache,因此您的第二个请求更快。