# How to get '\_node' field for hit without "explain=true"?

**URL:** <https://discuss.elastic.co/t/how-to-get--node-field-for-hit-without-explain-true/14184>\
**Category:** Elasticsearch\
**Created:** [October 31, 2013, 6:24am UTC](https://discuss.elastic.co/t/how-to-get--node-field-for-hit-without-explain-true/14184 "2013-10-31T06:24:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Artem\_Shpynov](https://avatars.discourse-cdn.com/v4/letter/a/ea666f/32.png) [@Artem\_Shpynov](https://discuss.elastic.co/u/Artem_Shpynov)\
**Post date:** [October 31, 2013, 6:24am UTC](https://discuss.elastic.co/t/how-to-get--node-field-for-hit-without-explain-true/14184/1 "2013-10-31T06:24:29Z")

</div>

Hi All,

Is there some way to get information which node hit come from?

I found that "explain" option can give such info, but there is huge  
overhead by unnecessary "\_explanation" field.

After source code investigation it is clear that information is come from \*  
InternalSearchHit.java:\*

```
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params

```

) throws IOException {  
builder.startObject();  
if (explanation() != null) {  
builder.field("\_shard", shard.shardId());  
builder.field("\_node",\* shard.nodeIdText\*());  
}  
...

Is it possible to get info from 'shard' object without code modification?  
For example by some script fields?

Best regards,

Artem Shpynov aka FYR

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [October 31, 2013, 7:56pm UTC](https://discuss.elastic.co/t/how-to-get--node-field-for-hit-without-explain-true/14184/2 "2013-10-31T19:56:00Z")

</div>

As you pointed out, the node and shard information is not reliant on the  
explanation info, only the access to the info uses a shared parameter. I  
would raise this as an issue on github that the coupling between the two  
concepts should be loosen. Perhaps another parameter that does not executes  
the somewhat heavyweight processing of the explanation. Useful information  
to have. My two cents. 🙂

Cheers,

Ivan

On Wed, Oct 30, 2013 at 11:24 PM, Artem Shpynov [ashpynov@gmail.com](mailto:ashpynov@gmail.com) wrote:

> Hi All,
> 
> Is there some way to get information which node hit come from?
> 
> I found that "explain" option can give such info, but there is huge  
> overhead by unnecessary "\_explanation" field.
> 
> After source code investigation it is clear that information is come from  
> _InternalSearchHit.java:_
> 
> ```
> @Override
> public XContentBuilder toXContent(XContentBuilder builder, Params
> 
> ```
> 
> params) throws IOException {  
> builder.startObject();  
> if (explanation() != null) {  
> builder.field("\_shard", shard.shardId());  
> builder.field("\_node",\* shard.nodeIdText\*());  
> }  
> ...
> 
> Is it possible to get info from 'shard' object without code modification?  
> For example by some script fields?
> 
> Best regards,
> 
> Artem Shpynov aka FYR
> 
> --  
> 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).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Artem\_Shpynov](https://avatars.discourse-cdn.com/v4/letter/a/ea666f/32.png) [@Artem\_Shpynov](https://discuss.elastic.co/u/Artem_Shpynov)\
**Post date:** [November 1, 2013, 5:26am UTC](https://discuss.elastic.co/t/how-to-get--node-field-for-hit-without-explain-true/14184/3 "2013-11-01T05:26:56Z")

</div>

Great,

I did it already due to kimchi suggestion. Please update

> <https://github.com/elastic/elasticsearch/issues/4022>
>
> Hi,
> I need to have information which node hit received from.
> Exactly the same as… "explain" does. But without "explanation", same manner an "\_index" field.
> 
> The way I found is to change InternalSearchHit.java:
> 
> @Override
> public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
> builder.startObject();
> if (explanation() != null) {
> builder.field("\_shard", shard.shardId());
> builder.field("\_node", shard.nodeIdText());
> }
> 
> just move builder.field("\_node", shard.nodeIdText()); out from braces (same as for index name).
> 
> But I'm looking for some method to do this without code modification.
> E.g.:
> 1. some access from script field,
> 2. or access by some plugin,
> 3. or the best from my opinion is to support \_shard, \_node, \_index and other "shard" object properties in "fields" clause.

BR,

Artem

четверг, 31 октября 2013 г., 23:56:00 UTC+4 пользователь Ivan Brusic  
написал:

> As you pointed out, the node and shard information is not reliant on the  
> explanation info, only the access to the info uses a shared parameter. I  
> would raise this as an issue on github that the coupling between the two  
> concepts should be loosen. Perhaps another parameter that does not executes  
> the somewhat heavyweight processing of the explanation. Useful information  
> to have. My two cents. 🙂
> 
> Cheers,
> 
> Ivan
> 
> On Wed, Oct 30, 2013 at 11:24 PM, Artem Shpynov \<[ashp...@gmail.com](mailto:ashp...@gmail.com)\<javascript:\>
> 
> > wrote:
> 
> > Hi All,
> > 
> > Is there some way to get information which node hit come from?
> > 
> > I found that "explain" option can give such info, but there is huge  
> > overhead by unnecessary "\_explanation" field.
> > 
> > After source code investigation it is clear that information is come from  
> > _InternalSearchHit.java:_
> > 
> > ```
> > @Override
> > public XContentBuilder toXContent(XContentBuilder builder, Params 
> > 
> > ```
> > 
> > params) throws IOException {  
> > builder.startObject();  
> > if (explanation() != null) {  
> > builder.field("\_shard", shard.shardId());  
> > builder.field("\_node",\* shard.nodeIdText\*());  
> > }  
> > ...
> > 
> > Is it possible to get info from 'shard' object without code  
> > modification? For example by some script fields?
> > 
> > Best regards,
> > 
> > Artem Shpynov aka FYR
> > 
> > --  
> > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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).  
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:09am UTC](https://discuss.elastic.co/t/how-to-get--node-field-for-hit-without-explain-true/14184/4 "2017-07-06T02:09:26Z")

</div>

Closed on July 6, 2017, 2:09am UTC


