Facets don't appear with query filtered

When I try to use facets with my filtered search I don't get facets.
Remove the "filtered" element and it works.

Without filtered:
curl -X GET "http://localhost:9200/products/product/_search?
pretty=true" -d '{
"query": {
"bool": {
"must": [{
"query_string": {
"query": "*",
"default_operator": "AND"
}
}]
}
},
"facets": {
"tags": {
"terms": {
"field": "tag_names",
"size": 10,
"all_terms": false
}
}
}
}'

This returns my facets as expected:

{
"took" : 3,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 2,
"max_score" : 1.0,
"hits" : [ {
"_index" : "encore_dev_product",
"_type" : "product",
"_id" : "1",
"_score" : 1.0, "_source" : {"client_id":
1,"description":"","name":"Green Day concert
tickets","location_coordinates":["32.716254,-117.160118"],"tag_names":
["concert","entertainment"]}
}, {
"_index" : "encore_dev_product",
"_type" : "product",
"_id" : "2",
"_score" : 1.0, "_source" : {"client_id":
1,"description":null,"name":"Gift certificate","location_coordinates":
["32.716254,-117.160118","33.8095868,-117.9229975"],"tag_names":
["food","restaurant"]}
} ]
},
"facets" : {
"tags" : {
"_type" : "terms",
"missing" : 0,
"total" : 4,
"other" : 0,
"terms" : [ {
"term" : "restaurant",
"count" : 1
}, {
"term" : "food",
"count" : 1
}, {
"term" : "entertainment",
"count" : 1
}, {
"term" : "concert",
"count" : 1
} ]
}
}

With filtered:

curl -X GET "http://localhost:9200/products/product/_search?
pretty=true" -d '{
"query": {
"bool": {
"must": [{
"query_string": {
"query": "*",
"default_operator": "AND"
}
}]
},
"filtered": {
"filter": [{
"geo_distance": {
"location_coordinates": "33.6147846,-117.637617",
"distance": "90mi"
}
}]
}
},
"facets": {
"tags": {
"terms": {
"field": "tag_names",
"size": 10,
"all_terms": false
}
}
}
}'

Returns no facets...

{
"took" : 2,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 2,
"max_score" : 1.0,
"hits" : [ {
"_index" : "products",
"_type" : "product",
"_id" : "1",
"_score" : 1.0, "_source" : {"client_id":
1,"description":"","name":"Green Day concert
tickets","location_coordinates":["32.716254,-117.160118"],"tag_names":
["concert","entertainment"]}
}, {
"_index" : "products",
"_type" : "product",
"_id" : "2",
"_score" : 1.0, "_source" : {"client_id":
1,"description":null,"name":"Gift certificate","location_coordinates":
["32.716254,-117.160118","33.8095868,-117.9229975"],"tag_names":
["food","restaurant"]}
} ]
}

What am I doing wrong?

shouldn't your query go into filtered?

http://groups.google.com/group/elasticsearch/browse_thread/thread/655f9706efc7240e/90eb6b56c7898959?lnk=gst&q=facet+filter#90eb6b56c7898959

BTW: Also have a look into the filter element which does not apply to
the facets:

Peter.

On 18 Jan., 22:37, Bobby Tables rob...@maintainedauto.com wrote:

When I try to use facets with my filtered search I don't get facets.
Remove the "filtered" element and it works.

Without filtered:
curl -X GET "http://localhost:9200/products/product/_search?
pretty=true" -d '{
"query": {
"bool": {
"must": [{
"query_string": {
"query": "*",
"default_operator": "AND"
}
}]
}
},
"facets": {
"tags": {
"terms": {
"field": "tag_names",
"size": 10,
"all_terms": false
}
}
}

}'

This returns my facets as expected:

