A convenience function for autocomplete use cases should be designed that returns a list of query suggestions based on the characters provided. Suggested implementation:
If only one token is provided, the query is automatically turned into a prefix query
The first token will be transformed into a ^token OR token query
If more than one token is provided, the last token will be turned into a prefix query, all other tokens will not be prefix queries, thus token1 token2 will become "^token1 OR token1 AND token2*
For the first implementation only one field can be searched for suggestions
API:
# return suggestions where title contains tokens that have the prefix "ind"
pocketsearch.autocomplete(title="Ind")
# return suggestions where title contains tokens "indiana" AND tokens with prefix "jo"
pocketsearch.autocomplete(title="Indiana jo")
# typeahead should return a Query objects, so we use all other methods on it:
pocketsearch.autocomplete(title="Indiana jo").order_by("-rank")
A convenience function for autocomplete use cases should be designed that returns a list of query suggestions based on the characters provided. Suggested implementation:
API: