Case-sensitive search allows you to find words considering uppercase and lowercase letters as distinct. For example, in the context of case-sensitive search, the words ‘Theory’, ’theory’, and ‘THEORY’ are all different.
Note that case-sensitive search cannot be combined with fuzzy search, synonym search, homophone search, word forms search, spelling correction, and keyboard layout correction (see Search flow). If case-sensitive search is enabled together with any of these options, the search does not throw an exception: it returns an empty result and raises the error_occurred event of the index with a message describing the conflict. For details, see the Search options page.
The following example demonstrates how to perform case-sensitive search with a query in text form.
importosfromgroupdocs.searchimportIndexfromgroupdocs.search.optionsimportSearchOptionsindex=Index("./index")# Creating index in the specified folderindex.add("./documents")# Indexing documents from the specified folderoptions=SearchOptions()options.use_case_sensitive_search=True# Enabling case sensitive searchquery="Windows"result=index.search(query,options)# Searching# Printing the documents foundprint("Documents found:",result.document_count)fordocumentinresult:print(" ",os.path.basename(document.document_info.file_path),document.terms)
The next example demonstrates how to perform case-sensitive search with a query in object form.
importosfromgroupdocs.searchimportIndex,SearchQueryfromgroupdocs.search.optionsimportSearchOptionsindex=Index("./index")# Creating index in the specified folderindex.add("./documents")# Indexing documents from the specified folderoptions=SearchOptions()options.use_case_sensitive_search=True# Enabling case sensitive searchquery=SearchQuery.create_word_query("Windows")# Creating search query in object formresult=index.search(query,options)# Searching# Printing the documents foundprint("Documents found:",result.document_count)fordocumentinresult:print(" ",os.path.basename(document.document_info.file_path),document.terms)