{
"took" : 3,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 2,
"max_score" : 1.0,
"hits" : [ {
"_index" : "encore_dev_product",
"_type" : "product",
"_id" : "1",
"_score" : 1.0, "_source" : {"client_id":
1,"description":"","name":"Green Day concert
tickets","location_coordinates":["32.716254,-117.160118"],"tag_names":
["concert","entertainment"]}
}, {
"_index" : "encore_dev_product",
"_type" : "product",
"_id" : "2",
"_score" : 1.0, "_source" : {"client_id":
1,"description":null,"name":"Gift certificate","location_coordinates":
["32.716254,-117.160118","33.8095868,-117.9229975"],"tag_names":
["food","restaurant"]}
} ]
},
"facets" : {
"tags" : {
"_type" : "terms",
"missing" : 0,
"total" : 4,
"other" : 0,
"terms" : [ {
"term" : "restaurant",
"count" : 1
}, {
"term" : "food",
"count" : 1
}, {
"term" : "entertainment",
"count" : 1
}, {
"term" : "concert",
"count" : 1
} ]
}
}

With filtered:

curl -X GET "http://localhost:9200/products/product/_search?
pretty=true" -d '{
"query": {
"bool": {
"must": [{
"query_string": {
"query": "*",
"default_operator": "AND"
}
}]
},
"filtered": {
"filter": [{
"geo_distance": {
"location_coordinates": "33.6147846,-117.637617",
"distance": "90mi"
}
}]
}
},
"facets": {
"tags": {
"terms": {
"field": "tag_names",
"size": 10,
"all_terms": false
}
}
}

}'

Returns no facets...

{
"took" : 2,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 2,
"max_score" : 1.0,
"hits" : [ {
"_index" : "products",
"_type" : "product",
"_id" : "1",
"_score" : 1.0, "_source" : {"client_id":
1,"description":"","name":"Green Day concert
tickets","location_coordinates":["32.716254,-117.160118"],"tag_names":
["concert","entertainment"]}
}, {
"_index" : "products",
"_type" : "product",
"_id" : "2",
"_score" : 1.0, "_source" : {"client_id":
1,"description":null,"name":"Gift certificate","location_coordinates":
["32.716254,-117.160118","33.8095868,-117.9229975"],"tag_names":
["food","restaurant"]}
} ]
}

What am I doing wrong?

I'm not sure I understand. I hate to ask but would you mind moving the
elements around to be correct so I can see it right?

On Jan 18, 2:04 pm, Karussell tableyourt...@googlemail.com wrote:

shouldn't your query go into filtered?

Elasticsearch Platform — Find real-time answers at scale | Elastic...

BTW: Also have a look into the filter element which does not apply to
the facets:Elasticsearch Platform — Find real-time answers at scale | Elastic

Peter.

On 18 Jan., 22:37, Bobby Tables rob...@maintainedauto.com wrote:

When I try to use facets with my filtered search I don't get facets.
Remove the "filtered" element and it works.

Without filtered:
curl -X GET "http://localhost:9200/products/product/_search?
pretty=true" -d '{
"query": {
"bool": {
"must": [{
"query_string": {
"query": "*",
"default_operator": "AND"
}
}]
}
},
"facets": {
"tags": {
"terms": {
"field": "tag_names",
"size": 10,
"all_terms": false
}
}
}

}'

This returns my facets as expected:

{
"took" : 3,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 2,
"max_score" : 1.0,
"hits" : [ {
"_index" : "encore_dev_product",
"_type" : "product",
"_id" : "1",
"_score" : 1.0, "_source" : {"client_id":
1,"description":"","name":"Green Day concert
tickets","location_coordinates":["32.716254,-117.160118"],"tag_names":
["concert","entertainment"]}
}, {
"_index" : "encore_dev_product",
"_type" : "product",
"_id" : "2",
"_score" : 1.0, "_source" : {"client_id":
1,"description":null,"name":"Gift certificate","location_coordinates":
["32.716254,-117.160118","33.8095868,-117.9229975"],"tag_names":
["food","restaurant"]}
} ]
},
"facets" : {
"tags" : {
"_type" : "terms",
"missing" : 0,
"total" : 4,
"other" : 0,
"terms" : [ {
"term" : "restaurant",
"count" : 1
}, {
"term" : "food",
"count" : 1
}, {
"term" : "entertainment",
"count" : 1
}, {
"term" : "concert",
"count" : 1
} ]
}
}

With filtered:

