Reputation: 23
I'm using PyLucene and trying to use MultiFieldQueryParser with field boosting. I saw in the documentation that the constructor's fields are MultiFieldQueryParser(String[] fields, Analyzer analyzer, Map<String,Float> boosts)
(boosts being optional) and wrote my constructor like this:
def mapFunc(a, b):
return b
mapping = map(mapFunc, ("Post", "Title", "Comments", "Subreddit"), (1, 1.2, 0.1, 0.5))
def retrieve(storeDir, query, amt:int):
searchDir = NIOFSDirectory(Paths.get(storeDir))
searcher = IndexSearcher(DirectoryReader.open(searchDir))
# parser = QueryParser("Post", StandardAnalyzer())
# parser = MultiFieldQueryParser(["Post", "Title", "Comments", "Subreddit"], StandardAnalyzer(), mapping)
parser = MultiFieldQueryParser(["Post", "Title", "Comments", "Subreddit"], StandardAnalyzer())
parsed_query = parser.parse(query)
Didn't find much in terms of PyLucene documentation, and the few examples I found on Lucene were for Java and did not include examples for boosting.
I tried removing the boost mapping to see if it would work and got a different error saying 'parse' for 'QueryParserBase' object doesn't apply to a 'str' object (not sure what that's all about, the QueryParser worked just fine).
Using boost mapping gave me this error about invalid arguments. Not sure how to fix this, do I need to wrap the Python map in a Java container? If so, how would I do that?
Upvotes: 0
Views: 43