1.Refresh 时间间隔
为了提高索引性能,Elasticsearch 在写入数据时候,采用延迟写入的策略,即数据先写到内存中,当超过默认 1 秒 (index.refresh_interval)会进行一次写入操作,就是将内存中 segment 数据刷新到操作系统中,此时我们才能将数据搜索出来,所以这就是为什么 Elasticsearch 提供的是近实时搜索功能,而不是实时搜索功能。
PUT traded_item_e-local-alias/_settings
{
"index.refresh_interval" : "20s"
}
2.查询优化
query_string 或 multi_match的查询字段越多, 查询越慢。可以在mapping阶段,利用copy_to属性将多字段的值索引到一个新字段,multi_match时,用新的字段查询。
商品库: productName、companyName、productCode、productStyle、material、hotElement
3.boost和minimum_should_match
4.当进行关键字搜索时,先进行评分排序,再进行业务排序
5.尽量先进行过滤再进行精确匹配,不要全都是精确匹配,否则速度很慢。



