Cognitive search get only matching child item

Mert Ozdag 21 Reputation points
2021-11-02T18:59:17.657+00:00

Let's say I have a document like this:

[
  {
    "id": "0",
    "Heading1Name": "Other Non-Commercial Risks",
    "Items": [
      {
        "Heading2Name": "Some Heading2 Name text - mert",
        "Items": [
          {
            "ArticleId": "1.53",
            "ArticleText": "Some article text bla bla - clem"
          }
        ]
      },
      {
        "Heading2Name": "Another heading 2 text - ava",
        "Items": [
          {
            "ArticleId": "1.54",
            "ArticleText": "the Underwriting Authority may provide coverage against losses resulting."
          }
        ]
      }
    ]
  }
]

When I search "mert", I only want to get the following item/child

    {
            "Heading2Name": "Some Heading2 Name text - mert",
            "Items": [
              {
                "ArticleId": "1.53",
                "ArticleText": "Some article text bla bla - clem"
              }
            ]
}

because this is the item that contains "mert"

how should construct my rest api query?

Thank you

Azure AI Search
Azure AI Search
An Azure search service with built-in artificial intelligence capabilities that enrich information to help identify and explore relevant content at scale.
1,062 questions
0 comments No comments
{count} votes

Accepted answer
  1. ajkuma 26,636 Reputation points Microsoft Employee
    2021-11-04T05:54:06.49+00:00

    @Mert Ozdag ,

    Because the granularity of your index is at the parent level rather than the child level, current it is not possible pull only the child item (mert) from the list.
    Alternatively, you could change the granularity of your index. Another option could be to keep your existing schema and then do a second layer of filtering of the */child at the application layer, to have only required criteria to list in your application.

    Quoting the response from Derek Legenzoff (from our Azure Search PG).
    “We don't have any immediate plans to change the way this works that I'm aware of but we're always looking to improve the product based on feedback from customers like yourself so we appreciate you sharing the feedback with us.”

    Kindly check this thread for similar feedback request, response from our PG and workaround that you could leverage:

    [FEATURE REQ] Azure Search Working with Complex Collections]
    https://github.com/Azure/azure-sdk-for-net/issues/23569


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.