# Elasticsearch query array

**URL:** https://discuss.elastic.co/t/elasticsearch-query-array/10781
**Category:** Elasticsearch
**Created:** [February 18, 2013, 5:19pm UTC](https://discuss.elastic.co/t/elasticsearch-query-array/10781 "2013-02-18T17:19:56Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![eric\_sanford](https://avatars.discourse-cdn.com/v4/letter/e/9fc348/32.png) [@eric\_sanford](https://discuss.elastic.co/u/eric_sanford)
#### Post date: [February 18, 2013, 5:19pm UTC](https://discuss.elastic.co/t/elasticsearch-query-array/10781/1 "2013-02-18T17:19:56Z")

</div>

Hello

i have this JSON structure

{  
"id" : "2001",  
"promptViews" : [ {  
"id" : "2780",  
"itemType" : "promptView"...

And im trying to query it like this...

FilterBuilder filter =FilterBuilders.boolFilter()  
.must(FilterBuilders.termFilter("id", "2001"))  
.should(FilterBuilders.termFilter("promptViews.id", "2780"));

final SearchResponse response =  
client.prepareSearch("sfw1685asm28").setTypes("prompt").setFilter(filter)  
.execute().actionGet();

but its giving me all the promptViews in the array. not just the one i  
specified in the filter (2780)

Any help is appreciated

Thank you

--  
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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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: [February 18, 2013, 8:09pm UTC](https://discuss.elastic.co/t/elasticsearch-query-array/10781/2 "2013-02-18T20:09:40Z")

</div>

You are searching for documents, generally speaking.  
When your document contain a value you search for, your document is sent back exactly as you indexed it.  
Whatever the structure of the document.

If you want to search for some parts of your array, index them as documents.

Does it make sense?

--  
David Pilato | Technical Advocate | [Elasticsearch.com](http://Elasticsearch.com)  
@dadoonet | @elasticsearchfr | @scrutmydocs

Le 18 févr. 2013 à 18:19, eric sanford [pcstechnologiesinc@gmail.com](mailto:pcstechnologiesinc@gmail.com) a écrit :

> Hello
> 
> i have this JSON structure
> 
> {  
> "id" : "2001",  
> "promptViews" : [ {  
> "id" : "2780",  
> "itemType" : "promptView"...
> 
> And im trying to query it like this...
> 
> ```
> FilterBuilder filter =FilterBuilders.boolFilter()
> .must(FilterBuilders.termFilter("id", "2001"))	    	  
> .should(FilterBuilders.termFilter("promptViews.id", "2780"));
> 
> final SearchResponse response = client.prepareSearch("sfw1685asm28").setTypes("prompt").setFilter(filter) 
> .execute().actionGet();
> 
> ```
> 
> but its giving me all the promptViews in the array. not just the one i specified in the filter (2780)
> 
> Any help is appreciated
> 
> Thank you
> 
> --  
> 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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![eric\_sanford](https://avatars.discourse-cdn.com/v4/letter/e/9fc348/32.png) [@eric\_sanford](https://discuss.elastic.co/u/eric_sanford)
#### Post date: [March 4, 2013, 8:25pm UTC](https://discuss.elastic.co/t/elasticsearch-query-array/10781/3 "2013-03-04T20:25:18Z")

</div>

yes..perfect sense... thank you

On Monday, February 18, 2013 11:19:56 AM UTC-6, eric sanford wrote:

> Hello
> 
> i have this JSON structure
> 
> {  
> "id" : "2001",  
> "promptViews" : [ {  
> "id" : "2780",  
> "itemType" : "promptView"...
> 
> And im trying to query it like this...
> 
> FilterBuilder filter =FilterBuilders.boolFilter()  
> .must(FilterBuilders.termFilter("id", "2001"))  
> .should(FilterBuilders.termFilter("promptViews.id", "2780"));
> 
> final SearchResponse response =  
> client.prepareSearch("sfw1685asm28").setTypes("prompt").setFilter(filter)  
> .execute().actionGet();
> 
> but its giving me all the promptViews in the array. not just the one i  
> specified in the filter (2780)
> 
> Any help is appreciated
> 
> Thank you

--  
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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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: [July 6, 2017, 2:48am UTC](https://discuss.elastic.co/t/elasticsearch-query-array/10781/4 "2017-07-06T02:48:27Z")

</div>


