# ElasticSearch: search document pairs by specific query?

**URL:** <https://discuss.elastic.co/t/elasticsearch-search-document-pairs-by-specific-query/17815>\
**Category:** Elasticsearch\
**Created:** [May 29, 2014, 5:26pm UTC](https://discuss.elastic.co/t/elasticsearch-search-document-pairs-by-specific-query/17815 "2014-05-29T17:26:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alexey\_Shevchenko](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alexey_shevchenko/32/1539_2.png) [@Alexey\_Shevchenko](https://discuss.elastic.co/u/Alexey_Shevchenko)\
**Post date:** [May 29, 2014, 5:26pm UTC](https://discuss.elastic.co/t/elasticsearch-search-document-pairs-by-specific-query/17815/1 "2014-05-29T17:26:19Z")

</div>

How to search for the document _pairs_ that matched to specific query[http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl.html](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl.html) (in  
my case it is more\_like\_this query[http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-mlt-query.html#query-dsl-mlt-query](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-mlt-query.html#query-dsl-mlt-query))  
and _order_ them using a specific field(s)?

Probably _pairs_ can be formed using aggregations[http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations.html](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations.html) but  
I can't figure out how.

Also have no idea if we even form such aggregated pairs then how to _order_  
them?  
Question is posted to stackoverflow, will appreciate if you answer there:  
[http://stackoverflow.com/questions/23938975/elasticsearch-search-document-pairs-by-specific-query](http://stackoverflow.com/questions/23938975/elasticsearch-search-document-pairs-by-specific-query)

Thanks.

--  
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/6e877ffe-3450-4e76-89c9-9fd8ecea0cd8%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/6e877ffe-3450-4e76-89c9-9fd8ecea0cd8%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:26am UTC](https://discuss.elastic.co/t/elasticsearch-search-document-pairs-by-specific-query/17815/2 "2017-07-06T01:26:04Z")

</div>


