Total number of documents be included in each query


(kazoompa-3) #1

Hi,

I would like to know whether I can perform a query and get not only the
total hits but also the total document counts.

Here is an example of one of my queries:

{
"from" : 0,
"size" : 30,
"query" : {
"filtered" : {
"query" : {
"match_all" : { }
},
"filter" : {
"bool" : {
"must" : {
"terms" : {
"valueType" : [ "decimal" ]
}
}
}
}
}
},
"aggregations" : {
"variableType" : {
"terms" : {
"field" : "variableType",
"order" : {
"_term" : "asc"
}
}
}
}
}

And a part of my sample response:

{
"took" : 7,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 285,
"max_score" : 1.0,
"hits" : [ {...} ]
}

I would love to include the total documents count as well, as if I had done
a match_all() query only.

Thanks a lot.

--
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/c11848bb-7767-42da-a4c3-60892b766116%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(David Pilato) #2

You could try http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-multi-search.html

Or this: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-bucket-global-aggregation.html

--
David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 4 sept. 2014 à 23:01, kazoompa rhaeri@p3g.org a écrit :

Hi,
I would like to know whether I can perform a query and get not only the total hits but also the total document counts.

Here is an example of one of my queries:

{
"from" : 0,
"size" : 30,
"query" : {
"filtered" : {
"query" : {
"match_all" : { }
},
"filter" : {
"bool" : {
"must" : {
"terms" : {
"valueType" : [ "decimal" ]
}
}
}
}
}
},
"aggregations" : {
"variableType" : {
"terms" : {
"field" : "variableType",
"order" : {
"_term" : "asc"
}
}
}
}
}

And a part of my sample response:

{
"took" : 7,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 285,
"max_score" : 1.0,
"hits" : [ {...} ]
}

I would love to include the total documents count as well, as if I had done a match_all() query only.

Thanks a lot.

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/c11848bb-7767-42da-a4c3-60892b766116%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
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/E01FBBCB-2918-4373-BD24-82CA26EF92F0%40pilato.fr.
For more options, visit https://groups.google.com/d/optout.


(kazoompa-3) #3

Fantastic, Thanks David.

BTW, I have to thank you for your video presentation in French, it really
helped me a lot to understand the basics od ES two years ago.

Cheers.

On Thursday, September 4, 2014 5:09:35 PM UTC-4, David Pilato wrote:

You could try
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-multi-search.html

Or this:
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-bucket-global-aggregation.html

--
David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 4 sept. 2014 à 23:01, kazoompa <rha...@p3g.org <javascript:>> a écrit :

Hi,

I would like to know whether I can perform a query and get not only the
total hits but also the total document counts.

Here is an example of one of my queries:

{
"from" : 0,
"size" : 30,
"query" : {
"filtered" : {
"query" : {
"match_all" : { }
},
"filter" : {
"bool" : {
"must" : {
"terms" : {
"valueType" : [ "decimal" ]
}
}
}
}
}
},
"aggregations" : {
"variableType" : {
"terms" : {
"field" : "variableType",
"order" : {
"_term" : "asc"
}
}
}
}
}

And a part of my sample response:

{
"took" : 7,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 285,
"max_score" : 1.0,
"hits" : [ {...} ]
}

I would love to include the total documents count as well, as if I had
done a match_all() query only.

Thanks a lot.

--
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:>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/c11848bb-7767-42da-a4c3-60892b766116%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/c11848bb-7767-42da-a4c3-60892b766116%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

--
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/9964220a-0c74-4164-a49d-b13e0fc8a3f7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(David Pilato) #4

Cool! Lot of things have changed since though! :slight_smile:

--
David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 5 sept. 2014 à 15:41, kazoompa rhaeri@p3g.org a écrit :

Fantastic, Thanks David.

BTW, I have to thank you for your video presentation in French, it really helped me a lot to understand the basics od ES two years ago.

Cheers.

On Thursday, September 4, 2014 5:09:35 PM UTC-4, David Pilato wrote:
You could try http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-multi-search.html

Or this: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-bucket-global-aggregation.html

--
David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 4 sept. 2014 à 23:01, kazoompa rha...@p3g.org a écrit :

Hi,
I would like to know whether I can perform a query and get not only the total hits but also the total document counts.

Here is an example of one of my queries:

{
"from" : 0,
"size" : 30,
"query" : {
"filtered" : {
"query" : {
"match_all" : { }
},
"filter" : {
"bool" : {
"must" : {
"terms" : {
"valueType" : [ "decimal" ]
}
}
}
}
}
},
"aggregations" : {
"variableType" : {
"terms" : {
"field" : "variableType",
"order" : {
"_term" : "asc"
}
}
}
}
}

And a part of my sample response:

{
"took" : 7,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 285,
"max_score" : 1.0,
"hits" : [ {...} ]
}

I would love to include the total documents count as well, as if I had done a match_all() query only.

Thanks a lot.

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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/c11848bb-7767-42da-a4c3-60892b766116%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
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/9964220a-0c74-4164-a49d-b13e0fc8a3f7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
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/FB6AB667-5722-40D5-91FD-73FD65775011%40pilato.fr.
For more options, visit https://groups.google.com/d/optout.


(system) #5