0

We are using Azure Search to find courses from a list. We search on three fields. We need fuzzy searches on the Coursename and Keywords, but want only to include exact matches for the course code (which has sequential numeric codes like "RB046").

Using the Search Explorer, you can do something like this with the URL:

https://xxx.search.windows.net/indexes/prospectussearchindexlive/docs?api-version=2016-09-01&search=CourseCode:"HCN_6_006" OR Coursename:"HCN_6_006~1" OR Keywords:"HCN_6_006~1"

But in the API it seems you can only have one search term applied to all specified columns. Does anyone know of a way you can do this with the API without performing two searches?

David Makogon
  • 69,407
  • 21
  • 141
  • 189
  • If these columns are filterable, then you can write an odata filter. – Gaurav Mantri Mar 31 '18 at 13:08
  • @Electromorph There should be no difference in behavior between Search Explorer and the REST API, because Search Explorer uses the REST API. Can you please edit your question to show how you're calling the Search API? – Bruce Johnston Apr 01 '18 at 18:36
  • @Electromorph: Just curious, what was the reason you added quotes around the search terms? You don't really have to do that... Also, perhaps you should've used queryType = full in the url parameters (and even searchMode = all) – Arvind - MSFT Apr 02 '18 at 17:37

1 Answers1

1

So as pointed out in the comments by Bruce Johnston, largely the feature set (especially with respect to search query syntax) should be identical between the REST API and the Azure search .Net SDK. The search explorer on the Azure portal, is literally a call into the REST API, so there shouldn't be any differences there.

The following search API call might translate to what you are looking for (I have included the POST version, you should be able to use GET as well if you'd like).

POST /indexes/prospectussearchindexlive/docs/search?api-version=2016-09-01  
{  
  "search": "CourseCode:HCN_6_006 OR Coursename:HCN_6_006~1 OR Keywords:HCN_6_006~1",  
  "queryType": "full",  
  "searchMode": "all"  
}  

You should take a look at the Lucene syntax for Azure search, which is here: https://learn.microsoft.com/en-us/rest/api/searchservice/lucene-query-syntax-in-azure-search that will help you write different search queries.

You can also refer to the SDK documentation here: https://learn.microsoft.com/en-us/azure/search/search-howto-dotnet-sdk which talks about how to use the .NET SDK to perform search queries. Look at the Documents.Search method for more details.

Arvind - MSFT
  • 561
  • 2
  • 6