# Find documents where field "transaction" is the same as in the document where another fields equals something

**URL:** <https://discuss.elastic.co/t/find-documents-where-field-transaction-is-the-same-as-in-the-document-where-another-fields-equals-something/126337>\
**Category:** Elasticsearch\
**Created:** [March 31, 2018, 8:07pm UTC](https://discuss.elastic.co/t/find-documents-where-field-transaction-is-the-same-as-in-the-document-where-another-fields-equals-something/126337 "2018-03-31T20:07:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vb4t](https://avatars.discourse-cdn.com/v4/letter/v/a698b9/32.png) [@vb4t](https://discuss.elastic.co/u/vb4t)\
**Post date:** [March 31, 2018, 8:07pm UTC](https://discuss.elastic.co/t/find-documents-where-field-transaction-is-the-same-as-in-the-document-where-another-fields-equals-something/126337/1 "2018-03-31T20:07:35Z")

</div>

Hello. I have following documents:

doc1\> transaction:1, initiator:john, info:somedata  
doc2\> transaction:1, info: anotherdata  
doc3\> transaction:1, info: anotherdata

I need to return all documents where transaction id is the same as the transaction id where field initiator is "john".

Is it possible? How?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 31, 2018, 9:30pm UTC](https://discuss.elastic.co/t/find-documents-where-field-transaction-is-the-same-as-in-the-document-where-another-fields-equals-something/126337/2 "2018-03-31T21:30:11Z")

</div>

May be with parent/child feature.  
Or field collapsing.

But I'd better recommend denormalizing your data.

If the primary object you are searching for is a transaction, index a transaction and not a sub part of a transaction.

My 0.02 cents

---

<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:** [April 28, 2018, 9:30pm UTC](https://discuss.elastic.co/t/find-documents-where-field-transaction-is-the-same-as-in-the-document-where-another-fields-equals-something/126337/3 "2018-04-28T21:30:35Z")

</div>

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