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.