Synonym search allows you to find not only the words specified in the search query, but also their synonyms, that is, words that mean the same.
To enable synonym search, you must set the use_synonym_search property of the SearchOptions class to True. By default, synonym search is disabled. Synonym search cannot be combined with case-sensitive search. If synonym search is enabled together with case-sensitive search, or if the synonym dictionary of the index is empty, the search returns an empty result and the error is reported through the error_occurred event (see Search options).
The default synonym dictionary contains synonyms only for the English language. To manage the synonym dictionary, see the Synonym dictionary page in the Managing dictionaries section.
The following example demonstrates the synonym search.
importosfromgroupdocs.searchimportIndexfromgroupdocs.search.optionsimportSearchOptions# Creating an index in the specified folderindex=Index("./index")# Indexing documents from the specified folderindex.add("./documents")# Creating a search options objectoptions=SearchOptions()options.use_synonym_search=True# Enabling synonym search# Search for the word 'answer'# In addition to the word 'answer', the words 'reply' and 'response' will also be foundresult=index.search("answer",options)# Printing the words found in each documentprint("Documents found:",result.document_count)fordocumentinresult:print(" ",os.path.basename(document.document_info.file_path),document.terms)