Some indices have data that has a one to many relationship that you need to filter in a way that array filtering won't work for.
If your logical structure requires that the location in the array is meaningful and doesn't just match any value anywhere in the array, you can't just use an array. A structure like
{
"car":{
"year":2000,
"make":"Ford"
},
{
"year":2002,
"make":"Lexus"
}
}
is the same as a two array structure of year and make:
{
"car":{
"year":[2000,2002],
"make":[
"Ford","Lexus"]
}
}
Filtering on this is equivalent to filtering with "AND"s on two separate arrays, and it won't incorporate the position in the array.
In another example, a specific object may have many start and end dates associated with it. Or, a specific machine part may be applicable to many different machines.
In a case like that you have two main data structures that you can use, but both have pros and cons.
For some item A with a relationship with main_item_a and main_item_b, have a record for each
item that it has a relationship with. The con here is that this may be a lot of items.
{
"id":"my_id_a",
"belongs_to":"main_item_a",
"objectId":"uniqueA"
}
{
"id":"my_id_a",
"belongs_to":"main_item_b"
"objectId":"uniqueB"
}
The second way that you can create a record is like this:
{
"id":"my_id_a",
"belongs_to_one":"main_item_A",
"belongs_to_two":"main_item_B",
"objectId":"uniqueB"
}
The problem here is that you can't as easily add more items to the structure and your filters may be more complex (i.e belongs_to_one = main_item_A OR belongs_to_two = main_item_B, etc).
There isn't a one size fits all solution for this currently.
You can also review this article on the issue.