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 ErrorOccurred event of the index with a message describing the conflict. For details, see the Search options page.
A word pattern (see Wildcard search) and a regular expression (see Regular expression search) are matched with the words of the index without regard to the letter case. Since version 26.11, in a case-sensitive search such a part of a query finds the words in any letter case, and the Warnings property of the result tells it by the line “Letter case ignored for query: " followed by the part of the query; the other parts of the query are case-sensitive. Before, such a part found only the occurrences of the words in lower case: for example, the pattern Vend?(0~5) found ‘vendor’ but not ‘Vendor’. A word that such a part finds is given in the found terms (FoundDocumentField.Terms) in its form in lower case, in upper case or with the first letter in upper case, for example ‘vendor’, ‘VENDOR’ and ‘Vendor’, and the highlighting marks these forms as it marks the words of a case-sensitive search. A word written in another mix of the cases, for example ‘VenDor’, is found and counted, but it is given in lower case and is not highlighted. To find one form of a word, search for the word itself.
The following example demonstrates how to perform case-sensitive search with a query in text form.
C#
stringindexFolder=@"c:\MyIndex\";stringdocumentsFolder=@"c:\MyDocuments\";Indexindex=newIndex(indexFolder);// Creating index in the specified folderindex.Add(documentsFolder);// Indexing documents from the specified folderSearchOptionsoptions=newSearchOptions();options.UseCaseSensitiveSearch=true;// Enabling case sensitive searchstringquery="Windows";SearchResultresult=index.Search(query,options);// Searching
The next example demonstrates how to perform case-sensitive search with a query in object form.
C#
stringindexFolder=@"c:\MyIndex\";stringdocumentsFolder=@"c:\MyDocuments\";Indexindex=newIndex(indexFolder);// Creating index in the specified folderindex.Add(documentsFolder);// Indexing documents from the specified folderSearchOptionsoptions=newSearchOptions();options.UseCaseSensitiveSearch=true;// Enabling case sensitive searchSearchQueryquery=SearchQuery.CreateWordQuery("Windows");// Creating search query in object formSearchResultresult=index.Search(query,options);// Searching
More resources
GitHub examples
You may easily run the code from documentation articles and see the features in action in our GitHub examples: