# Best way to index "subfield" / mapping

**URL:** <https://discuss.elastic.co/t/best-way-to-index-subfield-mapping/87414>\
**Category:** Elasticsearch\
**Created:** [May 29, 2017, 8:17am UTC](https://discuss.elastic.co/t/best-way-to-index-subfield-mapping/87414 "2017-05-29T08:17:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Miku](https://avatars.discourse-cdn.com/v4/letter/m/7ab992/32.png) [@Miku](https://discuss.elastic.co/u/Miku)\
**Post date:** [May 29, 2017, 8:17am UTC](https://discuss.elastic.co/t/best-way-to-index-subfield-mapping/87414/1 "2017-05-29T08:17:40Z")

</div>

Hi guys,

i have the following situation. I have an Element with attributes, like title, description and so on.  
And there are subelements, also with title, value...

What is the best mapping to achive that i can query Elements with specific values in subelements. I think nested is the wrong way, because i wont query Subelements as separate Items.

Query something like: "Find element where value in subelement1 is true"...

Dummy Structure:

```
"element": {
  "title" : "myelement",
  "description" : "myDescription",
   "subelements": [
            {
              "title": "subelement1",
              "value": "false"
            },
            {
              "title": "subelement2",
              "value": "true"
            }
   ]
}

```

Thanks for any advice.

Best regards.

---

<div class="post-metadata">

**Author:** ![Miku](https://avatars.discourse-cdn.com/v4/letter/m/7ab992/32.png) [@Miku](https://discuss.elastic.co/u/Miku)\
**Post date:** [May 29, 2017, 11:37am UTC](https://discuss.elastic.co/t/best-way-to-index-subfield-mapping/87414/2 "2017-05-29T11:37:40Z")

</div>

Hi,

after digging a little bit deeper in the "nested" Functionality, i correct myself and say that this might be a possible way.

Disagreements? Improvements?

Thanks.

Best regards.

---

<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:** [June 26, 2017, 11:37am UTC](https://discuss.elastic.co/t/best-way-to-index-subfield-mapping/87414/3 "2017-06-26T11:37:56Z")

</div>

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