# Getting local nodeID with Java API from within native script

**URL:** <https://discuss.elastic.co/t/getting-local-nodeid-with-java-api-from-within-native-script/13769>\
**Category:** Elasticsearch\
**Created:** [September 26, 2013, 6:45pm UTC](https://discuss.elastic.co/t/getting-local-nodeid-with-java-api-from-within-native-script/13769 "2013-09-26T18:45:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Clarence\_Chio](https://avatars.discourse-cdn.com/v4/letter/c/58956e/32.png) [@Clarence\_Chio](https://discuss.elastic.co/u/Clarence_Chio)\
**Post date:** [September 26, 2013, 6:45pm UTC](https://discuss.elastic.co/t/getting-local-nodeid-with-java-api-from-within-native-script/13769/1 "2013-09-26T18:45:45Z")

</div>

Hi all,

I'm having trouble getting the local nodeID with the Java API from within a  
native script.

What I want is to have my native script return only documents present  
locally on the node, so I can perform some operations on them.

My plan of execution is to get the local nodeID, then create a node using  
nodeBuilder within the native script and execute a search with the search  
preferences "\_only\_node:nodeID" as part of my search criterion.

This will hopefully achieve the result I am looking for.

Does anyone have any experience doing something similar with the Java API?

Thank you.

--  
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:14am UTC](https://discuss.elastic.co/t/getting-local-nodeid-with-java-api-from-within-native-script/13769/2 "2017-07-06T02:14:33Z")

</div>


