# Search specific field in elastic search

**URL:** <https://discuss.elastic.co/t/search-specific-field-in-elastic-search/103807>\
**Category:** Elasticsearch\
**Created:** [October 13, 2017, 2:32am UTC](https://discuss.elastic.co/t/search-specific-field-in-elastic-search/103807 "2017-10-13T02:32:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chanpiseth\_Ros](https://avatars.discourse-cdn.com/v4/letter/c/c4cdca/32.png) [@Chanpiseth\_Ros](https://discuss.elastic.co/u/Chanpiseth_Ros)\
**Post date:** [October 13, 2017, 2:32am UTC](https://discuss.elastic.co/t/search-specific-field-in-elastic-search/103807/1 "2017-10-13T02:32:15Z")

</div>

Hi everyone, i want o search records with specific fields in elastic search like records below:

```
"person": [
	{
		"id": 1
		"name": "jame"
	},
	{
		"id": 2,
		"name": "EVP"
	},
	{
		"id": 3,
		"name": "GP"
	},
	{
		"id": 3,
		"name": "PLR"
     }
]

```

I want to search id (2 and 3) in the person, i have tried query\_string but it's not working, my code is as below:

```
{
    "query" : {
        "query_string" : {
            "default_field" : "person.id",
            "query" : "2, 3"
        }
    }
}

```

And i also try to use another way, but i always get error with NumberFormatException.

 ![Screenshot from 2017-10-13 10-53-01](https://us1.discourse-cdn.com/elastic/original/3X/d/7/d7be5cc34dd4e054df035cb5db2ee7d70758c481.png)

Can anyone help me?  
Thanks

---

<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 13, 2017, 6:45am UTC](https://discuss.elastic.co/t/search-specific-field-in-elastic-search/103807/2 "2017-10-13T06:45:54Z")

</div>

Please format your code using `</>` icon as explained in [this guide](https://discuss.elastic.co/t/about-the-elasticsearch-category/21). It will make your post more readable.

Or use markdown style like:

````
```
CODE
```

````

Don't paste images if not useful. Better to paste the full error in your case so it's searchable.

The short answer is that you probably should use a bool query and should or must or filter clauses.

But I don't understand the model here TBH. What are you searching for? This group of persons or just individuals?

If the later, then index them one by one. One person per document.  
Then if you just want to GET by id a person run:

```
GET person/doc/1

```

And you're done.

---

<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 10, 2017, 6:46am UTC](https://discuss.elastic.co/t/search-specific-field-in-elastic-search/103807/3 "2017-11-10T06:46:13Z")

</div>

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