Correlating Documents Based On Unique Field

Good Afternoon,
I have a question about correlating documents based on a search term that only exists in some of the results. Our data has two unique identifiers. The first one (X) exists throughout the lifetime of the message as it progresses through our system. The second identifier (Y), is assigned about halfway through the system and is the ID that users are able to search on. My question is, how can I display all of the documents with a given X identifier but only search on Y? Essentially I need Elasticsearch to use select the X value of the document that matches Y and return all of the results with that unique X value. I apologize in advance if I'm not explaining this very clearly.
Thank you for the help!

Any help with this? I'm having a really hard time finding a way to make this work.