FAQ
Hi!
My index contains a few (really 7) fields and I need to search by all
of them. I use BooleanQuery and seven TermQueries added to this one.
Problem: result must to be sorted by max(field.boost), not by Lucene’s
default formula.
I think, for this I need to implement MySimilarity (it will simply
return 1.0 from all methods – empty similarity), MyBooleanQuery (and
MyBooleanWeight, and MyBooleanScorer), MyTermQuery (and MyTermWeight,
and MyTermScorer), and at last MyCollector. Collector should be
overridden because at this point possible change default summation to
max().
Maybe I was mistaken and there is more straightforward way to realize
such behavior?
Thanks in advance!
Dmytro

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

Search Discussions

  • Umesh Prasad at Jan 24, 2011 at 9:26 am
    DisjunctionMaxQuery may be one you are looking for.
    http://lucene.apache.org/java/2_4_0/api/org/apache/lucene/search/DisjunctionMaxQuery.html
    *This is useful when searching for a word in multiple fields with
    different boost factors (so that the fields cannot be combined equivalently
    into a single search field). We want the primary score to be the one
    associated with the highest boost, not the sum of the field scores (as
    BooleanQuery would give)*

    Thanks & Regards
    Umesh
    On Mon, Jan 24, 2011 at 2:09 PM, Dmytro Barabash wrote:
    Hi!
    My index contains a few (really 7) fields and I need to search by all
    of them. I use BooleanQuery and seven TermQueries added to this one.
    Problem: result must to be sorted by max(field.boost), not by Lucene’s
    default formula.
    I think, for this I need to implement MySimilarity (it will simply
    return 1.0 from all methods – empty similarity), MyBooleanQuery (and
    MyBooleanWeight, and MyBooleanScorer), MyTermQuery (and MyTermWeight,
    and MyTermScorer), and at last MyCollector. Collector should be
    overridden because at this point possible change default summation to
    max().
    Maybe I was mistaken and there is more straightforward way to realize
    such behavior?
    Thanks in advance!
    Dmytro

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


    --
    ---
    Thanks & Regards
    Umesh Prasad
  • Dmytro Barabash at Jan 24, 2011 at 9:32 am
    Thanks a lot, Umesh!

    2011/1/24 Umesh Prasad <umesh.iitk@gmail.com>:
    DisjunctionMaxQuery may be one you are looking for.
    http://lucene.apache.org/java/2_4_0/api/org/apache/lucene/search/DisjunctionMaxQuery.html
    *This is useful when searching for a word in multiple fields with
    different boost factors (so that the fields cannot be combined equivalently
    into a single search field). We want the primary score to be the one
    associated with the highest boost, not the sum of the field scores (as
    BooleanQuery would give)*

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

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupjava-user @
categorieslucene
postedJan 24, '11 at 8:39a
activeJan 24, '11 at 9:32a
posts3
users2
websitelucene.apache.org

2 users in discussion

Dmytro Barabash: 2 posts Umesh Prasad: 1 post

People

Translate

site design / logo © 2022 Grokbase