# Accessing non-stored fields

**URL:** <https://discuss.elastic.co/t/accessing-non-stored-fields/16346>\
**Category:** Elasticsearch\
**Created:** [March 13, 2014, 10:09am UTC](https://discuss.elastic.co/t/accessing-non-stored-fields/16346 "2014-03-13T10:09:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tom\_Verschueren](https://avatars.discourse-cdn.com/v4/letter/t/b5a626/32.png) [@Tom\_Verschueren](https://discuss.elastic.co/u/Tom_Verschueren)\
**Post date:** [March 13, 2014, 10:09am UTC](https://discuss.elastic.co/t/accessing-non-stored-fields/16346/1 "2014-03-13T10:09:23Z")

</div>

Hi

I am new to elasticsearch and am trying out the attachement plugin. I'm a  
bit confused on how to handle the meta-data from the attachements.

I have created a simple mapping as example. I explicitly store the 'title'  
field, other fields are by default not stored.  
PUT /test/file/\_mapping  
{  
"random" : {  
"properties": {  
"content" : {  
"type" : "attachment",  
"fields" : {

```
                "title" : {
                    "index": "analyzed", 
                    "store" : "yes"
                },

                "content_type" : {
                    "store" : "no"
                }
            }
      }
  }

```

}  
}

This is the mapping as given by elasticsearch

{  
"test": {  
"mappings": {  
"file": {  
"properties": {  
"content": {  
"type": "attachment",  
"path": "full",  
"fields": {  
"content": {  
"type": "string"  
},  
"author": {  
"type": "string"  
},  
"title": {  
"type": "string",  
"store": true  
},  
"name": {  
"type": "string"  
},  
"date": {  
"type": "date",  
"format": "dateOptionalTime"  
},  
"keywords": {  
"type": "string"  
},  
"content\_type": {  
"type": "string"  
},  
"content\_length": {  
"type": "integer"  
}  
}  
}  
}  
}  
}  
}  
}

Example query:

GET /test/file/\_search  
{  
"fields": [  
"\*", "content.content\_type"  
],  
"query": {  
"match": {  
"content.content\_type": "xhtml test document"  
}  
}  
}

response:  
{  
"took": 13,  
"timed\_out": false,  
"\_shards": {  
"total": 5,  
"successful": 5,  
"failed": 0  
},  
"hits": {  
"total": 1,  
"max\_score": 0.26574233,  
"hits": [  
{  
"\_index": "test",  
"\_type": "file",  
"\_id": "3SmwWJe6TtiP0nheD6pFCg",  
"\_score": 0.26574233,  
"fields": {  
"content.content\_type": [  
"...PCEtLQogTGljZW5zZWQgdG8gdGhlI..."  
],  
"content.title": [  
"XHTML test document"  
]  
}  
}  
]  
}  
}

So I am able to query on the "content\_type" field, but in the response I  
get the base64 representation of the attachement, instead of  
""application/xhtml+xml".  
Do I really need to store each meta-data field for my attachement? I was  
under the impression that elasticsearch would extract the field from the  
\_source at runtime (or would this cause to much overhead?)

Thx,  
Tom

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/461e4ba9-cdab-4c76-a915-c8e1f8b7ae22%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/461e4ba9-cdab-4c76-a915-c8e1f8b7ae22%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Binh\_Ly\_2](https://avatars.discourse-cdn.com/v4/letter/b/d07c76/32.png) [@Binh\_Ly\_2](https://discuss.elastic.co/u/Binh_Ly_2)\
**Post date:** [March 13, 2014, 7:41pm UTC](https://discuss.elastic.co/t/accessing-non-stored-fields/16346/2 "2014-03-13T19:41:52Z")

</div>

Yes you'd need to store the content\_type to get it back. The \_source field  
in your case is actually nothing more than the base64 of your raw input  
document at the time you indexed it.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/e7c8c6d7-7c9d-49a6-8234-9bebec5050d8%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/e7c8c6d7-7c9d-49a6-8234-9bebec5050d8%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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 6, 2017, 1:43am UTC](https://discuss.elastic.co/t/accessing-non-stored-fields/16346/3 "2017-07-06T01:43:20Z")

</div>


