Вопрос

I have came across a number of questions lamenting the inability to handle multivalued fields for sorting, however they were dated 1 or 2 years ago. I wonder whether newer versions of Solr (4.4) and SolrJ (4.3.0) allows sorting on multivalued fields. In my case, I have the field:

<field name="title" type="text_general" indexed="true" stored="true" multiValued="true"/>

And my Java-based implementation looks like:

query.setQuery(qs).
setIncludeScore(true);

if (sort != null) {

            query.addSort("author", SolrQuery.ORDER.desc);  

        } else {

            query.addSort( "score", SolrQuery.ORDER.desc );
                       }

Is there any way to sort multivalued fields? Currently, I am returned with the following error:

Exception: AbstractSearchAction: Unexpected error occured while performing a search. Cause: {1} 
javax.ejb.EJBException: can not sort on multivalued field: title

Thank you for your help,

I.

Это было полезно?

Решение

It was only recently (Feb 14) implemented in Lucene, see https://issues.apache.org/jira/browse/LUCENE-5454

So it will take some time before the feature is available in Solr. In the issue, you can see it is scheduled for version 4.8 or 5.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top