quickwit-oss / tantivy-py

Python bindings for Tantivy
MIT License
275 stars 63 forks source link

Expose Tantivy's TermSetQuery #249

Closed aecio closed 5 months ago

aecio commented 5 months ago

This PR adds the Query.term_set_query method and corresponding tests.

Expected usage:

terms = ["old", "man"]
query = Query.term_set_query(index.schema, "title", terms)
result = index.searcher().search(query, 10)

The new term_set_query method has a signature similar to the existing term_query:

@staticmethod
def term_query(schema: Schema, field_name: str, field_value: Any, index_option: str = "position") -> Query:
    pass

@staticmethod
def term_set_query(schema: Schema, field_name: str, field_values: Sequence[Any]) -> Query:
    pass

See also issue https://github.com/quickwit-oss/tantivy-py/issues/20.