Multiple facets in a single request


(Pat Christopher-2) #1

Hola,
I'm attempting to issue several facet requests in a single query. I
thought I could do something like so:

{
"query": {
"query_string": {
"query": "things"
}
},
"facets": [
{
"time1": {
"terms": {
"field": "a thang"
},
"facet_filter": {
"numeric_range": {
"event_timestamp": {
"gte": 1339188071000,
"lte": 1339188076000
}
}
}
}
},
{
"time2": {
"terms": {
"field": "a thing"
},
"facet_filter": {
"numeric_range": {
"event_timestamp": {
"gte": 1339188071000,
"lte": 1339188076000
}
}
}
}
}
]
}

I thought that 'facets' could operate over a list of named facet requests.
But when I do that I receive the following error:

Parse Failure [No facet type found for [time1]]

So it seems that elasticsearch is reading the name of the facet as the
type. I'm running 0.18.5. If this is a fixed/known issue, my bad. But,
is that the correct syntax? I was unable to find any examples in the docs
or on the newsgroup.

Thanks,
Pat


(David Pilato) #2

I think that "A thing" can not be the name of a field.

David :wink:
Twitter : @dadoonet / @elasticsearchfr

Le 13 juin 2012 à 23:52, Pat Christopher coffeepac@gmail.com a écrit :

Hola,
I'm attempting to issue several facet requests in a single query. I thought I could do something like so:

{
"query": {
"query_string": {
"query": "things"
}
},
"facets": [
{
"time1": {
"terms": {
"field": "a thang"
},
"facet_filter": {
"numeric_range": {
"event_timestamp": {
"gte": 1339188071000,
"lte": 1339188076000
}
}
}
}
},
{
"time2": {
"terms": {
"field": "a thing"
},
"facet_filter": {
"numeric_range": {
"event_timestamp": {
"gte": 1339188071000,
"lte": 1339188076000
}
}
}
}
}
]
}

I thought that 'facets' could operate over a list of named facet requests. But when I do that I receive the following error:

Parse Failure [No facet type found for [time1]]

So it seems that elasticsearch is reading the name of the facet as the type. I'm running 0.18.5. If this is a fixed/known issue, my bad. But, is that the correct syntax? I was unable to find any examples in the docs or on the newsgroup.

Thanks,
Pat


(Pierre Durand) #3

This is the correct syntax for facets:

"facets": {
"level": {
"terms": {
"field": "level"
}
},
"color": {
"nested": "balls",
"terms": {
"field": "color"
}
},
"size": {
"nested": "balls",
"terms": {
"field": "size"
}
}
}

On Wednesday, June 13, 2012 11:52:06 PM UTC+2, Pat Christopher wrote:

Hola,
I'm attempting to issue several facet requests in a single query. I
thought I could do something like so:

{
"query": {
"query_string": {
"query": "things"
}
},
"facets": [
{
"time1": {
"terms": {
"field": "a thang"
},
"facet_filter": {
"numeric_range": {
"event_timestamp": {
"gte": 1339188071000,
"lte": 1339188076000
}
}
}
}
},
{
"time2": {
"terms": {
"field": "a thing"
},
"facet_filter": {
"numeric_range": {
"event_timestamp": {
"gte": 1339188071000,
"lte": 1339188076000
}
}
}
}
}
]
}

I thought that 'facets' could operate over a list of named facet requests.
But when I do that I receive the following error:

Parse Failure [No facet type found for [time1]]

So it seems that elasticsearch is reading the name of the facet as the
type. I'm running 0.18.5. If this is a fixed/known issue, my bad. But,
is that the correct syntax? I was unable to find any examples in the docs
or on the newsgroup.

Thanks,
Pat


(Pat Christopher-2) #4

And it is! Thanks Pierre!

On Thursday, June 14, 2012 2:54:23 AM UTC-7, Pierre Durand wrote:

This is the correct syntax for facets:

"facets": {
"level": {
"terms": {
"field": "level"
}
},
"color": {
"nested": "balls",
"terms": {
"field": "color"
}
},
"size": {
"nested": "balls",
"terms": {
"field": "size"
}
}
}

On Wednesday, June 13, 2012 11:52:06 PM UTC+2, Pat Christopher wrote:

Hola,
I'm attempting to issue several facet requests in a single query. I
thought I could do something like so:

{
"query": {
"query_string": {
"query": "things"
}
},
"facets": [
{
"time1": {
"terms": {
"field": "a thang"
},
"facet_filter": {
"numeric_range": {
"event_timestamp": {
"gte": 1339188071000,
"lte": 1339188076000
}
}
}
}
},
{
"time2": {
"terms": {
"field": "a thing"
},
"facet_filter": {
"numeric_range": {
"event_timestamp": {
"gte": 1339188071000,
"lte": 1339188076000
}
}
}
}
}
]
}

I thought that 'facets' could operate over a list of named facet
requests. But when I do that I receive the following error:

Parse Failure [No facet type found for [time1]]

So it seems that elasticsearch is reading the name of the facet as the
type. I'm running 0.18.5. If this is a fixed/known issue, my bad. But,
is that the correct syntax? I was unable to find any examples in the docs
or on the newsgroup.

Thanks,
Pat


(system) #5