Hello,

I'd like to use the setAllowLeadingWildcard method with
PythonMultiFieldQueryParser but I always get a

lucene.JavaError: org.apache.lucene.queryParser.ParseException: Cannot
parse '*a': '*' or '?' not allowed as first character in WildcardQuery

It works fine with PythonQueryParser but not with
PythonMultiFieldQueryParser.
Some code to trace what I mean:


from lucene import StandardAnalyzer, IndexSearcher, PythonQueryParser, \
    PythonMultiFieldQueryParser, BooleanClause, Version, initVM, \
    SimpleFSDirectory, File
initVM()
indexDir = "index-dir"
analyzer = StandardAnalyzer(Version.LUCENE_CURRENT)
searcher = IndexSearcher(SimpleFSDirectory(File(indexDir)), True)

querystring="*a"

parser = PythonQueryParser(Version.LUCENE_CURRENT, 'name', analyzer)
parser.setAllowLeadingWildcard(True)
query = parser.parse(querystring)
hits = searcher.search(query, 10)
print "PythonQueryParser works just fine:",hits

parser = PythonMultiFieldQueryParser(Version.LUCENE_CURRENT, ['name'],
analyzer)
parser.setAllowLeadingWildcard(True)
query=parser.parse(Version.LUCENE_CURRENT, querystring, ['name'],
    [BooleanClause.Occur.SHOULD], analyzer)
# lucene.JavaError will occur
hits = searcher.search(query, 10)


Is it my code or is setAllowLeadingWildcard not working properly with
PythonMultiFieldQueryParser?

Thanks,
Daniel

Reply via email to