I want to perform an Azure search on a location index (comprising of 100K records of countryCode and location information)
The need is to
a) limit the search to specified country codes
b) be able to handle fuzzy search
I am able to achieve filtered search in simple query syntax using odata syntax on
$filter=(countrycode eq 'IN' or countrycode eq 'AT' or countrycode eq 'AU')
https://learn.microsoft.com/en-us/rest/api/searchservice/odata-expression-syntax-for-azure-search
I am able to achieve fuzzy search using Lucene search by
queryType=full&search=euroe~1
as per this syntax
queryType=full&search=sydne~1&$filter=CountryCode eq 'AT' or CountryCode eq 'AU' &searchMode=All
Is there a way to use a contains instead of multiple eq. The syntax seems to be limited
There is no syntax for set containment in Azure Search. If this feature is important to you, please add an item to User Voice to help the Azure Search team prioritize.
Late answer, but what about search.in?
Your request could be:
queryType=full&search=sydne~1&$filter=search.in(CountryCode, 'AT, AU')&searchMode=All
You can find more info on OData expression syntax for Azure Search
Related
If I may have missed this in some other area of SO please redirect me but I don't think this is a duped question.
I am using Azure Search with an index field called Title which is searchable and filterable using a Standard Lucerne Analyzer.
When using the built-in explorer, if I want to return all Job Titles that are explicitly named Full Stack Developer I can achieve it this way:
$filter=Title eq 'Full Stack Developer'&$count=true
But if I want to retrieve all the Job Titles using a wildcard to return all records having Full Stack in the name this way:
$filter=Title eq 'Full Stack*'&$count=true
The first 20 or so records returned are spot on, but after that point I get a mix of records that have absolutely nothing in common with the Title I specified in the query. My initial assumption was that perhaps Azure was including my specified Title performing an inclusive keyword search on the text as well.
Though I found a few instances where that hypothesis seemed to prove out, so many more of the records returned invalidated that altogether.
Maybe I don't understand fully the mechanics under the hood of Azure Search and so though my query appears to be valid; my expectation of the result is way off.
So how should my query look to perform a wildcard resulting to guarantee the words specified in the search to be included in the Titles returned, if this should be possible? And what would be the correct syntax to condition the return to accommodate for OR operators to be inclusive?
Azure Cognitive Search allows you to perform wildcard searches limited to specific fields only. To do so, you will need to specify the name of the fields in which you want to perform the search in searchFields parameter.
Your search URL in this case would be something like:
https://accountname.search.windows.net/indexes/indexname/docs?api-version=2020-06-30&searchFields=Title&search=Full Stack*
From the link here:
Does anyone know how to ensure we can return normal result as well as accented result set via the azure search filter. For e.g the below filter query in Azure search returns a name called unicorn when i check for record with name unicorn.
var result= searchServiceClient.Documents.SearchAsync<myDto>("*",new SearchParameters
{
SearchFields = new List<string> {"Name"},
Filter = "Name eq 'unicorn'"
});
This is all good but what i want is i want to write a filter such that it returns record named unicorn as well as record named únicorn (please note the first accented character) provided that both record exist.
This can be achieved when searching for such name via the search query using language or Standard ASCII folding search analyzer as mentioned in this link. What i am struggling to find out is how can we implement the same with azure filters?
Please let me know if anyone has got any solutions around this.
Filters are applied on the non-analyzed representation of the data, so I don’t think there’s any way to do any type of linguistic analysis on filters. One way to work around this is to manually create a field which only do lowercasing + asciifloding (no tokenization) and then search lucene queries that look like this:
"normal search query terms" AND customFilterColumn:"filtérValuèWithÄccents"
Basically the document would both need to match the search terms in any field AND also match the filter term in the “customFilterColumn”. This may not be sufficient for your needs, but at least you understand the art of the possible.
Using filters it won't work unless you specify in advance all the possibilities:
for example:
$filter=name eq 'unicorn' or name eq 'únicorn'
You'd better work with a different analyzer that will change accents to it's root form. As another possibility, you can try fuzzy search:
search=unicorn~&highlight=Name
How to do case-insensitive search in azure search?
My index contains Etc. if I search with ETC using fuzzy search i cant get result back. I think its for case sensitivity. How to do case-insensitive search?
If you use an equivalent of $filter=city eq 'amsterdam' it will not match "Amsterdam" since filtering is case-sensitive. In this case you could use $filter=search.ismatch('amsterdam', 'city'). But then your city field must be defined als searchable and not simply filterable.
Based on the latest comment in this thread, it is not supported by Azure Search so far.
You could vote up that for prioritize.
I have an index with nutritional information. A search for burger does not match hamburger or burgers.
What is the most appropriate & efficient way to be able to search for these with Azure Search? I can use wildcards to match burgers (i.e. burger*) but Azure Search does not support wildcards at the start of the query, so I can't figure out how to match hamburger.
You can achieve this by using Lucene query syntax (see link below) in azure search.
Construct your query by using querytype full (which enables Lucene query syntax) with your term as a search. As an example, to find all matches containing the word burger, construct your query like this (try it in the azure search, search explorer query window:
queryType=full&search=/.*burger.*/
Microsoft docs for Lucene query syntax
We're migrating a custom site to Magento Community, and are discovering that the default search isn't that great.
Eg searching for "shirts" will not find a product called shirt.
I'm using Like, and would prefer to keep doing so.
Yes we could monitor internal searches and create synonyms for them, but we would prefer to be proactive.
The old site had a specific field for search keywords, which they would prefer to keep using.
Is there a way of either:
a. including an attribute by default in all searches? we would define a new attribute for all products
b. or using the existing meta keywords tag as a list of keywords we would like the internal search to use?
You can change weather or not an attribute is used for searches in the admin.
catalog -> attributes -> edit
then you can enable the attribute to be used in searches.
Try to change the Search Type from like to fulltext
Configuration -> Catalog -> Catalog Search.