Store multiple ranges (of integer values) in the same field

I am interested with the best way of storing multiple ranges in the same field (or any other better way for storing multiple ranges).

for example,
I have an object type A, that should hold the following data:


  • name
  • RangesFieldA: [1-2, 5, 7, 22-29]
  • RangedFieldB: [2, 4-6].

then, I would like to query the objects of type A, by asking - give me all the objects of type A that range (x-y) contained in 'RangesFieldA' field.

now, I saw that there exist a range type, but I couldn't find if it's support multiple ranges?

I am currently using ES 5.6, and in the near future, we are upgrading to 6+ if it matters..

I am also interested to know, if your answer changes if A is a nested object inside another document..


Yes, this is possible (at least in 6.x but I believe that is as well possible in your version), you just need to send your ranges as an array, for example:

PUT range_index
  "mappings": {
    "_doc": {
      "properties": {
        "int_range": {
          "type": "integer_range"

PUT range_index/_doc/1
  "int_range" : [{ 
    "gte" : 10,
    "lte" : 20
    "gte" : 30,
    "lte" : 40
1 Like

And it should apply to nested field as well.

1 Like

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