How to design ES fields for nested logical query

I want to query ES to find docs meeting this pattern: A & (B | C) & (D | E). And A is the value of a field, both B and C are the values of the other field, and D and E are the values of another field.

Here is a concrete example:
Gender: male, Birth Place: US, UK or JP, and Birth Day Range: 1990-1995, or 1996-2000

So a user profile of which gender is male, birth place is US and birth day range is 1990-1999 can be returned.
And following user profiles will be ignored:

  • gender: female, birth place is US and birth day range is 1990-1999 (gender part does not meet the condition)
  • gender: male, birth place is CN and birth day range is 1990-1999 (birth place part is not one of US, UK or JP )
  • gender: male, birth place is US and birth day range is 1980-1985 (birth day part is not one of 1990-1995 or 1996-2000)

what data type should I use? note that the number of these kinds of fields can be changed. Maybe later Birth Day Range is not considered any more. Or a new field called Degree: BS, MS or PHD can be added.

Note that ES 7.* is used.

Thanks

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.