Hi there
I want to know what is the best filtering approach for my scenario. (Search API Filters)
Scenario:
Intro: I have arrays of values on the client side, and on the engine document schema one. I want documents to be returned only if there is an intersection between client side array and indexed document array.
Indexed document example:
{
id: "1",
name: "name 1",
author: "u1",
idx_groups_a1: ["ga1", "ga2", "ga3", ..., "gaX000th"],
idx_groups_b2: ["gb1", "gb2", "gb3", ..., "gbX000th"]
}
On the client side let's say I have:
a1_groups = ["ga50", "ga51"]
a2_groups = ["gb1000", "gb1001"]
I want to return then: documents that match if there is an :
- intersection between
a1_groups
andidx_groups_a1
OR - intersection between
a2_groups
andidx_groups_b2
.
I understand there are at least 2 possible ways of achieving, but I wanted to know which one is the preferred one in terms of performance, and in terms of limitations since a1_groups
and a2_groups
could have thousands of values.
Option A
This option is based of the requests that the App Search Generated Search UI performs:
"filters": {
"any": [
{
"any": [
{
"idx_groups_a1": "ga50"
},
{
"idx_groups_a1": "ga51"
}
]
},
{
"any": [
{
"idx_groups_b2": "gb1000"
},
{
"idx_groups_b2": "gb1001"
}
]
}
]
},
Option B
"filters": {
"any": [
{
"idx_groups_a1": [
"ga50",
"ga51"
]
},
{
"idx_groups_b2": [
"gb1000",
"gb1001"
]
}
]
}
Thanks in advance !