You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Enrique Lamas <en...@corp.ya.com> on 2006/02/27 12:12:22 UTC

Problem with reverse ordering

Hi,
I have an index with some fields, one of them is a String representing a 
date in the format yyyyMMddHHmmss.
I store this field as a Keyword to be sortable.

My problem is that I obtain the results in the same order with
Hits hits = is.search(query, new Sort("formatted-date"));
than
Hits hits = is.search(query, new Sort("formatted-date", true));


doen anyone why this could be happening?

Thanks


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Re: queryParser and sorting question

Posted by Enrique Lamas <en...@corp.ya.com>.
Thanks Chris, I'll try that.

Bye

----- Original Message ----- 
From: "Chris Hostetter" <ho...@fucit.org>
To: <ja...@lucene.apache.org>
Sent: Tuesday, July 25, 2006 3:46 AM
Subject: Re: queryParser and sorting question



1) subclass DefaultSimilarity so that tf/idf allways return either
0 or 1 (more info on this can be found in the archives).

2) sort on score, and then your specific field as a secondary sort.

Of the top of my head, that should give you what you want ... but there
may be something else about the score that you have to tweak with the
Similarity class ... Searcher.explain will help you check that you get
consistent scores in all of your potential cases.

: Date: Mon, 24 Jul 2006 15:19:32 +0200
: From: Enrique Lamas <en...@corp.ya.com>
: Reply-To: java-user@lucene.apache.org
: To: java-user@lucene.apache.org
: Subject: queryParser and sorting question
:
: Hi,
: I'm, trying to execute a query to find some words, and I'm using
:
: QueryParser queryParser = new MultiFieldQueryParser(new String[] {"tags",
: "title"}, ProcessConstants.analyzer);
: Query query = queryParser.parse("word1 word2 word3");
:
: I want to show the results sorted like this:
:
: first, documents containing all of the three words, and this documents
: sorted by one of the index fields.
: Next, documents containing two of the words, also sorted by the same field
: like before.
: And so on.
:
: ¿How can I do this?
:
: I wold like to avoid executing several queries of this kind:
: "word1 + word2 + word3"
: "word1 + word2 - word3"
: "word1 - word2 + word3"
: "word1 - word2 - word3"
: .....
:
: Thanks
:
:
: ---------------------------------------------------------------------
: To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
: For additional commands, e-mail: java-user-help@lucene.apache.org
:



-Hoss


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Re: queryParser and sorting question

Posted by Chris Hostetter <ho...@fucit.org>.
1) subclass DefaultSimilarity so that tf/idf allways return either
0 or 1 (more info on this can be found in the archives).

2) sort on score, and then your specific field as a secondary sort.

Of the top of my head, that should give you what you want ... but there
may be something else about the score that you have to tweak with the
Similarity class ... Searcher.explain will help you check that you get
consistent scores in all of your potential cases.

: Date: Mon, 24 Jul 2006 15:19:32 +0200
: From: Enrique Lamas <en...@corp.ya.com>
: Reply-To: java-user@lucene.apache.org
: To: java-user@lucene.apache.org
: Subject: queryParser and sorting question
:
: Hi,
: I'm, trying to execute a query to find some words, and I'm using
:
: QueryParser queryParser = new MultiFieldQueryParser(new String[] {"tags",
: "title"}, ProcessConstants.analyzer);
: Query query = queryParser.parse("word1 word2 word3");
:
: I want to show the results sorted like this:
:
: first, documents containing all of the three words, and this documents
: sorted by one of the index fields.
: Next, documents containing two of the words, also sorted by the same field
: like before.
: And so on.
:
: ¿How can I do this?
:
: I wold like to avoid executing several queries of this kind:
: "word1 + word2 + word3"
: "word1 + word2 - word3"
: "word1 - word2 + word3"
: "word1 - word2 - word3"
: .....
:
: Thanks
:
:
: ---------------------------------------------------------------------
: To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
: For additional commands, e-mail: java-user-help@lucene.apache.org
:



-Hoss


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


queryParser and sorting question

Posted by Enrique Lamas <en...@corp.ya.com>.
Hi,
I'm, trying to execute a query to find some words, and I'm using

QueryParser queryParser = new MultiFieldQueryParser(new String[] {"tags", 
"title"}, ProcessConstants.analyzer);
Query query = queryParser.parse("word1 word2 word3");

I want to show the results sorted like this:

first, documents containing all of the three words, and this documents 
sorted by one of the index fields.
Next, documents containing two of the words, also sorted by the same field 
like before.
And so on.

¿How can I do this?

I wold like to avoid executing several queries of this kind:
"word1 + word2 + word3"
"word1 + word2 - word3"
"word1 - word2 + word3"
"word1 - word2 - word3"
.....

Thanks


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org