最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin2浏览0评论

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.

发布评论

评论列表(0)

  1. 暂无评论