# How to get count of total records without size in elastic search

**URL:** <https://discuss.elastic.co/t/how-to-get-count-of-total-records-without-size-in-elastic-search/105713>\
**Category:** Elasticsearch\
**Created:** [October 30, 2017, 5:49am UTC](https://discuss.elastic.co/t/how-to-get-count-of-total-records-without-size-in-elastic-search/105713 "2017-10-30T05:49:09Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![sanjay25](https://avatars.discourse-cdn.com/v4/letter/s/5f8ce5/32.png) [@sanjay25](https://discuss.elastic.co/u/sanjay25)\
**Post date:** [October 30, 2017, 5:49am UTC](https://discuss.elastic.co/t/how-to-get-count-of-total-records-without-size-in-elastic-search/105713/1 "2017-10-30T05:49:09Z")

</div>

I want to get count of total records from elastic search.  
Executing manual query is giving 400 records whereas elastic search giving 10 records. How do I get total records regardless of size.?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [October 30, 2017, 8:05am UTC](https://discuss.elastic.co/t/how-to-get-count-of-total-records-without-size-in-elastic-search/105713/2 "2017-10-30T08:05:56Z")

</div>

Can you share the exact response of elasticsearch ?

---

<div class="post-metadata">

**Author:** ![sanjay25](https://avatars.discourse-cdn.com/v4/letter/s/5f8ce5/32.png) [@sanjay25](https://discuss.elastic.co/u/sanjay25)\
**Post date:** [October 30, 2017, 8:51am UTC](https://discuss.elastic.co/t/how-to-get-count-of-total-records-without-size-in-elastic-search/105713/3 "2017-10-30T08:51:59Z")

</div>

@dadoonet  
\> [searchfound] =\> 2

> ```
> [result] => Array
> (
> [0] => Array
> (
> [prod_id] => 
> [lang_id] => 1
> [manuf_id] => 5
> [cat_type_id] => 1
> [cat_id] => 10
> [network_id] => 3
> [comp_group_id] => 0
> [prod_name] => Samsung E250 Black On Orange PAYG Mobile Phone
> [prod_short_name] => 
> [prod_color] => 0
> [prod_seo_name] => Samsung-e250-black-orange-payg
> [prod_model] => E250
> [prod_video_url] => 
> [prod_purchase_price] => 53.00
> [prod_reseller_price] => 0.00
> [prod_retail_price] => 27.08
> [prod_sp_offer_price] => 999.00
> [prod_credit] => 0.00
> [prod_stock_qty] => 0
> [prod_alert_at_qty] => 0
> [prod_univ_comptability] => 0
> [prod_preorder] => 0
> [prod_preorder_text] => 
> [prod_have_specs] => 0
> [prod_discount_flag] => 0
> [prod_ships_in] => 1
> [prod_mpn] => Samsung E250 Black Orange PAYG
> [prod_newarrival] => No
> [prod_supersaver] => No
> [prod_best] => No
> [prod_sku] => 
> [prod_ean] => 5037808910007
> [prod_ean_type] => autogenerated
> [prod_type] => Consumer Electronics
> [prod_node] => 564420
> [prod_rating] => 4
> [prod_insurance_id] => 1
> [prod_latest] => 0
> [prod_best_selling] => 0
> [prod_best_deal] => 0
> [prod_added_on] => 2010-12-27 07:15:06
> [prod_bundle_ids] => 
> [prod_upd_user_id] => 17
> [prod_upd_datetime] => 2011-02-04 12:55:48
> [prod_status] => 0
> [is_comp_phone] => 0
> [is_excluded] => 0
> [parent_prod_id] => 0
> [is_canonical] => 0
> [product_for] => 
>                         
> )
> )
> 
> ```

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [October 30, 2017, 9:24am UTC](https://discuss.elastic.co/t/how-to-get-count-of-total-records-without-size-in-elastic-search/105713/4 "2017-10-30T09:24:01Z")

</div>

It does not look like an elasticsearch answer. Could you produce the JSON response from elasticsearch please?

---

<div class="post-metadata">

**Author:** ![sanjay25](https://avatars.discourse-cdn.com/v4/letter/s/5f8ce5/32.png) [@sanjay25](https://discuss.elastic.co/u/sanjay25)\
**Post date:** [October 30, 2017, 9:42am UTC](https://discuss.elastic.co/t/how-to-get-count-of-total-records-without-size-in-elastic-search/105713/5 "2017-10-30T09:42:55Z")

</div>

Actually I am new to elastic search.

Below is my URL:

`http://example.com/ppm2.0/search.html?q=samsung-e250-black-on-orange-payg-mobile-phone`

It is in PHP and returning an array. I don't know how can I produce in JSON.

below is my elasic search:

```
 $params = [
                'index' => $this->client->getIndex(),
                'type' => $this->client->getType(),
				"from" => 0, "size" => 1000,
				//"scroll" => "1m",

                'body' => [
               "query" => [
				   "bool" => [
					  "must" => [
						 [
							  "multi_match" => [
								  "fields" => ["prod_name", "prod_seo_name"],
								  "type" => "phrase_prefix",
								  "query" => $query
							  ]
						 ],
						 [
							  "term"=> ["cat_type_id"=>1]
						 ]
					  ]
				   ]
				]
				],
           ];
```

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [October 30, 2017, 9:55am UTC](https://discuss.elastic.co/t/how-to-get-count-of-total-records-without-size-in-elastic-search/105713/6 "2017-10-30T09:55:11Z")

</div>

Could you provide a full recreation script as described in

> [@About the Elasticsearch category](https://discuss.elastic.co/t/about-the-elasticsearch-category/21):
>
> The heart of the free and open Elastic Stack Elasticsearch is a distributed, RESTful search and analytics engine capable of addressing a growing number of use cases. As the heart of the Elastic Stack, it centrally stores your data for lightning fast search, fine‑tuned relevancy, and powerful analytics that scale with ease. warning PLEASE READ THIS SECTION IF IT'S YOUR FIRST POST Some useful links: [elasticsearch reference guide](http://www.elastic.co/guide/en/elasticsearch/reference/current/index.html)[elasticsearch user guide](http://www.elastic.co/guide/en/elasticsearch/guide/current/index.html)[elasticsearch plugins](https://www.elastic.co/guide/en/elasticsearch/plugins/current/index.html)[elasticsearch cl…](https://www.elastic.co/guide/en/elasticsearch/client/index.html)

It will help to better understand what you are doing.  
Please, try to keep the example as simple as possible.

---

<div class="post-metadata">

**Author:** ![sanjay25](https://avatars.discourse-cdn.com/v4/letter/s/5f8ce5/32.png) [@sanjay25](https://discuss.elastic.co/u/sanjay25)\
**Post date:** [October 30, 2017, 10:06am UTC](https://discuss.elastic.co/t/how-to-get-count-of-total-records-without-size-in-elastic-search/105713/7 "2017-10-30T10:06:54Z")

</div>

```
"query" :{
	 "bool" :{
		  "must" :{
			   {
			      "multi_match" :{
				                "fields" : ["prod_name", "prod_seo_name"],
						 "type" : "phrase_prefix",
						 "query" : 'Samsung Mobile'
						  }
			    },
			    {
				 "term": ["cat_type_id"=>1]
			     }
			     }
			   }
			}
```

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [October 30, 2017, 10:20am UTC](https://discuss.elastic.co/t/how-to-get-count-of-total-records-without-size-in-elastic-search/105713/8 "2017-10-30T10:20:48Z")

</div>

I can't help.

Please reproduce the problem and share the output from elasticsearch. Not anything that your application is parsing/changing.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [November 27, 2017, 10:20am UTC](https://discuss.elastic.co/t/how-to-get-count-of-total-records-without-size-in-elastic-search/105713/9 "2017-11-27T10:20:51Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
