lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christian Bongiorno <christ...@bongiorno.org>
Subject Re: term query boost problem
Date Thu, 13 Aug 2009 04:10:50 GMT
turns out the index is being built with lower-case terms which is why we
aren't getting hits the way we expect. When I change my search terms to
lower I see more of what I expect.

Gonna keep working on this and post updates.

On Wed, Aug 12, 2009 at 12:46 PM, Christian Bongiorno <
christian@bongiorno.org> wrote:

> I have a situation where I have a series of terms queries as part of a
> BooleanQuery.
>
> example:
>
> term: 'sole type' -> leather
>   BooleanClause.SHOULD_OCCURR
> term: 'title' -> 'Men's Golf shoes'
>   BooleanClause.SHOULD_OCCURR
> ...
>
> But, some terms are incredibly powerful indicators of match
> term: 'band type' -> 'gold'
>
> Normally, I would set this as a field boost in the query. Problem is, it
> isn't producing ANY changes even when I set the boost score absurdly high. I
> have also tried to set the BooleanClause.MUST on my really important term
> and I get no results at all.
>
> I tried a simple TermQuery for that (no clause) and got no results. Below
> is a code snippet. I checked through the recent archives discussing field
> boosts and I am pretty confident I am doing it right. So, now I am presuming
> it's a problem with my query.
>
>     private Query buildQuery(Map<String, String> CatalogInfo) {
>         if (CatalogInfo != null && CatalogInfo.size() > 0) {
>             BooleanQuery booleanQuery = new BooleanQuery();
>             for (Map.Entry<String, String> attributeValue :
> CatalogInfo.entrySet()) {
>                 String attributeName = attributeValue.getKey();
>                 String[] attributeValues;
>                 if (attributeValue.getValue().indexOf(VALUES_DELIMITER) ==
> -1) {
>                     attributeValues = new String[]
> {attributeValue.getValue()};
>                 } else {
>                     attributeValues =
> attributeValue.getValue().split(VALUES_DELIMITER);
>                 }
>                 for (String attributeValue : attributeValues) {
>                     String escapedValue =
> QueryParser.escape(attributeValue).trim();
>                     TermQuery termQuery = new TermQuery(new
> Term(attributeName, escapedValue));
>
>
>                     Float boostNumber = _boostMap.get(attributeName); //
> this is where 'band type' gets it's boost
>                     if (boostNumber != null) {
>                         LOG.warn("Boost value found: " + boostNumber);
>                         termQuery.setBoost(boostNumber);
>                     }
>                     booleanQuery.add(termQuery,
> BooleanClause.Occur.SHOULD);
>                 }
>             }
>             LOG.warn("Boolean query: " + booleanQuery.toString());
>             return booleanQuery;
>         }
>         return null;
>     }
> --
> Christian Bongiorno
>
>


-- 
Christian Bongiorno

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message