문제

I'm trying to understand if it's possible to use RandomSortField in conjunction with another field to sort search results with solr. Let me explain better: I have a SearchQuerySet (I'm using haystack) that is already ordered by a field N but the client want to randomize the search results maintaining the order of the field N, so that the results are randomized inside the "groups" defined by the field N. Before doing everything I would like to now if someone had the same problem and if it's doable using solr (and haystack).

도움이 되었습니까?

해결책

See this. After adding these to your schema.xml:

<types>
  ...
  <fieldType name="random" class="solr.RandomSortField" />
  ... 
 </types>
 <fields>
  ...
  <dynamicField name="random*" type="random" indexed="true" stored="false"/>
  ...
 </fields>

you can do:

sort=fieldN asc,random_XYZ asc

Keep changing XYZ for different ordering within each group of fieldN.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top