Azure Search Index - Search For Exact Word - azure

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

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.

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://learn.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

Related

Azure Search orders results based on the position of the matched text

I would like to sort the documents based on the position of the matching text and then alphabetically.
E.g I have follow 3 values.
PATRICK STREET WEST
MOUNT ST PATRICK ROAD
PATTI MCCULLOCH WAY
I am search with Pat* and I want the results should be sort by the position of the matching text and then alphabetically.
E.g Required result
PATRICK STREET WEST
PATTI MCCULLOCH WAY
MOUNT ST PATRICK ROAD
but I am getting the result in the below order.
PATRICK STREET WEST
MOUNT ST PATRICK ROAD
PATTI MCCULLOCH WAY
This is a bit of a tricky requirement. Let's break this down into the two distinct asks:
Sort results based on the position of the text - there's no query syntax that would allow you to do this but there are some ways to get at this requirement. One option to allow you to boost documents that start with Pat would be to create a second field with the same text that uses a custom analyzer with a keyword_v2 tokenizer and lowercase token filter. That new field would only match if the string of text started with the letters Pat. You could then use scoring profiles or term boosting to weight matches in that field more to bring those results that matched at the beginning to the top.
Sort alphabetically - I'd recommend sorting by search score and then by the text like this: $orderby=search.score() desc,TextField desc. If you follow my recommendations from #1, items where they matched in the beginning of the string should have higher scores than other items and then can be sorted alphabetically within that set. Then all items where the match wasn't in the beginning will come after and will also be sorted alphabetically.
That should at least get you fairly close to the requirement! You could always do a bit of extra sorting on the client side if needed too.

Azure Search: Prioritize closest exact match over others in a prefix search

I'm currently doing a prefix search with Azure Cognitive Search like so:
docs?api-version=2019-05-06&search=Do*
Suppose that my index contains Dog, Big Dog, and Small Dog. The result set seems to be sorted alphabetically by default and looks like:
Big Dog
Dog
Small Dog
How can I change my query string so that the closest exact match appears first and the rest is sorted alphabetically? Here's the output I want:
Dog
Big Dog
Small Dog
So, if the user types D, Do, or Dog, I want to show Dog first to help them short-circuit typing.
The results are ordered according to a score. This, is the result of TFxIDF formula. In other words, the results are displayed according to which term is more relevant according to your documents.
Saying that, I believe you must use NGram in order to get the most relevant term.
more info:
https://azure.microsoft.com/en-us/blog/custom-analyzers-in-azure-search/
Can you share what your exact document looks like? As Thiago mentioned Azure Cognitive Search returns a relevance score which shows the relative relevance of the entire document corresponding to the input query.
If your documents have only 1 matching field with the exact text you shared, it should return "Dog" with the highest score as it's more relevant to the query.

How to form a Solr edismax query with mutiple fields and different minimum match and boosts for different fields?

I've a Solr index with all documents having three fields - name, address and other_addresses. I want to search for a person having name say 'Tom Cruise' and Address '3rd Avenue 23rd Floor New York, NY 10016'.
Now I want to search name in only name field having its some specific boost value and minimum match value as well. Also, address need to be searched in both address and other_addresses, with different mm and boost values.
Can someone help me in writing edismax query on any other way around for Solr?
I'm doing something like :
select?debugQuery=on&defType=edismax&fl=*%20score&mm=70%25&q=name%3A(Rita%20Suman%20Shinde%20Near)%20address%3A(Gunjan%20Talkies%20Yerwada%20Pune)%20other_addresses%3A(Gunjan%20Talkies%20Yerwada%20Pune)&qf=name%20other_addresses%20address&stopwords=true
but not able to figure how to give different mm values.
You can use LocalParams to compose several dismax queries into one, and each of those subqueries can have its own dismax parameters. For example:
q={!dismax qf=name mm=2 v=$q1}^2.0 {!dismax qf=address1 mm=4 v=$q2}^1.5 {!dismax qf=other_address mm=4 v=$q2}^1.0
q1=Tom Cruise
q2=3rd Avenue 23rd Floor New York, NY 10016

Azure Search- Is there way to get exact match of words?

In Azure Search , Is there a way we can get exact match result of multiple words?
If i Search for word "Coca Cola Millenials". Can i get the result from results of azure matching the word "Coca Cola Millenials"
Are you asking if you can search for the phrase "Coca Cola Millenials"? Yes, you can. Surround the phrase with quotes as you did in this question.
From our documentation:
The phrase operator encloses a phrase in quotation marks. For example,
while Roach Motel (without quotes) would search for documents
containing Roach and/or Motel anywhere in any order, "Roach Motel"
(with quotes) will only match documents that contains that whole
phrase together and in that order (text analysis still applies).
Hope that helps

Search for exact term in an Algolia index

I want to filter an index by an exact value of an attribute. I wonder what possibilities Algolia offers for that.
Querying an index always results in a search for substrings, that means a search term abc will always match any object which attribute values contain abc. What I want to achieve is a search for abc that finds only abc as a value of an attribute (in this case I have specific attributes to search in).
One possibility I came up with was tagging, which doesn't seem to be the best way to think of.
Edit
I think I could also use facet filters. I thought about the different pros and cons and can't come up with arguments that places either one position above the other.
You're right with your edit that facet filters would be the way to go on this one. You'll get the exact match you're looking for and won't have to create a new attribute of _tags to use the tag filter.

Resources