Hi,
I'm struggling on how to best query my data when I have different types
within the same index. Let me explain.
I have an index (poc) where I define several types representing different
task types (taskA, taskB, etc.). All the task types share some common
fields, like the "taskId", but then each individual task type may have its
own specific fields:
taskA --> milestone
taskB --> legalstatus
Therefore, I want to provide my users with a search form where any
combination of criteria can be entered, so for instance they can search
something like:
"Give me all the taskA with milestone = 5, and all the taskB with
legalstatus = 12"
As you can see from that query, I have to combine criteria based on
different types, so basically I'm following this strategy:
- Use a filtered query
- If there are any common fields in the user's query, then use them for
the "query" part; else use a "match_all" - For all the specific fields, use the "filter" part using an "or" array
for each and every criterion
So following our example, I would have:
Now my questions:
- Is this a valid way to perform such queries? Think about all sort of
different combinations in my data, with more task types (up to 7 different
ones), and heterogeneous fields in each one (plus the common fields for all
of them). - If it is, how does ES actually run this query? Does ES sequentially
scan each and every document in the index, and applies the filter on each,
or does something different? I'm worried here whether being a valid
approach, it's actually the optimal one.
Here I provide the full curl recreation with sample data for you evaluation:
Thanks!
--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.