lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Hostetter <>
Subject Re: custom sort
Date Wed, 31 Aug 2005 22:11:20 GMT

: What I'm doing now is taking the whole resulting document collection,
: iterating through it and manually moving these 10 documents to the front
: of the collection.  This is slow and ugly.  I was hoping there might be
: a slicker way to do it as part of the actual sort.  I will play around
: with the custom sorting and report back if I figure out an elegant way
: to do it.

you could definitely do this with a Custom Sort ... but a simpler way to
go would be to do two searches.  if the users's basic search criteria is
soemthing like "foo:bar +yak:wak" and the criteria for identifying the
documents you want to return is "promote:yes" then first issue a search
for "+promote:yes +(foo:bar +yak:wak)" and display the first N, and keep
track of hte identity of the N that you display  Then do
a search for "foo:bar +yak:wak -id:id1 -id:id2 -id:id3 ... -id:idN"

this is assuming that you you only want to display the first N (sounds
like N is ten) but there might be a lot more then N which match but you
want the rest to display in their regular spots.  if you want them *ALL*
to be in the front, then making your second search "-promote:yes +(foo:bar
+yak:wak)" should work just fine.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message