lucene-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Remijan <mjremi...@yahoo.com>
Subject Having trouble getting QueryParser to work...
Date Wed, 21 Sep 2011 16:20:06 GMT
Sorry if this is an obvious question.

I have the following BooleanQuery set up which works fine, and when I say "fine" I mean if
I change the search values to values which I know are not in the index then the search returns
no results. So this works OK.

        Query
             dinnerQuery     = new TermQuery(new Term("entry", "dinner"))
               ,accountIdQuery = new TermQuery(new Term("accountid", NumericUtils.intToPrefixCoded(1)))
        ;           
        BooleanQuery 
            query = new BooleanQuery();
              query.add(accountIdQuery, Occur.MUST);
              query.add(dinnerQuery, Occur.MUST);

When I run the above code I get 1 result I am expecting:

Found 1 hits
HIT #1
  accountid = 1
  journalid = 1
  id = 306



Now I've been trying to convert this to use a QueryParser expression but I have not had any
luck.  Here is my first attempt.

        String str =
            "accountid:1 AND entry:dinner"                    
        ;        
        Query query 
            = parser.parse(str);

When I execute this, I get no results:

Found 0 hits

So I changed the query to use NumericUtils thinking that might be the problem...

        String str =
            "accountid:" +NumericUtils.intToPrefixCoded(1)+ " AND entry:dinner"   
            
        ;        
        Query query 
            = parser.parse(str);

When I execute this, I thought I got the results I was looking for because the query found
the 1 hit it was suppose to, however, during testing I found I could put any value i want
in for accountid and the search will always return the 1 hit.  

So I'm not sure what I'm doing wrong and why QueryParser is giving the results it is.
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message