本文整理汇总了Java中org.elasticsearch.action.get.GetRequestBuilder.get方法的典型用法代码示例。如果您正苦于以下问题:Java GetRequestBuilder.get方法的具体用法?Java GetRequestBuilder.get怎么用?Java GetRequestBuilder.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.elasticsearch.action.get.GetRequestBuilder
的用法示例。
在下文中一共展示了GetRequestBuilder.get方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getInstance
import org.elasticsearch.action.get.GetRequestBuilder; //导入方法依赖的package包/类
@Override public Instance getInstance(int instanceId) {
logger.debug("get instance info, instance id: {}", instanceId);
GetRequestBuilder requestBuilder = getClient().prepareGet(InstanceTable.TABLE, String.valueOf(instanceId));
GetResponse getResponse = requestBuilder.get();
if (getResponse.isExists()) {
Instance instance = new Instance();
instance.setId(getResponse.getId());
instance.setApplicationId(((Number)getResponse.getSource().get(InstanceTable.COLUMN_APPLICATION_ID)).intValue());
instance.setAgentUUID((String)getResponse.getSource().get(InstanceTable.COLUMN_AGENT_UUID));
instance.setRegisterTime(((Number)getResponse.getSource().get(InstanceTable.COLUMN_REGISTER_TIME)).longValue());
instance.setHeartBeatTime(((Number)getResponse.getSource().get(InstanceTable.COLUMN_HEARTBEAT_TIME)).longValue());
instance.setOsInfo((String)getResponse.getSource().get(InstanceTable.COLUMN_OS_INFO));
return instance;
}
return null;
}
示例2: getById
import org.elasticsearch.action.get.GetRequestBuilder; //导入方法依赖的package包/类
@Override
public <T> T getById(Class<T> clazz, String id, @Nullable String routing) {
String typeName = MappingProcessor.getIndexTypeName(clazz);
if (logger.isDebugEnabled()) {
logger.debug("Get object by id, class: {}, type: {}, id: {}, routing: {}", clazz.getSimpleName(), typeName, id, routing);
}
GetRequestBuilder getRequest = client.prepareGet(getIndexName(), typeName, id);
if (routing != null) {
getRequest.setRouting(routing);
}
GetResponse response = getRequest.get();
if (!response.isExists()) {
return null;
}
return objectProcessor.fromJsonString(response.getSourceAsString(), clazz);
}
示例3: getDocument
import org.elasticsearch.action.get.GetRequestBuilder; //导入方法依赖的package包/类
private GetResponse getDocument(String index, String type, String docId, String field, @Nullable String routing) {
GetRequestBuilder getRequestBuilder = client().prepareGet().setIndex(index).setType(type).setId(docId).setStoredFields(field);
if (routing != null) {
getRequestBuilder.setRouting(routing);
}
return getRequestBuilder.get();
}
示例4: documentExists
import org.elasticsearch.action.get.GetRequestBuilder; //导入方法依赖的package包/类
public boolean documentExists(final String index, final String type, final String id) {
LOGGER.trace("Checking for existence of document: '{}/{}/{}'", index, type, id);
GetRequestBuilder builder = client.prepareGet()
.setIndex(index)
.setType(type)
.setId(id)
.setFields(new String[] {});
addCommonHeaders(builder);
GetResponse response = builder.get();
final boolean exists = response.isExists();
LOGGER.trace("Document '{}/{}/{}' exists? {}", index, type, id, exists);
return exists;
}
示例5: getAddress
import org.elasticsearch.action.get.GetRequestBuilder; //导入方法依赖的package包/类
@Override public String getAddress(int addressId) {
logger.debug("get network address, address id: {}", addressId);
ElasticSearchClient client = getClient();
GetRequestBuilder getRequestBuilder = client.prepareGet(NetworkAddressTable.TABLE, String.valueOf(addressId));
GetResponse getResponse = getRequestBuilder.get();
if (getResponse.isExists()) {
return (String)getResponse.getSource().get(NetworkAddressTable.COLUMN_NETWORK_ADDRESS);
}
return Const.EMPTY_STRING;
}
示例6: getServiceName
import org.elasticsearch.action.get.GetRequestBuilder; //导入方法依赖的package包/类
@Override public String getServiceName(int serviceId) {
GetRequestBuilder getRequestBuilder = getClient().prepareGet(ServiceNameTable.TABLE, String.valueOf(serviceId));
GetResponse getResponse = getRequestBuilder.get();
if (getResponse.isExists()) {
String serviceName = (String)getResponse.getSource().get(ServiceNameTable.COLUMN_SERVICE_NAME);
int applicationId = ((Number)getResponse.getSource().get(ServiceNameTable.COLUMN_APPLICATION_ID)).intValue();
return applicationId + Const.ID_SPLIT + serviceName;
}
return Const.EMPTY_STRING;
}
示例7: getApplicationCode
import org.elasticsearch.action.get.GetRequestBuilder; //导入方法依赖的package包/类
@Override public String getApplicationCode(int applicationId) {
logger.debug("get application code, applicationId: {}", applicationId);
ElasticSearchClient client = getClient();
GetRequestBuilder getRequestBuilder = client.prepareGet(ApplicationTable.TABLE, String.valueOf(applicationId));
GetResponse getResponse = getRequestBuilder.get();
if (getResponse.isExists()) {
return (String)getResponse.getSource().get(ApplicationTable.COLUMN_APPLICATION_CODE);
}
return Const.EMPTY_STRING;
}