# How to run a query with the properties from a stored document?

**URL:** <https://discuss.elastic.co/t/how-to-run-a-query-with-the-properties-from-a-stored-document/67222>\
**Category:** Elasticsearch\
**Created:** [November 25, 2016, 10:41pm UTC](https://discuss.elastic.co/t/how-to-run-a-query-with-the-properties-from-a-stored-document/67222 "2016-11-25T22:41:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tom12e](https://avatars.discourse-cdn.com/v4/letter/t/41988e/32.png) [@tom12e](https://discuss.elastic.co/u/tom12e)\
**Post date:** [November 25, 2016, 10:41pm UTC](https://discuss.elastic.co/t/how-to-run-a-query-with-the-properties-from-a-stored-document/67222/1 "2016-11-25T22:41:29Z")

</div>

Let's say we have a index with docs which contain the following fields: uid, gender and hobbies. How can I run a query to find similarities between 1 and the other users, without having to retrieve the user first and then run a new query with his hobbies? I also want to include a must query which contains the opposite gender.

I know about the more like this query, but AFAIK it is not possible to directly access the stored doc values.

Is this possible with painless?

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [November 26, 2016, 12:41am UTC](https://discuss.elastic.co/t/how-to-run-a-query-with-the-properties-from-a-stored-document/67222/2 "2016-11-26T00:41:20Z")

</div>

This is what Graph is really good at, but there's no single query in ES that can do this.

---

<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:** [December 24, 2016, 12:41am UTC](https://discuss.elastic.co/t/how-to-run-a-query-with-the-properties-from-a-stored-document/67222/3 "2016-12-24T00:41:27Z")

</div>

Closed on December 24, 2016, 12:41am UTC

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