Remove an element from struct type array using search query in vespa

138 Views Asked by At

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!!

1

There are 1 best solutions below

0
On

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