I'm confused. What do you mean that a user can "set any number of arbitrarily named fields on a document". It sounds like you are talking about a user adding arbitrarily may entries to a multi-valued field? Or is it some kind of key:value pairs in a field in your schema?
Under any circumstances, sorting on a multi-valued field is...er... hard. What does sorting mean there? Sort by the first value entered? The second? The 15th? This is indeterminate behavior. What is the over-arching problem you're addressing? I wonder if this is an XY problem. see: http://people.apache.org/~hossman/#xyproblem Best Erick On Fri, Oct 8, 2010 at 8:15 PM, Simon Wistow <si...@thegestalt.org> wrote: > On Fri, Oct 08, 2010 at 04:56:38PM -0700, kenf_nc said: > > > > What behavior are you trying to see? You are allowed to sort on fields > that > > are potentially empty, they just sort to the top or bottom depending on > your > > sort order. Now, if you Query on the fields that could be empty, you > won't > > see the result, but if your document is valid for the query, you can sort > on > > whatever field you want whether the document has that field or not. > > A user can set any number of arbitarily named fields on a document. We'd > like to be able to sort by those fields. > > The problem is that users can set multiple arbitary fields and we may > have thousands of them - it would be impractical for us to have these as > actual fields in the schema. > > If I could sort on only the matching values of a multi valued field then > this would be easy - I'd just collapse down key / value pairs to > <key>_<value> and then search for user_field:<key>_* > > > > > >