Re: sorting by score and an additional field
Erik: doc.add(Field.Keyword("rank_field", rank_value)); is what I use to build my customized rank field. Considering the rank_value is an integer, should it be zero padded? Currently I have it padded because the rest of lucene needs it that way, should it be the same here? If I specify INT or STRING, the sort of rank works just fine... but its when I combine the two that I have issues. I'm using 1.4.2... but I'll see how my code differs from yours and give it a try.. can you tell me how you indexed your secondary rank field? as a keyword or what have you? Thanks, Chris Fraschetti On Thu, 4 Nov 2004 04:33:12 -0500, Erik Hatcher <[EMAIL PROTECTED]> wrote: > On Nov 3, 2004, at 9:52 PM, Chris Fraschetti wrote: > > Has anyone had any luck using lucene's built in sort functions to sort > > first by the lucene hit score and secondarily by a Field in each > > document indexed as Keyword and in integer form? > > I get multiple sort fields to work, here's two examples: > > new Sort(new SortField[]{ > new SortField("category"), > SortField.FIELD_SCORE, > new SortField("pubmonth", SortField.INT, true) > }); > >new Sort(new SortField[] {SortField.FIELD_SCORE, new > SortField("category")}) > > Both of these, on a tiny dataset of only 10 documents, works exactly as > expected. > > > I can only get it to sort by one or the other... but when it does one, > > it does sort correctly, but together in {score, custom_field} only the > > first sort seems to apply. > > > > Any ideas? > > Are you using Lucene 1.4.2? How did you index your integer field? Are > you simply using the .toString() of an Integer? Or zero padding the > field somehow? You can use the .toString method, but you have to be > sure that the sorting code does the right parsing of it - so you might > need to specify SortField.INT as its type. It will do automatic > detection if the type is not specified, but that assumes that the first > document it encounters parses properly, otherwise it will fall back to > using a String sort. > >Erik > > > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- ___ Chris Fraschetti, Student CompSci System Admin University of San Francisco e [EMAIL PROTECTED] | http://meteora.cs.usfca.edu - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: sorting by score and an additional field
On Nov 3, 2004, at 9:52 PM, Chris Fraschetti wrote: Has anyone had any luck using lucene's built in sort functions to sort first by the lucene hit score and secondarily by a Field in each document indexed as Keyword and in integer form? I get multiple sort fields to work, here's two examples: new Sort(new SortField[]{ new SortField("category"), SortField.FIELD_SCORE, new SortField("pubmonth", SortField.INT, true) }); new Sort(new SortField[] {SortField.FIELD_SCORE, new SortField("category")}) Both of these, on a tiny dataset of only 10 documents, works exactly as expected. I can only get it to sort by one or the other... but when it does one, it does sort correctly, but together in {score, custom_field} only the first sort seems to apply. Any ideas? Are you using Lucene 1.4.2? How did you index your integer field? Are you simply using the .toString() of an Integer? Or zero padding the field somehow? You can use the .toString method, but you have to be sure that the sorting code does the right parsing of it - so you might need to specify SortField.INT as its type. It will do automatic detection if the type is not specified, but that assumes that the first document it encounters parses properly, otherwise it will fall back to using a String sort. Erik - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: sorting by score and an additional field
On Thursday 04 November 2004 03:52, Chris Fraschetti wrote: > I can only get it to sort by one or the other... but when it does one, > it does sort correctly, but together in {score, custom_field} only the > first sort seems to apply. Do you use real documents for that test? The score is a float value and it's hardly ever the same for two documents (unless you use very short test documents), so that's why the second field may not be used for sorting. regards Daniel -- http://www.danielnaber.de - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
sorting by score and an additional field
I mailed on this a while back, but am still at a loss. Has anyone had any luck using lucene's built in sort functions to sort first by the lucene hit score and secondarily by a Field in each document indexed as Keyword and in integer form? I can only get it to sort by one or the other... but when it does one, it does sort correctly, but together in {score, custom_field} only the first sort seems to apply. Any ideas? Thanks in advance! -Chris Fraschetti - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]