# Search on json field

**URL:** <https://discuss.elastic.co/t/search-on-json-field/7437>\
**Category:** Elasticsearch\
**Created:** [April 23, 2012, 4:01am UTC](https://discuss.elastic.co/t/search-on-json-field/7437 "2012-04-23T04:01:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![limac](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/limac/32/3981_2.png) [@limac](https://discuss.elastic.co/u/limac)\
**Post date:** [April 23, 2012, 4:01am UTC](https://discuss.elastic.co/t/search-on-json-field/7437/1 "2012-04-23T04:01:02Z")

</div>

Hi there,

I have a doc like this:

perf\_metric{  
in\_byte : 100,  
out\_byte :0,  
ret\_cod:{  
suc: "true",  
mc:"0000"  
}  
}

my question is, how to build a query or filter to search all doc with  
ret\_cod.suc="true", the ret\_cod is now mapped as string, is this the key  
point?

I am a newbie to elastic and sorry for so many questions 🙂

Alan

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [April 25, 2012, 3:45pm UTC](https://discuss.elastic.co/t/search-on-json-field/7437/2 "2012-04-25T15:45:18Z")

</div>

Here is a sample of one that searches on index test with a filtered  
match\_all query:

curl localhost:9200/test/\_search -d '{  
"query" : {  
"filtered" : {  
"query" : {  
"match\_all" : {}  
},  
"filter" : {  
"term" : {  
"ret\_cod.suc" : "true"  
}  
}  
}  
}  
}'

On Mon, Apr 23, 2012 at 7:01 AM, Wang Yong [cnwangyong@gmail.com](mailto:cnwangyong@gmail.com) wrote:

> Hi there,
> 
> I have a doc like this:
> 
> perf\_metric{  
> in\_byte : 100,  
> out\_byte :0,  
> ret\_cod:{  
> suc: "true",  
> mc:"0000"  
> }  
> }
> 
> my question is, how to build a query or filter to search all doc with  
> ret\_cod.suc="true", the ret\_cod is now mapped as string, is this the key  
> point?
> 
> I am a newbie to elastic and sorry for so many questions 🙂
> 
> Alan

---

<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, 3:31am UTC](https://discuss.elastic.co/t/search-on-json-field/7437/3 "2017-07-06T03:31:07Z")

</div>


