Facet_filter with multiple ranges

Hi,

I am trying to build a facet filter, that filters on ranges of different
fields.
At the bottom there is a short example of what I am trying to do. Of
course, it does not work because the range-keyword appears twice ...

Any hint on how to do this correctly?

Thanks, Sven.

          'facet_filter': {
            'and': [
              {
                'range': {
                  'severity': {
                    'from': 0,
                    'to': 2
                  }
                },
                'range': {
                  'time': {
                    'from': from,
                    'to': now
                  }
                }
              }
            ]
          }

--
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.

On Fri, 2013-02-01 at 04:03 -0800, Sven Reissmann wrote:

Hi,

I am trying to build a facet filter, that filters on ranges of
different fields.
At the bottom there is a short example of what I am trying to do. Of
course, it does not work because the range-keyword appears twice ...

You're nesting incorrectly. Instead of:

and: [
  { range: {...}, range:{...}}
]

do:

and: [
  { range: {...}},
  { range: {...}}
]

clint

Any hint on how to do this correctly?

Thanks, Sven.

          'facet_filter': {
            'and': [
              {
                'range': {
                  'severity': {
                    'from': 0,
                    'to': 2
                  }
                },
                'range': {
                  'time': {
                    'from': from,
                    'to': now
                  }
                }
              }
            ]
          }

--
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.

--
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.

Oha. It's that easy :slight_smile:
Thank you very much Clinton.

On Friday, February 1, 2013 1:48:38 PM UTC+1, Clinton Gormley wrote:

On Fri, 2013-02-01 at 04:03 -0800, Sven Reissmann wrote:

Hi,

I am trying to build a facet filter, that filters on ranges of
different fields.
At the bottom there is a short example of what I am trying to do. Of
course, it does not work because the range-keyword appears twice ...

You're nesting incorrectly. Instead of:

and: [ 
  { range: {...}, range:{...}} 
] 

do:

and: [ 
  { range: {...}}, 
  { range: {...}} 
] 

clint

Any hint on how to do this correctly?

Thanks, Sven.

          'facet_filter': { 
            'and': [ 
              { 
                'range': { 
                  'severity': { 
                    'from': 0, 
                    'to': 2 
                  } 
                }, 
                'range': { 
                  'time': { 
                    'from': from, 
                    'to': now 
                  } 
                } 
              } 
            ] 
          } 

--
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 elasticsearc...@googlegroups.com <javascript:>.
For more options, visit https://groups.google.com/groups/opt_out.

--
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.

Hey,

I have the ~same problem, that's my code i don't know where is my error ...

{ 'query': {'match_all': {}},

'facets': {
'visite': {
'terms': {'field': 'is_newuser', 'size': '21'},
'facet_filter': {
'and': [
{'range': {'time': {'from' : 1396303200 ,'to' : 1398895200 }}},
{'range': {'time': {'from' : 1398895201 ,'to' : 1401573600 }}}
]
}

			  }
  }

}

Thx for reading me