1

I need to remove the element of an array of struct type.My json is given below.So what would be my query if I want search results where userID is "abcd" and I should get the elements of an array "data" where dd is equal to 1.I mean I should not get that element in which dd is equal to 0 in an array.

{
  "fields": {
    "userId":"abcd",
        "data": [
             {
                "aa": "Text 1",
                "bb": 15,
                "cc": 100000000000,
                "dd": 1
            },
            {
                "aa": "Text 2",
                "bb": 15,
                "cc": 100000000000,
                "dd": 1
            },
            {
                "aa": "Text 3",
                "bb": 15,
                "cc": 100000000000,
                "dd": 1
            },
            {
                "aa": "Text 4",
                "bb": 15,
                "cc": 100000000000,
                "dd": 0
            }
        ]
    }
}

Please help!!

Mohammad Sunny
  • 371
  • 1
  • 3
  • 15

1 Answers1

1

You cannot modify the document itself by a search.

To search a array of structyou should use sameElement. Plenty of examples using sameElement here https://docs.vespa.ai/documentation/query-language.html

Jo Kristian Bergum
  • 2,984
  • 5
  • 8