1. ES排序问题
- 场景: 查询ES时,两次访问查询的主备分片不同,且没有评分,返回的数据顺序不一致
官方解释如下:
when two documents have the same score, they will be sorted by their internal Lucene doc id (which is unrelated to the _id) by default. However these doc ids could be different across copies of the same shard.
- 解决方案如下:
The recommended way to work around this issue is to use a string that identifies the user that is logged is (a user id or session id for instance) as a preference This ensures that all queries of a given user are always going to hit the same shards, so scores remain more consistent across queries.
preference
参数 |
---|