Solr sort multivalued field

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Solr sort multivalued field

Marc Lammers
Hi All.



I want to sort my data by a multivalued field. I add this to my query
„*sort=field(foo,min)
asc“*. The configuration in the schema for this field is



<field name="foo" type="string" multiValued="true" indexed="true"
stored="true" docValues="true"/>



The solr documentation says that i have to add the docValues="true"
attribute for this field. After this I deleted the collection and
reimported the data. But when I execute my query I get the following error
message:

*„ sort param could not be parsed as a query, and is not a field that
exists in the index: field(foo,min)*“


Did I forget to set something?

Thanks in advance,

Marc
Reply | Threaded
Open this post in threaded view
|

Re: Solr sort multivalued field

Shawn Heisey-2
On 6/12/2018 2:56 AM, Marc Lammers wrote:
> I want to sort my data by a multivalued field. I add this to my query
> „*sort=field(foo,min)
> asc“*. The configuration in the schema for this field is
>
> <field name="foo" type="string" multiValued="true" indexed="true"
> stored="true" docValues="true"/>

The documentation for the field function says that the field must
contain numeric docvalues.  Your field has type="string" and although
you did not indicate what the definition of string is in your schema,
most likely it is the solr.StrField class.

https://lucene.apache.org/solr/guide/7_3/function-queries.html#FunctionQueries-field

Because this is not a numeric field, I'm guessing that it will not work
with the field function.  All of the examples for that function are
referencing a float field.

Thanks,
Shawn