# Adding payload and retrieve them in highlighting

**URL:** <https://discuss.elastic.co/t/adding-payload-and-retrieve-them-in-highlighting/16770>\
**Category:** Elasticsearch\
**Created:** [April 2, 2014, 2:59pm UTC](https://discuss.elastic.co/t/adding-payload-and-retrieve-them-in-highlighting/16770 "2014-04-02T14:59:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Karol\_Sikora](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/karol_sikora/32/983_2.png) [@Karol\_Sikora](https://discuss.elastic.co/u/Karol_Sikora)\
**Post date:** [April 2, 2014, 2:59pm UTC](https://discuss.elastic.co/t/adding-payload-and-retrieve-them-in-highlighting/16770/1 "2014-04-02T14:59:04Z")

</div>

Hi,

My simplified use case is to search in pages of book and show back to user  
on which pages search phrase was found.  
First think about such case was to denormalize pages structure into fields  
in book, eg page\_1, page\_2, .... The important thing is that i need to  
return back on which page we found phrase occurence.  
This approach fails, because i need to search in content fields, but  
querying and highlighting i fields named page\_\* is impossible.  
I was also thinked about storing pages in nested structures, but it also  
fails because i cannot get back information about page in highlighting.  
Tested strucuture looked as following:  
pages: [{'name': 1, 'content': 'lorem ipsum'}, ...] (inner objects)  
pages: {1: 'lorem ipsum', ...}, (nested objects)  
Both above also fails.

The way that i'm thinking is to store payload(page numner) with content  
attribute, so indexing structure as inner objects will be theoretically  
able to return page number with higlighting response.

Im asking here for advice more advanced users. As far as i know storing  
payloads and returing them in highlight response is currently not possible,  
but i can try to develop support for such feature.  
But, maybe there is an easier way that i'm missing now.

Regards,  
Karol

--  
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/cc4a5e0c-56b0-486b-9595-6d7ffac37212%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/cc4a5e0c-56b0-486b-9595-6d7ffac37212%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:38am UTC](https://discuss.elastic.co/t/adding-payload-and-retrieve-them-in-highlighting/16770/2 "2017-07-06T01:38:44Z")

</div>