curl -X GET "http://localhost:9200/products/product/_search?
pretty=true" -d '{
"query": {
"bool": {
"must": [{
"query_string": {
"query": "*",
"default_operator": "AND"
}
}]
},
"filtered": {
"filter": [{
"geo_distance": {
"location_coordinates": "33.6147846,-117.637617",
"distance": "90mi"
}
}]
}
},
"facets": {
"tags": {
"terms": {
"field": "tag_names",
"size": 10,
"all_terms": false
}
}
}

}'

Returns no facets...

{
"took" : 2,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 2,
"max_score" : 1.0,
"hits" : [ {
"_index" : "products",
"_type" : "product",
"_id" : "1",
"_score" : 1.0, "_source" : {"client_id":
1,"description":"","name":"Green Day concert
tickets","location_coordinates":["32.716254,-117.160118"],"tag_names":
["concert","entertainment"]}
}, {
"_index" : "products",
"_type" : "product",
"_id" : "2",
"_score" : 1.0, "_source" : {"client_id":
1,"description":null,"name":"Gift certificate","location_coordinates":
["32.716254,-117.160118","33.8095868,-117.9229975"],"tag_names":
["food","restaurant"]}
} ]
}

What am I doing wrong?

On Wed, 2012-01-18 at 15:48 -0800, Bobby Tables wrote:

I'm not sure I understand. I hate to ask but would you mind moving the
elements around to be correct so I can see it right?

I answered a similar question yesterday, with examples:

clint

On Jan 18, 2:04 pm, Karussell tableyourt...@googlemail.com wrote:

shouldn't your query go into filtered?

Elasticsearch Platform — Find real-time answers at scale | Elastic...

BTW: Also have a look into the filter element which does not apply to
the facets:Elasticsearch Platform — Find real-time answers at scale | Elastic

Peter.

On 18 Jan., 22:37, Bobby Tables rob...@maintainedauto.com wrote:

When I try to use facets with my filtered search I don't get facets.
Remove the "filtered" element and it works.

Without filtered:
curl -X GET "http://localhost:9200/products/product/_search?
pretty=true" -d '{
"query": {
"bool": {
"must": [{
"query_string": {
"query": "*",
"default_operator": "AND"
}
}]
}
},
"facets": {
"tags": {
"terms": {
"field": "tag_names",
"size": 10,
"all_terms": false
}
}
}

}'

This returns my facets as expected:

{
"took" : 3,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 2,
"max_score" : 1.0,
"hits" : [ {
"_index" : "encore_dev_product",
"_type" : "product",
"_id" : "1",
"_score" : 1.0, "_source" : {"client_id":
1,"description":"","name":"Green Day concert
tickets","location_coordinates":["32.716254,-117.160118"],"tag_names":
["concert","entertainment"]}
}, {
"_index" : "encore_dev_product",
"_type" : "product",
"_id" : "2",
"_score" : 1.0, "_source" : {"client_id":
1,"description":null,"name":"Gift certificate","location_coordinates":
["32.716254,-117.160118","33.8095868,-117.9229975"],"tag_names":
["food","restaurant"]}
} ]
},
"facets" : {
"tags" : {
"_type" : "terms",
"missing" : 0,
"total" : 4,
"other" : 0,
"terms" : [ {
"term" : "restaurant",
"count" : 1
}, {
"term" : "food",
"count" : 1
}, {
"term" : "entertainment",
"count" : 1
}, {
"term" : "concert",
"count" : 1
} ]
}
}

With filtered:

curl -X GET "http://localhost:9200/products/product/_search?
pretty=true" -d '{
"query": {
"bool": {
"must": [{
"query_string": {
"query": "*",
"default_operator": "AND"
}
}]
},
"filtered": {
"filter": [{
"geo_distance": {
"location_coordinates": "33.6147846,-117.637617",
"distance": "90mi"
}
}]
}
},
"facets": {
"tags": {
"terms": {
"field": "tag_names",
"size": 10,
"all_terms": false
}
}
}

}'

Returns no facets...

{
"took" : 2,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 2,
"max_score" : 1.0,
"hits" : [ {
"_index" : "products",
"_type" : "product",
"_id" : "1",
"_score" : 1.0, "_source" : {"client_id":
1,"description":"","name":"Green Day concert
tickets","location_coordinates":["32.716254,-117.160118"],"tag_names":
["concert","entertainment"]}
}, {
"_index" : "products",
"_type" : "product",
"_id" : "2",
"_score" : 1.0, "_source" : {"client_id":
1,"description":null,"name":"Gift certificate","location_coordinates":
["32.716254,-117.160118","33.8095868,-117.9229975"],"tag_names":
["food","restaurant"]}
} ]
}

