Home > Software design >  Vespa query filter - how to check whether a specific int is in a document's int array<int>
Vespa query filter - how to check whether a specific int is in a document's int array<int>

Time:12-14

What's the proper way to check whether an integer is inside an array field when filtering in a Vespa query?

Given the following field in a document:

field location_ids type array<int> {
    indexing: summary | attribute
}

I want to filter documents that contain a specific integer ID:

{'yql': 'SELECT * FROM doc WHERE userQuery() AND <int X in location_ids>',
'query': 'some query text'
}

I'm not sure how to do this with an int array, as the docs and project examples dealt mainly with string arrays.

Any help appreciated!

CodePudding user response:

For a single value X

{'yql': 'SELECT * FROM doc WHERE userQuery() AND location_ids=X',
'query': 'some query text'
}

Will match if X is in the array.

CodePudding user response:

Searching numeric values (equals, range etc.) is documented at https://docs.vespa.ai/en/reference/query-language-reference.html#numeric

  • Related