
Results = searchClient.Search("\"five star\"", searchOptions) Ĭonsole.WriteLine("Search the entire index for the term 'internet':\n") Console.WriteLine("Search the entire index for the phrase \"five star\":\n") Phrase queries, such as "five star", must be enclosed in quotation marks, and might also need escape characters depending on your client. In RunQueriesWithNonExistentTermsInIndex, issue search queries with "five star", "internet", and "economy AND hotel". Thread.Sleep(10000) // Wait for the changes to propagateĬonsole.WriteLine("Complete. RunQueriesWithNonExistentTermsInIndex(searchClientForQueries) Ĭonsole.WriteLine("Adding synonyms.\n") Ĭonsole.WriteLine("Enabling synonyms in the test index.\n") ĮnableSynonymsInHotelsIndexSafely(indexClient) SearchClient searchClientForQueries = CreateSearchClientForQueries() SearchClient searchClient = indexClient.GetSearchClient("hotels") Ĭonsole.WriteLine("Uploading documents.\n") SearchIndexClient indexClient = CreateSearchIndexClient() Ĭonsole.WriteLine("Cleaning up resources.\n") Ĭonsole.WriteLine("Creating index.\n")

The code below demonstrates the overall flow.

Second, the code enables the synonyms feature, then re-issues the same queries, this time returning results based on matches in the synonym map. First, the application executes search queries using terms and phrases that do not appear in the index. In this example, a sample application executes queries and returns results on a sample "hotels" index populated with two documents. Overviewīefore-and-after queries are used to demonstrate the value of synonyms. You can find the full source code of the sample application used in this example on GitHub.
ANOTHER WORD FOR ADD ON HOW TO
NET client library, see How to use Azure Cognitive Search in. Tutorial requirements include the following: Synonyms can be created programmatically, but not in the portal.