What am I doing wrong?

There is filtered query, there is filter and finally there is
facet_filter ... probably a bit too much, now explained in a quick
post:

Bobby, let me know if this solves a bit of your problem and how I
could improve my explanation there!

Peter.

On 19 Jan., 10:04, Clinton Gormley cl...@traveljury.com wrote:

On Wed, 2012-01-18 at 15:48 -0800, Bobby Tables wrote:

I'm not sure I understand. I hate to ask but would you mind moving the
elements around to be correct so I can see it right?

I answered a similar question yesterday, with examples:Elasticsearch: excluding filters while faceting possible? (like in Solr) - Stack Overflow...

clint

On Jan 18, 2:04 pm, Karussell tableyourt...@googlemail.com wrote:

shouldn't your query go into filtered?

Elasticsearch Platform — Find real-time answers at scale | Elastic......

BTW: Also have a look into the filter element which does not apply to
the facets:Elasticsearch Platform — Find real-time answers at scale | Elastic

Peter.

On 18 Jan., 22:37, Bobby Tables rob...@maintainedauto.com wrote:

When I try to use facets with my filtered search I don't get facets.
Remove the "filtered" element and it works.

Without filtered:
curl -X GET "http://localhost:9200/products/product/_search?
pretty=true" -d '{
"query": {
"bool": {
"must": [{
"query_string": {
"query": "*",
"default_operator": "AND"
}
}]
}
},
"facets": {
"tags": {
"terms": {
"field": "tag_names",
"size": 10,
"all_terms": false
}
}
}

}'

This returns my facets as expected:

{
"took" : 3,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 2,
"max_score" : 1.0,
"hits" : [ {
"_index" : "encore_dev_product",
"_type" : "product",
"_id" : "1",
"_score" : 1.0, "_source" : {"client_id":
1,"description":"","name":"Green Day concert
tickets","location_coordinates":["32.716254,-117.160118"],"tag_names":
["concert","entertainment"]}
}, {
"_index" : "encore_dev_product",
"_type" : "product",
"_id" : "2",
"_score" : 1.0, "_source" : {"client_id":
1,"description":null,"name":"Gift certificate","location_coordinates":
["32.716254,-117.160118","33.8095868,-117.9229975"],"tag_names":
["food","restaurant"]}
} ]
},
"facets" : {
"tags" : {
"_type" : "terms",
"missing" : 0,
"total" : 4,
"other" : 0,
"terms" : [ {
"term" : "restaurant",
"count" : 1
}, {
"term" : "food",
"count" : 1
}, {
"term" : "entertainment",
"count" : 1
}, {
"term" : "concert",
"count" : 1
} ]
}
}

With filtered:

curl -X GET "http://localhost:9200/products/product/_search?
pretty=true" -d '{
"query": {
"bool": {
"must": [{
"query_string": {
"query": "*",
"default_operator": "AND"
}
}]
},
"filtered": {
"filter": [{
"geo_distance": {
"location_coordinates": "33.6147846,-117.637617",
"distance": "90mi"
}
}]
}
},
"facets": {
"tags": {
"terms": {
"field": "tag_names",
"size": 10,
"all_terms": false
}
}
}

}'

Returns no facets...

{
"took" : 2,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 2,
"max_score" : 1.0,
"hits" : [ {
"_index" : "products",
"_type" : "product",
"_id" : "1",
"_score" : 1.0, "_source" : {"client_id":
1,"description":"","name":"Green Day concert
tickets","location_coordinates":["32.716254,-117.160118"],"tag_names":
["concert","entertainment"]}
}, {
"_index" : "products",
"_type" : "product",
"_id" : "2",
"_score" : 1.0, "_source" : {"client_id":
1,"description":null,"name":"Gift certificate","location_coordinates":
["32.716254,-117.160118","33.8095868,-117.9229975"],"tag_names":
["food","restaurant"]}
} ]
}

What am I doing wrong?