pythonwhoosh

Add multiple filter to search in Whoosh


Faced with an issue. I need to create multiple filters to search in Whoosh. I tried to add filter in search like that

qp = qparser.QueryParser("content", myindex.schema)
user_q = qp.parse(query_string)
filter = And(list of Term)
results = s.search(user_q, filter=filter) 

but it doesn't work. What can be the problem?


Solution

  • The problem could be in this:

    filter = And(list of Term)

    Check my answer here for the general recipe of adding multiple filters:

    https://stackoverflow.com/a/72566461/4882462