lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Casey Dement <cdem...@weather.com>
Subject Query works in Luke but not in code...
Date Thu, 22 May 2008 22:21:14 GMT
Hi - trying to execute a search in Lucene and getting results I don't
understand :(

The index contains fields search_text and type - both indexed tokenized.
I'm attempting to execute the query:

  +(search_text:austell~0.9 search_text:ga~0.9) +(type:1 type:4)

And expect to match document 156297 (search_text=="Austell GA", type==1).

I am executing this query both directly in code and via the tool Luke - but
getting WILDLY different answers.  In Luke, the expected document is found
no problem, but in my own code I find no results.  Obviously I suspect my
code of being crap ;)

Oh, FYI, in both my local code and Luke I am using a StandardAnalyzer and
the default column is "search_text".

Here's what I'm doing:

  /******************************************************************/
  File location = new File("/the/correct/path");
  IndexReader index = IndexReader.open(location);
  Searcher searcher = new IndexSearcher(index);
  QueryParser parser = new QueryParser("search_text", new
StandardAnalyzer());
  Query query = parser.parse("+(search_text:austell~0.9 search_text:ga~0.9)
+(type:1 type:4)");
  System.out.println(searcher.explain(query, 156296));
  /******************************************************************/

When I run this, I get:
|  0.0000 = (NON-MATCH) Failure to meet condition(s) of required/prohibited
clause(s)
|    0.0000 = no match on required clause (() ())
|      0.0000 = (NON-MATCH) product of:
|        0.0000 = (NON-MATCH) sum of:
|        0.0000 = coord(0/2)
|    0.2133 = (MATCH) product of:
|      0.4267 = (MATCH) sum of:
|        0.4267 = (MATCH) weight(type:1 in 156296), product of:
|          0.3672 = queryWeight(type:1), product of:
|            1.1618 = idf(docFreq=315734, numDocs=371197)
|            0.3161 = queryNorm
|          1.1618 = (MATCH) fieldWeight(type:1 in 156296), product of:
|            1.0000 = tf(termFreq(type:1)=1)
|            1.1618 = idf(docFreq=315734, numDocs=371197)
|            1.0000 = fieldNorm(field=type, doc=156296)
|      0.5000 = coord(1/2)

So obviously I'm loading the index (since it did match the "type") - but it
seems to be COMPLETELY ignoring the criteria on "search_text".

When I run this exact same string in Luke, I get:
|  8.0079 = (MATCH) sum of:
|    7.9578 = (MATCH) sum of:
|      5.4904 = (MATCH) weight(search_text:austell in 156297), product of:
|        0.8074 = queryWeight(search_text:austell), product of:
|          10.8800 = idf(docFreq=18, numDocs=371197)
|          0.0742 = queryNorm
|        6.8000 = (MATCH) fieldWeight(search_text:austell in 156297),
product of:
|          1.0000 = tf(termFreq(search_text:austell)=1)
|          10.8800 = idf(docFreq=18, numDocs=371197)
|          0.6250 = fieldNorm(field=search_text, doc=156297)
|      2.4673 = (MATCH) weight(search_text:ga in 156297), product of:
|        0.5413 = queryWeight(search_text:ga), product of:
|          7.2936 = idf(docFreq=685, numDocs=371197)
|          0.0742 = queryNorm
|        4.5585 = (MATCH) fieldWeight(search_text:ga in 156297), product of:
|          1.0000 = tf(termFreq(search_text:ga)=1)
|          7.2936 = idf(docFreq=685, numDocs=371197)
|          0.6250 = fieldNorm(field=search_text, doc=156297)
|    0.0501 = (MATCH) product of:
|      0.1002 = (MATCH) sum of:
|        0.1002 = (MATCH) weight(type:1 in 156296), product of:
|          0.0862 = queryWeight(type:1), product of:
|            1.1618 = idf(docFreq=315734, numDocs=371197)
|            0.0742 = queryNorm
|          1.1618 = (MATCH) fieldWeight(type:1 in 156296), product of:
|            1.0000 = tf(termFreq(type:1)=1)
|            1.1618 = idf(docFreq=315734, numDocs=371197)
|            1.0000 = fieldNorm(field=type, doc=156296)
|      0.5000 = coord(1/2)

Which while clearly looking at the same document ID in the same index is
conversely working perfectly!

Does anybody have any idea where I am screwing up?  Thanks!

Casey


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


Mime
View raw message