Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

sorting - Solr: Random sort order after index version change

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...