Devender S
Devender S

Reputation: 33

Azure Cognitive Search filter fields having mixed datatype

I have created a field (named as 'value') in my Azure Cognitive Search Index which may have values of different data types (for example, string, string array, object array). While creating the Index, I have configured type for this value field as "Edm.String" and due to which data in my Index is stored as:

  1. For string fields: "value": "value1"
  2. For string arrays: "value": "["value1","value2"]"
  3. For object arrays: "value": "[ {"key1":"value1"},{"key2":"value2"}]" Basically, my complex fields are getting stored in form of strings as I have defined these as "Edm.String". Hence, filters are not working properly in this. For example: If I try to filter data where "key1":"value1" (in point 3), the data is not getting matched as the actual value is "[ {"key1":"value1"},{"key2":"value2"}]".

Can anyone please guide on how to proceed in this case?

Note: I cannot make the value field of type "Collection(Edm.ComplexType)" because of the values are in string format and Indexer fails in this case. Also, I cannot modify the way database is structured.

Upvotes: 0

Views: 265

Answers (1)

Sairam Tadepalli
Sairam Tadepalli

Reputation: 1683

We have a method called search.in where we can apply filter on the collection created using Edm.String. We have different other methods mentioned like here, which speaks about the $filter and other operations using Edm.String.

We have the choice of using the below syntax for filtering

keyphrases/any(t: search.in(t, 'database'))

Upvotes: 0

Related Questions