# Output query results to document and index immediately

**URL:** <https://discuss.elastic.co/t/output-query-results-to-document-and-index-immediately/14844>\
**Category:** Elasticsearch\
**Created:** [December 12, 2013, 9:43pm UTC](https://discuss.elastic.co/t/output-query-results-to-document-and-index-immediately/14844 "2013-12-12T21:43:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Joanna\_Kochaniak](https://avatars.discourse-cdn.com/v4/letter/j/a4c791/32.png) [@Joanna\_Kochaniak](https://discuss.elastic.co/u/Joanna_Kochaniak)\
**Post date:** [December 12, 2013, 9:43pm UTC](https://discuss.elastic.co/t/output-query-results-to-document-and-index-immediately/14844/1 "2013-12-12T21:43:43Z")

</div>

Does ES provide the ability to write the results (ids) of a query directly  
to a new document and index it, instead of passing them back to the client?  
Or is there a plugin that provides this functionality? We are running  
queries that randomize documents and we'd like to be able to rerun the same  
query several times. Writing the ids to a document allows us to use the terms  
lookup[http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-terms-filter.html#\_terms\_lookup\_mechanism](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-terms-filter.html#_terms_lookup_mechanism) query  
to quickly recreate the same randomization, without needing to pass the ids  
back and forth. However, for the initial query we still have to pull back  
all the ids, create a document, then pass that document back to ES. Because  
retrieving the ids takes so long, we'd like to skip that step.

--  
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/92c924e9-377d-4c9a-8f0a-cddb7eff9150%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/92c924e9-377d-4c9a-8f0a-cddb7eff9150%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Andrew\_Cholakian\_2](https://avatars.discourse-cdn.com/v4/letter/a/7ab992/32.png) [@Andrew\_Cholakian\_2](https://discuss.elastic.co/u/Andrew_Cholakian_2)\
**Post date:** [December 13, 2013, 5:00am UTC](https://discuss.elastic.co/t/output-query-results-to-document-and-index-immediately/14844/2 "2013-12-13T05:00:07Z")

</div>

So far as I know, there is no equivalent to a SQL statement that performs  
an INSERT based on a SELECT

* * *

Andrew Cholakian  
Developer, Found Hosted Elasticsearch  
www.found.no, @foundsays

On Thursday, December 12, 2013 1:43:43 PM UTC-8, Joanna Kochaniak wrote:

> Does ES provide the ability to write the results (ids) of a query directly  
> to a new document and index it, instead of passing them back to the client?  
> Or is there a plugin that provides this functionality? We are running  
> queries that randomize documents and we'd like to be able to rerun the same  
> query several times. Writing the ids to a document allows us to use the terms  
> lookup[http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-terms-filter.html#\_terms\_lookup\_mechanism](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-terms-filter.html#_terms_lookup_mechanism) query  
> to quickly recreate the same randomization, without needing to pass the ids  
> back and forth. However, for the initial query we still have to pull back  
> all the ids, create a document, then pass that document back to ES. Because  
> retrieving the ids takes so long, we'd like to skip that step.

--  
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/5de31c26-cadb-4b5d-928d-f36f57c73806%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/5de31c26-cadb-4b5d-928d-f36f57c73806%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:01am UTC](https://discuss.elastic.co/t/output-query-results-to-document-and-index-immediately/14844/3 "2017-07-06T02:01:33Z")

</div>


