# Java API: Requesting fields from SearchShardTarget and docId

**URL:** <https://discuss.elastic.co/t/java-api-requesting-fields-from-searchshardtarget-and-docid/5298>\
**Category:** Elasticsearch\
**Created:** [September 1, 2011, 8:05pm UTC](https://discuss.elastic.co/t/java-api-requesting-fields-from-searchshardtarget-and-docid/5298 "2011-09-01T20:05:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jurgen\_kartnaller](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jurgen_kartnaller/32/3086_2.png) [@Jurgen\_kartnaller](https://discuss.elastic.co/u/Jurgen_kartnaller)\
**Post date:** [September 1, 2011, 8:05pm UTC](https://discuss.elastic.co/t/java-api-requesting-fields-from-searchshardtarget-and-docid/5298/1 "2011-09-01T20:05:17Z")

</div>

We are implementing a lot of facets for our use cases.

We have one facet which in the end provides a small list of documents.  
In the final reduce step in the facet processor we want to enrich the result  
by fetching additional fields for the documents in the facets.

What we have as the reference to the document is the SearchShardTarget and  
the docId.

How can I fetch fields using SearchShardTarget and the docId?

Jürgen

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [September 1, 2011, 8:11pm UTC](https://discuss.elastic.co/t/java-api-requesting-fields-from-searchshardtarget-and-docid/5298/2 "2011-09-01T20:11:32Z")

</div>

That reduce is executing on a different node probably, so you don't have  
access to the other nodes there to go and fetch more data. It requires  
building an API for that, and making sure it uses the same context when  
going to the remote shard and fetching relevant data.

On Thu, Sep 1, 2011 at 11:05 PM, Jürgen kartnaller \<  
[juergen.kartnaller@gmail.com](mailto:juergen.kartnaller@gmail.com)\> wrote:

> We are implementing a lot of facets for our use cases.
> 
> We have one facet which in the end provides a small list of documents.  
> In the final reduce step in the facet processor we want to enrich the  
> result by fetching additional fields for the documents in the facets.
> 
> What we have as the reference to the document is the SearchShardTarget and  
> the docId.
> 
> How can I fetch fields using SearchShardTarget and the docId?
> 
> Jürgen

---

<div class="post-metadata">

**Author:** ![Jurgen\_kartnaller](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jurgen_kartnaller/32/3086_2.png) [@Jurgen\_kartnaller](https://discuss.elastic.co/u/Jurgen_kartnaller)\
**Post date:** [September 2, 2011, 5:56am UTC](https://discuss.elastic.co/t/java-api-requesting-fields-from-searchshardtarget-and-docid/5298/3 "2011-09-02T05:56:08Z")

</div>

I thought of a solution like query\_then\_fetch. But that code seems to be  
really complex, so thats maybe the code to put in an API?

What I want to avoid is reading the document fields on each node using the  
reader because then I read more data than needed which makes the facet slow.

Jürgen

On Thu, Sep 1, 2011 at 10:11 PM, Shay Banon [kimchy@gmail.com](mailto:kimchy@gmail.com) wrote:

> That reduce is executing on a different node probably, so you don't have  
> access to the other nodes there to go and fetch more data. It requires  
> building an API for that, and making sure it uses the same context when  
> going to the remote shard and fetching relevant data.
> 
> On Thu, Sep 1, 2011 at 11:05 PM, Jürgen kartnaller \<  
> [juergen.kartnaller@gmail.com](mailto:juergen.kartnaller@gmail.com)\> wrote:
> 
> > We are implementing a lot of facets for our use cases.
> > 
> > We have one facet which in the end provides a small list of documents.  
> > In the final reduce step in the facet processor we want to enrich the  
> > result by fetching additional fields for the documents in the facets.
> > 
> > What we have as the reference to the document is the SearchShardTarget and  
> > the docId.
> > 
> > How can I fetch fields using SearchShardTarget and the docId?
> > 
> > Jürgen

--  
[http://www.sfgdornbirn.at](http://www.sfgdornbirn.at)  
[http://www.mcb-bregenz.at](http://www.mcb-bregenz.at)

---

<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, 3:55am UTC](https://discuss.elastic.co/t/java-api-requesting-fields-from-searchshardtarget-and-docid/5298/4 "2017-07-06T03:55:18Z")

</div>

Closed on July 6, 2017, 3:55am UTC


