0
votes

We are using Azure Search Index for one of our Search API. We have a field in Azure Search Index say Display Name (which is a string field. The requirement is from the API when we do a search using the Display Name, the search should be an exact search against the fields.

Eg: If we search for "George Joseph", the Search Index should return only records that exactly match the Display Name as "George Joseph" and it should not return records with names - "George Joseph John" or John George Joseph"

Is there any way I can accomplish this?

Regards,

John

2
Just thinking out loud, can you use filter instead of using search? So your search expression would be $filter=DisplaName%20eq%20'George Joseph'.Gaurav Mantri
Will it support collection of display names? like $filter=DisplayName%20eq%20'George Joseph'&DisplayName%20eq%20'George John'Silly John
Also, we need to have the same feature to be implemented for Person's Educational qualification which is a collection. That can have "Bachelor Desgree", "Master Degree" etc. Is that possible to do that in this case?Silly John
Why not? It's an ODATA filter query so you would construct it something like $filter=DisplayName%20eq%20'George Joseph'%20or%20DisplayName%20eq%20'George John'. Please see this link for more details: docs.microsoft.com/en-us/rest/api/searchservice/…. Only catch is that the fields on which you're filtering must have filterable attribute set.Gaurav Mantri
The other catch is that $filter is case-sensitive.Bruce Johnston

2 Answers

0
votes

You can use a filter to achieve this, assuming you are interested in case-sensitive matches. For example, DisplayName eq 'George Joseph' will match exactly George Joseph but will not match george JOSEPH. You can find details about the filter syntax here.

0
votes

You can specify "&searchMode=All"

When you set searchMode=all you tell the search engine that all query terms must be matched at least once in the document-

agency temps&$count=true&$top=30&$skip=0&searchMode=All&$filter=(CompanyCode eq '13453' and VNumber eq '00023232312016') &scoringProfile=BusinessProfile1&searchFields=VCategory

https://docs.microsoft.com/en-us/azure/search/query-lucene-syntax

The searchMode=all parameter is relevant in this example. Whenever operators are on the query, you should generally set searchMode=all to ensure that all of the criteria is matched.

GET /indexes/hotels/docs?search=category:budget AND "recently renovated"^3&searchMode=all&api-version=2020-06-30&querytype=full