# How to query by size/length of nested property

**URL:** https://discuss.elastic.co/t/how-to-query-by-size-length-of-nested-property/96334
**Category:** Elasticsearch
**Created:** [August 8, 2017, 7:53pm UTC](https://discuss.elastic.co/t/how-to-query-by-size-length-of-nested-property/96334 "2017-08-08T19:53:59Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![bploetz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bploetz/32/15189_2.png) [@bploetz](https://discuss.elastic.co/u/bploetz)
#### Post date: [August 8, 2017, 7:53pm UTC](https://discuss.elastic.co/t/how-to-query-by-size-length-of-nested-property/96334/1 "2017-08-08T19:53:59Z")

</div>

Assume the following mapping - A user has a nested array of "posts" objects:

```auto
PUT users
{
	"settings": {
		...
	},
	"mappings": {
		"user": {
			"dynamic": false,
			"_all": {"enabled": false },
			"properties": {
				"gender": {
					"type": "string",
					"index": "not_analyzed"
				},
				"posts": {
					"type": "nested",
					"properties": {
						"post_date": {
							"type": "date",
							"format": "epoch_second"
						},
						"text": {
							"type": "string",
							"analyzer": "not_analyzed"
						},
					}
				}
			}
		}
	}
}

```

I want to search for users that have more than 1 post (or other variations based on the length/size of the posts field) How do I write this search in Elasticsearch 5.x? I've tried every combination I've found online (searches, filters, script queries, etc) and I can't find anything that works.

Thanks in advance.  
BP

---

<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: [September 5, 2017, 7:54pm UTC](https://discuss.elastic.co/t/how-to-query-by-size-length-of-nested-property/96334/2 "2017-09-05T19:54:00Z")

</div>

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