You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@lucene.apache.org by jreeman <mi...@hotmail.com> on 2007/02/10 21:39:03 UTC

Sorting in a particular case

Hello,


Here is my problem : let say that a document can have one of its meta data
let's say 'domains' set either to "domain1" either to "domain2" either to
value "all_domains".

"all_domains" meaning the both domains ("domain1" and "domain2") are linked
to the document or rather the documents belongs to the two domains.

Now let's figure out that there are three documents:

the first "document1" has its metadata "domains" set to "domain1"
the second "document2" has its metadata "domains" set to "domain2"
the third document "document3" has its metadata "domains" set to
"all_domains".



My issue is to retrieve the first two documents sorted by relevance like
that :

document1 
document2


of course : when the user wants the documents belonging to "domain1".

Perhaps, do you have a solution to do this with lucene ?

Thang you for your help in advance.
-- 
View this message in context: http://www.nabble.com/Sorting-in-a-particular-case-tf3206612.html#a8904585
Sent from the Lucene - General mailing list archive at Nabble.com.

Re: Sorting in a particular case

Posted by Steven Rowe <sa...@syr.edu>.
jreeman wrote:
> could you tell me what is the value of the score of the hits when the
> query contains only criteria on metadata looking something like that
> : domains:domain1 or domains:all_domains ?

FYI, if you're using the Java version of Lucene, more people listen to
the java-user@l.a.o list than to this list (general@l.a.o).

Assuming you're using QueryParser, you should be using "OR" instead of
"or" for the operator.  Incidentally, QueryParser's default operator is
already "OR", so unless you've changed the default operator[1], the
following two queries are equivalent:

    domains:domain1 OR domains:all_domains

    domains:domain1 domains:all_domains

To sort documents that match the more specific component of the query
higher, give the more specific component a boost, e.g. (below is a
QueryParser query - note that there are equivalent API methods to set
boosts[2]):

    domains:domain1^10 domains:all_domains

The default boost is 1, so the above query gives 10 times more weight to
documents that have the "domain1" term than to those with the
"all_domains" term.

Steve

[1] QueryParser.setDefaultOperator():
<http://lucene.apache.org/java/docs/api/org/apache/lucene/queryParser/QueryParser.html#setDefaultOperator(org.apache.lucene.queryParser.QueryParser.Operator)>

[2] Query.setBoost():
<http://lucene.apache.org/java/docs/api/org/apache/lucene/search/Query.html#setBoost(float)>


Re: Sorting in a particular case

Posted by jreeman <mi...@hotmail.com>.
I have perhaps a solution :

could you tell me what is the value of the score of the hits when the query
contains only criteria on metadata looking something like that :
domains:domain1 or domains:all_domains ?

If so, I could put the metadata in the indexed field of my document and
write a query like that 

(domain) domains:domain1 or domains:all_domains.

do you think I'll get the hits sorted in the manner I want ?
-- 
View this message in context: http://www.nabble.com/Sorting-in-a-particular-case-tf3206612.html#a8904903
Sent from the Lucene - General mailing list archive at Nabble.com.