Facet within the specified size


(rubyprince) #1

Facets is very useful to get the count of the items, as a whole.

But my problem is, I want the count for the query, I am searching inside
the size limit I am specifying. Look at the query, I am making:

curl -X GET
'http://localhost:9200/posts/post/_search?from=0&size=10&pretty' -d '{
"query": {
"filtered": {
"query": {
"query_string": {
"query": "exists:country AND content:(obama OR somalia)"
}
}
}
},
"facets": {
"content": {
"terms": {
"field": "content",
"size": 10,
"all_terms": false,
"regex": "obama|somalia",
"regex_flags": [
"DOTALL",
"CASE_INSENSITIVE"
]
}
}
},
"size": 10000,
"fields": [
"continent",
"country",
"id",
"location",
"sentiment",
"tweet_created_at"
],
"version": true
}'

This is the query, I am using now. But the facet content is giving count
for the database as a whole satisfying the query string. But, I want to
facet within the 10,000 returned.

Is there a way to facet like that?

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/f5c1ccbb-3b01-492e-9357-37f14ea5e587%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(Ivan Brusic) #2

The facet will work on all the documents that satisfy the query. The size
parameter in the query only denotes how many documents that match the query
should be returned.

There is an issue regarding faceting only on the top n results:

Cheers,

Ivan

On Thu, Dec 19, 2013 at 9:36 PM, Prince princejcet@gmail.com wrote:

Facets is very useful to get the count of the items, as a whole.

But my problem is, I want the count for the query, I am searching inside
the size limit I am specifying. Look at the query, I am making:

curl -X GET '
http://localhost:9200/posts/post/_search?from=0&size=10&pretty' -d '{
"query": {
"filtered": {
"query": {
"query_string": {
"query": "exists:country AND content:(obama OR somalia)"
}
}
}
},
"facets": {
"content": {
"terms": {
"field": "content",
"size": 10,
"all_terms": false,
"regex": "obama|somalia",
"regex_flags": [
"DOTALL",
"CASE_INSENSITIVE"
]
}
}
},
"size": 10000,
"fields": [
"continent",
"country",
"id",
"location",
"sentiment",
"tweet_created_at"
],
"version": true
}'

This is the query, I am using now. But the facet content is giving count
for the database as a whole satisfying the query string. But, I want to
facet within the 10,000 returned.

Is there a way to facet like that?

--
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.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/f5c1ccbb-3b01-492e-9357-37f14ea5e587%40googlegroups.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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQAjOkXAEvG8CwhjSRKYbxSmzaJ5QAzvcmDOPGe-fjW2NQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


(system) #3