Creates an inverted query that matches all documents not matching the specified query.
defcreate_not_query(cls,query):...
Parameter
Type
Description
query
SearchQuery
The query to invert.
Returns: A combined NOT query.
Example
fromgroupdocs.searchimportSearchQuery# Create a word query for "Einstein"einstein_query=SearchQuery.create_word_query("Einstein")# Invert the query to find documents that do NOT contain "Einstein"not_query=SearchQuery.create_not_query(einstein_query)# Combine with another query using ANDrelativity_query=SearchQuery.create_word_query("relativity")combined_query=SearchQuery.create_and_query(relativity_query,not_query)# Execute the searchresults=index.search(combined_query)