lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Helmut Jarausch <jarau...@igpm.rwth-aachen.de>
Subject FuzzyQuery + QueryParser - I'm puzzled
Date Mon, 17 Dec 2007 09:27:58 GMT
Hi,

please help I am totally puzzled.

The same query, once with a direct call to FuzzyQuery
succeeds while the same query with QueryParser fails.

What am I missing?

Sorry, I'm using pylucene (with lucene-java-2.2.0-603782)

#!/usr/bin/python
import lucene
from lucene import *
lucene.initVM(lucene.CLASSPATH)

directory = RAMDirectory()
writer = IndexWriter(directory, WhitespaceAnalyzer(), True)
doc = Document()
doc.add(Field("field","Wolfgang Dahmen  Arnold Reusken",
              Field.Store.YES, Field.Index.TOKENIZED))
writer.addDocument(doc)

writer.optimize()
writer.close()

searcher = IndexSearcher(directory)

FQ= True
# FQ= False   # this case doesn't find anything  <+++++  WHY 

if  FQ :
  # this succeeds in finding the entry above
  query = FuzzyQuery(Term("field", "Damen"),0.79,0)
else :
  # this fails to find that entry
  parser= QueryParser("field",WhitespaceAnalyzer())
  query= parser.parse("Damen~0.79")

hits = searcher.search(query)
print "there are",hits.length(),"hits"
for k in range(0,hits.length()) :
  print hits.doc(k).get("field")

-- 
Helmut Jarausch

Lehrstuhl fuer Numerische Mathematik
RWTH - Aachen University
D 52056 Aachen, Germany

---------------------------------------------------------------------
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