[Xapian-discuss] Summing collapsed values
Olly Betts
olly at survex.com
Thu Mar 26 03:04:30 GMT 2009
On Wed, Mar 25, 2009 at 07:45:03PM +0000, Richard Boulton wrote:
> On Wed, Mar 25, 2009 at 07:08:56PM +0000, Simon Roe wrote:
> > Another element I've just thought of: I'd like to sort by the summed
> > value too...
> >
> > I guess that eliminates the double search option, would the matchspy
> > option handle this?
>
> No - you won't be able to sort by the summed value inside xapian; this kind
> of thing isn't really how Xapian is designed to be used.
The real problem here is that the sort key needs to be known at the
point at which we first "see" the document. So we can sort by
relevance, document id, values (or strings derived from them), or
something external (which can depend on the docid or values), or a
combination, but we can't sort on something that depends on documents
we've yet to see. And that's pretty fundamental to how the matcher
works.
You could run the search twice, and pick out and store the sums the
first time, then sort by them the second time. If your query load
is at all heavy though, it would be better to precalculate (or at
least cache) these sums.
Cheers,
Olly
More information about the Xapian-discuss
mailing list