Created
June 26, 2013 20:38
-
-
Save colinpollock/5871423 to your computer and use it in GitHub Desktop.
JestClient search authentication
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 static ClientConfig getClientConfig(String connectionUrl) { | |
ClientConfig clientConfig = new ClientConfig(); | |
LinkedHashSet<String> servers = new LinkedHashSet<String>(); | |
servers.add(connectionUrl); | |
clientConfig.getServerProperties().put(ClientConstants.SERVER_LIST, servers); | |
return clientConfig; | |
} | |
public static JestClient getClient(String connectionUrl) { | |
JestClientFactory factory = new JestClientFactory(); | |
factory.setClientConfig(getClientConfig(connectionUrl)); | |
return factory.getObject(); | |
} | |
QueryBuilder queryBuilder = QueryBuilders.termQuery("field", value); | |
Search search = new Search(Search.createQueryWithBuilder(queryBuilder.toString())); | |
search.addIndex(INDEX); | |
search.addType(TYPE); | |
getClientConfig(URL).execute(search); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment