question

MarcSelmanEasyAds-9779 avatar image
0 Votes"
MarcSelmanEasyAds-9779 asked SnehaAgrawal-MSFT answered

Is my search query possible?

I have a document model that represents product data that looks something like this:

ProductId
UserId
Title/Value
Title/ChannelId
Brand/Value
Brand/ChannelId

A product can have a title and a brand.
The title and brand can differ for every channel the product would be listed on.
The default title and brand is if the ChannelId is NULL , that would always be there.
Optionally there could be a different title or brand with a valid ChannelId value.

What I want is to query the index with a string that would match either a brand or a title.
When I pass no ChannelId as a filter it should match only if ChannelId is NULL.
But when I do pass a ChannelId it should find documents where there's a match on title or brand with that specific ChannelId OR the document does not contain a specific value for that ChannelId and then it should match the default value with ChannelId NULL.

I found out I could do something like:

Title/any(title: title/ChannelId eq 14 and title/Value eq 'my query') or not Title/any(title: title/ChannelId eq 14) and Title/any(title: title/ChannelId eq null and title/Value eq 'my query')

But that would search for an exact match. I would like to use search.ismatch but that cannot be used inside a lamda query.

Maybe I am missing something and I am making it too complex...

Is this possible in any way?

I am currently working with a new index so if I should change the whole model and the fields that's not a problem.

azure-cognitive-search
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Just checking in to see if you have chance to see below response. Let us know if you have any further query or issue remains.

0 Votes 0 ·

1 Answer

SnehaAgrawal-MSFT avatar image
0 Votes"
SnehaAgrawal-MSFT answered

Thanks for asking question! Azure Cognitive Search implements two Lucene-based query languages: Simple Query Parser and the Lucene Query Parser. Check Filter Functions: Filter expressions can include "search.ismatch" and "search.ismatchscoring" functions, allowing you to build a search query within the filter.

You may want to refer to this document link might helps: https://docs.microsoft.com/en-us/azure/search/search-query-odata-full-text-search-functions.

Let us know if issue remains.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.