# Combine fields in query

**URL:** <https://discuss.elastic.co/t/combine-fields-in-query/167858>\
**Category:** Elasticsearch\
**Created:** [February 11, 2019, 1:05pm UTC](https://discuss.elastic.co/t/combine-fields-in-query/167858 "2019-02-11T13:05:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Josef\_Fritzer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/josef_fritzer/32/54420_2.png) [@Josef\_Fritzer](https://discuss.elastic.co/u/Josef_Fritzer)\
**Post date:** [February 11, 2019, 1:05pm UTC](https://discuss.elastic.co/t/combine-fields-in-query/167858/1 "2019-02-11T13:05:40Z")

</div>

Hi,

I have the following document in my index:

```
{
  "_id": "0012020310",
  "_source": {
    "ConstructionProject": {
      "Candidates": [
        {
          "InterestIndicator": "NORMAL",
          "State": "CONTRACTOR"
        },
		{
          "InterestIndicator": "BIG",
          "State": "CLIENT"
        }
      ]
  }
}

```

If i send the following query (ConstructionProject.Candidates.InterestIndicator:NORMAL AND ConstructionProject.Candidates.State:CLIENT) to my elastic I get the document above back. That's perfect but it's not what I need. I need a query which searches on "Candidate" level which means, the document should get returned if the query fields "InterestIndicator:NORMAL" AND "State:CLIENT" will be found in one single candidate. Has anyone an idea?

THANKS

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [February 11, 2019, 1:09pm UTC](https://discuss.elastic.co/t/combine-fields-in-query/167858/2 "2019-02-11T13:09:53Z")

</div>

Hi Josef,  
You need to use the [nested](https://www.elastic.co/guide/en/elasticsearch/reference/current/nested.html) datatype and [nested query](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-nested-query.html) for these scenarios when you need to match \>1 field of an object in an array.

---

<div class="post-metadata">

**Author:** ![Josef\_Fritzer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/josef_fritzer/32/54420_2.png) [@Josef\_Fritzer](https://discuss.elastic.co/u/Josef_Fritzer)\
**Post date:** [February 12, 2019, 6:56am UTC](https://discuss.elastic.co/t/combine-fields-in-query/167858/3 "2019-02-12T06:56:26Z")

</div>

Hello Mark, this is what I've been looking for, thank you very much!

---

<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:** [March 12, 2019, 7:02am UTC](https://discuss.elastic.co/t/combine-fields-in-query/167858/4 "2019-03-12T07:02:22Z")

</div>

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