Solr: Random sort order after index version change

2019-08-06 13:54发布

I am using "solr.RandomSortField" to sort search result randomly base on passed random seed. it is working fine and giving same order for same random seed key.

Issue is:

When index version get changed by creating/deleting doc using API at run time. Then random order also get changed for same key between newer and older version.

By Searching in google, i came to know that "RandomSortField" use index version so when index version get changed sort order also get change.

Is there any way to exclude index version from random sort or pass index version to my query to search in older version instead of new updated version and get same order while paging search result.

Mostly getting issue in pagination whenever order change. get duplicate result after some page.

1条回答
太酷不给撩
2楼-- · 2019-08-06 14:49

Have you tried removing (int)top.getVersion();?

Using RandomSortField is a module/plugin found here: https://svn.apache.org/repos/asf/lucene/dev/tags/lucene_solr_5_4_1/solr/core/src/java/org/apache/solr/schema/RandomSortField.java

It's useful to be able to have random results that can be persisted for pagination. But if you have an index that gets updated often, then you will lose your random sort order because of the dependency on the index version. To get around this, you can remove the line i wrote above, or you can even simply:

return fieldName.hashCode();

in the getseed function.

you will need to make that into your own custom plugin, like a jarfile or whatever you want, and load that in the same namespace instead.

查看更多
登录 后发表回答