When entering search queries, users of your software may make input errors, forgetting to switch the desired keyboard layout. For example, entering the word ‘Einstein’ in the Russian keyboard layout will result in the word ‘Уштыеушт’ appearing.
To automatically fix such misprints, the keyboard layout correction feature can be used. To enable this feature, you must set the True value for the enabled property in the search options. By default, this feature is disabled.
Keyboard layout correction cannot be combined with case-sensitive search. If both are enabled, the search returns an empty result and the error is reported through the error_occurred event (see Search options).
The following example demonstrates the use of the keyboard layout correction feature.
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.keyboard_layout_corrector.enabled=True# Enabling keyboard layout correction# Search for the word 'Уштыеушт' gives documents containing the word 'Einstein'result=index.search("Уштыеушт",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)