# List Doc search in Doc

**URL:** <https://discuss.elastic.co/t/list-doc-search-in-doc/35321>\
**Category:** Elasticsearch\
**Created:** [November 23, 2015, 3:44pm UTC](https://discuss.elastic.co/t/list-doc-search-in-doc/35321 "2015-11-23T15:44:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![adoc](https://avatars.discourse-cdn.com/v4/letter/a/8e7dd6/32.png) [@adoc](https://discuss.elastic.co/u/adoc)\
**Post date:** [November 23, 2015, 3:44pm UTC](https://discuss.elastic.co/t/list-doc-search-in-doc/35321/1 "2015-11-23T15:44:33Z")

</div>

Hi,  
I have some classes like below. And i want to search, list of the person records that persontype id = 5 and name = "XX"

```
class Person
{
    public int Id { get; set; }
    public string Firstname { get; set; }
    public string Lastname { get; set; }
    public string User { get; set; }
    public string Pass { get; set; }
    public bool active { get; set; }

    public List<PersonType> listType { get; set; }
}

public class PersonType
{
    public int id { get; set; }
    public string name { get; set; }
}
```

---

<div class="post-metadata">

**Author:** ![mainec](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mainec/32/5557_2.png) [@mainec](https://discuss.elastic.co/u/mainec)\
**Post date:** [November 24, 2015, 9:55am UTC](https://discuss.elastic.co/t/list-doc-search-in-doc/35321/2 "2015-11-24T09:55:13Z")

</div>

Without having seen the actual json you indexed: Sounds like you should be able to achieve with a simple combination of a bool and term query to me:

```
DELETE index
 
PUT index/type/1
{
    "name": "john",
    "types": [1, 2, 3]
}

GET _search
{
    "query": {
        "bool": {
            "must": [
               {"term": {"name": {"value": "john"}}},
               {"term": {"types": "1"}}
        ]
        }}
}

```

The [ES Query DSL docs](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl.html) should provide you with more info. Probably the [data modeling](https://www.elastic.co/guide/en/elasticsearch/guide/current/modeling-your-data.html) docs are also interesting for you.

Translating this to .NET code should be easy enough with [https://www.elastic.co/guide/en/elasticsearch/client/net-api/current/index.html](https://www.elastic.co/guide/en/elasticsearch/client/net-api/current/index.html)

---

<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 5, 2017, 11:36pm UTC](https://discuss.elastic.co/t/list-doc-search-in-doc/35321/3 "2017-07-05T23:36:23Z")

</div>

Closed on July 5, 2017, 11:36pm UTC


