filter - Azure Cognitive Search: search.ismatch on Nested Field FieldFacet Not Working - Stack Overflow

I'm trying to use Azure Cognitive Search's search.ismatch function to filter results based on

I'm trying to use Azure Cognitive Search's search.ismatch function to filter results based on a substring match within a nested field called FieldFacet, which is inside a collection field Fields. However, my queries are not working as expected.

Here's my document structure (simplified):

{
  "Fields": [
    {
      "FieldName": "Category",
      "FieldFacet": "Category |#| Vehicle",
      "FieldValue": "Vehicle"
    },
    {
      "FieldName": "OtherField",
      "FieldFacet": "OtherField |#| SomeValue",
      "FieldValue": "SomeValue"
    }
    // ... more Fields objects
  ]
}

I've tried the following queries:

search.ismatch('value', 'Fields/FieldFacet') Fields/any(s: search.ismatch('value', 'FieldFacet', 'simple', 'any')) I expect these queries to return documents where the FieldFacet field contains the substring "value" (case-insensitive). However, I'm getting either no results or an error.

My Questions:

What is the correct syntax for using search.ismatch on a nested field like Fields/FieldFacet? Is it possible to use search.ismatch within an any or all collection filter? Are there any alternative approaches to achieve substring matching on this nested field?

I'm trying to use Azure Cognitive Search's search.ismatch function to filter results based on a substring match within a nested field called FieldFacet, which is inside a collection field Fields. However, my queries are not working as expected.

Here's my document structure (simplified):

{
  "Fields": [
    {
      "FieldName": "Category",
      "FieldFacet": "Category |#| Vehicle",
      "FieldValue": "Vehicle"
    },
    {
      "FieldName": "OtherField",
      "FieldFacet": "OtherField |#| SomeValue",
      "FieldValue": "SomeValue"
    }
    // ... more Fields objects
  ]
}

I've tried the following queries:

search.ismatch('value', 'Fields/FieldFacet') Fields/any(s: search.ismatch('value', 'FieldFacet', 'simple', 'any')) I expect these queries to return documents where the FieldFacet field contains the substring "value" (case-insensitive). However, I'm getting either no results or an error.

My Questions:

What is the correct syntax for using search.ismatch on a nested field like Fields/FieldFacet? Is it possible to use search.ismatch within an any or all collection filter? Are there any alternative approaches to achieve substring matching on this nested field?

Share asked Mar 14 at 14:00 NISARGA TMNISARGA TM 11 bronze badge 1
  • try using Fields/any(f: search.ismatch('value', f/FieldFacet, 'simple')) – JayashankarGS Commented Mar 19 at 9:08
Add a comment  | 

1 Answer 1

Reset to default 0

You can use below kind of expression.

{
"search": "*",
"filter":"search.ismatch("Value",'Rooms/Type')"
}

Without filter

With filter

You can see the total count is 50 and filtered one is 47.

There are some cases where you may still get the results which you are not expecting, that is because the values are still mapped to the records which matching your text under collections.

Example: Let's say we have below records in index

[   
{
    Name:"xyz1",
    Rooms:[
        {
            id:1,
            Type: "Deluxe room"
        }
        ]
},
{
    Name:"xyz2",
    Rooms:[
        {
            id:1,
            Type: "Standard room"
        }
        ]
},
{
    Name:"xyz3",
    Rooms:[
        {
            id:1,
            Type: "Deluxe room"
        },
        {
            id:2,
            Type: "Standard room"
        }
        ]
}
]

Here when you do filter on Type with value Deluxe, you would expect the output will be only first record but you get the results 1st and 3rd, because the value is having a match in 3rd record id 1.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744652537a4585986.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信