Welcome to OGeek Q&A 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 Reply

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

56.8k users

...