Created
November 27, 2011 20:19
-
-
Save anonymous/1398083 to your computer and use it in GitHub Desktop.
JUnit test connecting to local ES node
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class EsNodeLocalTest { | |
@Test | |
public void testLocalEs() throws IOException, InterruptedException { | |
Settings esSettings = ImmutableSettings.settingsBuilder() | |
.put("path.data", pathData) | |
.put("id", "a23") | |
.build(); | |
NodeBuilder nBuilder = nodeBuilder().settings(esSettings); | |
nBuilder.local(true); | |
final Node node = nBuilder.build().start(); | |
Thread.sleep(3*1000); | |
Client esClient = new TransportClient().addTransportAddress(new LocalTransportAddress("a23")); | |
SearchRequestBuilder impl = esClient.prepareSearch("xxxindex"); | |
impl.setSearchType(SearchType.QUERY_THEN_FETCH); | |
impl.setTypes("xxxtype"); | |
impl.setFrom(1); | |
impl.setSize(5); | |
SearchResponse res = impl.execute().actionGet(); | |
LOG.info(res); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment