Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't sort on multivalued field, but admin config allows selecting it #25

Closed
ksclarke opened this issue Apr 20, 2012 · 2 comments
Closed
Assignees
Labels
Milestone

Comments

@ksclarke
Copy link

Solr doesn't allow sorting on multivalue fields, but the SolrSearch plugins index configuration allows any field to be selected as a sort field. If you select a multivalue field to be a sort field and then try it, you get an exception in Solr:

org.apache.solr.core.SolrCore - org.apache.solr.common.SolrException: can not sort on multivalued field: 40_s
at org.apache.solr.schema.SchemaField.checkSortability(SchemaField.java:161)
at org.apache.solr.schema.FieldType.getStringSort(FieldType.java:527)
at org.apache.solr.schema.StrField.getSortField(StrField.java:40)
at org.apache.solr.schema.SchemaField.getSortField(SchemaField.java:144)
at org.apache.solr.search.QueryParsing.parseSort(QueryParsing.java:385)
at org.apache.solr.search.QParser.getSort(QParser.java:251)
at org.apache.solr.handler.component.QueryComponent.prepare(QueryComponent.java:102)
at org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:173)
at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:129)
at org.apache.solr.core.SolrCore.execute(SolrCore.java:1372)
at org.apache.solr.servlet.SolrDispatchFilter.execute(SolrDispatchFilter.java:356)
at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:252)

@ksclarke
Copy link
Author

Oh, looking a little deeper I see in the solr config:

<dynamicField name="*_s" multiValued="true" type="string" indexed="true" stored="true"/>

which means all fields are multivalued by default. So how does sort work at all when solr can't sort on multivalued fields? Or did Solr 3.6 add this? I'm using 3.5.

As a workaround, for fields you know aren't multivalued you can add the following to your solr schema config:

<field name="sortedTitle" type="text" indexed="true" stored="false" multiValued="false"/>
<!-- 50_s would be whatever the field is in your omeka install -->
<copyField source="50_s" dest="sortedTitle" />

If you add that for a field that really is multivalued though you'll get an error on indexing.

@ghost ghost assigned erochest May 2, 2012
@erochest
Copy link
Contributor

erochest commented May 2, 2012

We're stuck between two systems, here. Because we want to define fields dynamically and because all fields in Omeka can take multiple values, they all have to be marked multiValue for Solr. But Solr cannot sort multivalue fields.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants