0

I am using the latest Microsoft.Azure.Search SDK with the following search parameters. I have filter ID's that are MFR-1, MFR-2, MFR-3, etc. I am trying to bring back ANY record that has Filter ID that starts with MFR.

It seems that this should be simple query, but I am not finding a way to make this work with the SDK.

var Params = new SearchParameters()
{
    SearchMode = SearchMode.Any,
    QueryType = QueryType.Full,
    Top = 72,
    Skip = 0,
    IncludeTotalResultCount = true,
    Filter = "FilterIDs/any(c: c eq 'MFR-57')",
    OrderBy = new List<string> { "Sort", "Title"},
    Facets = new List<string>() { "Filters,count:500,sort:value" }
};

Data looks like this:

{
"id": "691",
"RecordType": "product",
"FilterIDs": [
    "MFR-106",
    "36-250",
    "36-265"
],
}

I've tried this, but it doesn't appear to work with arrays as the title would suggest.

Contains / in array in Azure Search (Preview)

Matty
  • 873
  • 8
  • 21

1 Answers1

0

Per my understanding , you are looking for a filter express that could filter all record whose FilterIDs string collection(array) contains item value started with "MFR" .

As official doc indicated :

Inside lambda expressions for string collections, the only comparison operators that can be used are eq and ne.

So I am afraid there is no way to do fuzzy search here.

But if your filter ids are enumerable , maybe you can use the filter express as below :

FilterIDs/any(c: c eq 'MFR-1') or FilterIDs/any(c: c eq 'MFR-2') or FilterIDs/any(c: c eq 'MFR-3') or ....

I think it would be a work around here, it works for me on my side . Hope it helps.

Stanley Gong
  • 11,522
  • 1
  • 8
  • 16
  • I would use this to shorten the code: `FilterIDs/any(c: search.in(c, 'MFR-57, MFR-94'))` although it would maybe make more sense to combine the fields into one string and then do a "like" type query. Thanks for the answer... I'll keep searching for a solution. We have 1000's of manufacturers. – Matty Oct 14 '19 at 20:38