# Indexing and searching of flattened

**URL:** <https://discuss.elastic.co/t/indexing-and-searching-of-flattened/368247>\
**Category:** Elasticsearch\
**Created:** [October 4, 2024, 12:22pm UTC](https://discuss.elastic.co/t/indexing-and-searching-of-flattened/368247 "2024-10-04T12:22:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ivenhov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ivenhov/32/138072_2.png) [@ivenhov](https://discuss.elastic.co/u/ivenhov)\
**Post date:** [October 4, 2024, 12:22pm UTC](https://discuss.elastic.co/t/indexing-and-searching-of-flattened/368247/1 "2024-10-04T12:22:47Z")

</div>

Hi Assuming I have a document like below

```json
{
  "name": "Document 1",
  "fieldA": 123.45,
  "fieldB": "Sample text",
  "fieldC": "keyword_value",
  "ValuesDocument": {
    "al6gq": "true",
    "63c095bebb3a6b02afcb2cbd": "ABC-369",
    "ab4jh" : "anc@gmail.com",
    "awb6p" : "1.2.3.4",
    "afl2f" : {
        "_t": "ValueSelection",
        "_id": "abc",
        "Value": "test string",
        "v": "xyz"
    }
  }
}

```

I would like to use flattened on ValuesDocument  
If I understand correctly this will put all the values of internal fields as keywords of the ValuesDocument field  
If that's the case how can searching on internal fields like below be possible?  
`ValuesDocument.ab4jh:anc@gmail.com`

Does it mean it is done as a filtering stage from \_source of all matching documents? Or is it something else going on behind the scenes?

Furthermore, what happens if I'm starting to use AND operation on more than one internal fields? Does search time starts to add up because more documents needs to be checked?

Considering that flattening is done to avoid creating extra mappings I'm guessing it's one internal inverted index for terms of ValuesDocument?

Thanks
