本文整理汇总了Java中org.elasticsearch.action.get.MultiGetItemResponse.getResponse方法的典型用法代码示例。如果您正苦于以下问题:Java MultiGetItemResponse.getResponse方法的具体用法?Java MultiGetItemResponse.getResponse怎么用?Java MultiGetItemResponse.getResponse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.elasticsearch.action.get.MultiGetItemResponse
的用法示例。
在下文中一共展示了MultiGetItemResponse.getResponse方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: queryByMultiGet
import org.elasticsearch.action.get.MultiGetItemResponse; //导入方法依赖的package包/类
/**
* 获取多个对象(根据ID)
*
* @param transportClient
* @throws IOException
*/
private static void queryByMultiGet(TransportClient transportClient) throws IOException {
MultiGetResponse multiGetItemResponses = transportClient.prepareMultiGet()
.add("product_index", "product", "1")
.add("product_index", "product", "2")
.add("product_index", "product", "3")
.add("product_index", "product", "4")
.add("product_index", "product", "5")
.get();
String resultJSON = null;
for (MultiGetItemResponse multiGetItemResponse : multiGetItemResponses) {
GetResponse getResponse = multiGetItemResponse.getResponse();
if (getResponse.isExists()) {
resultJSON = getResponse.getSourceAsString();
}
}
logger.info("--------------------------------:" + resultJSON);
}
示例2: getByIds
import org.elasticsearch.action.get.MultiGetItemResponse; //导入方法依赖的package包/类
@Override
public <T> List<T> getByIds(Class<T> clazz, List<String> ids) {
String typeName = MappingProcessor.getIndexTypeName(clazz);
if (logger.isDebugEnabled()) {
logger.debug("Get objects by ids, class: {}, type: {}, ids: {}", clazz.getSimpleName(), typeName, ids);
}
MultiGetResponse responses = client.prepareMultiGet().add(getIndexName(), typeName, ids).get();
List<T> results = new ArrayList<T>();
if (responses != null) {
for (MultiGetItemResponse response : responses) {
if (response.getResponse() != null) {
results.add(objectProcessor.fromJsonString(response.getResponse().getSourceAsString(), clazz));
}
}
}
return results;
}
示例3: existBulk
import org.elasticsearch.action.get.MultiGetItemResponse; //导入方法依赖的package包/类
public Set<String> existBulk(String indexName, String typeName, final Collection<String> ids) {
if (ids == null || ids.size() == 0) return new HashSet<>();
MultiGetResponse multiGetItemResponses = elasticsearchClient.prepareMultiGet()
.add(indexName, typeName, ids)
.get();
Set<String> er = new HashSet<>();
for (MultiGetItemResponse itemResponse : multiGetItemResponses) {
GetResponse response = itemResponse.getResponse();
if (response.isExists()) {
er.add(response.getId());
}
}
return er;
}
示例4: MultiGet
import org.elasticsearch.action.get.MultiGetItemResponse; //导入方法依赖的package包/类
private static void MultiGet(Client client) {
MultiGetResponse response = client.prepareMultiGet()
.add("twitter","tweet","2","1")
.get();
for(MultiGetItemResponse itemResponse:response){
GetResponse getResponse = itemResponse.getResponse();
if(getResponse.isExists()){
System.out.println(getResponse.getSourceAsString());
}
}
}
示例5: name
import org.elasticsearch.action.get.MultiGetItemResponse; //导入方法依赖的package包/类
@Test
public void name() throws Exception {
MultiGetResponse multiGetItemResponses = client.prepareMultiGet()
.add("twitter", "tweet", "1")
.add("twitter", "tweet", "2", "3", "4")
.add("another", "type", "foo")
.get();
for (MultiGetItemResponse itemResponse : multiGetItemResponses) {
GetResponse response = itemResponse.getResponse();
if (response.isExists()) {
String json = response.getSourceAsString();
}
}
}
示例6: findAll
import org.elasticsearch.action.get.MultiGetItemResponse; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public List<T> findAll(final List<String> ids) {
if (ids.isEmpty()) {
return ImmutableList.of();
}
final Builder<T> builder = ImmutableList.builder();
final MultiGetResponse response = client
.prepareMultiGet()
.add(index, type, ids)
.execute()
.actionGet();
for(final MultiGetItemResponse item : response.getResponses()) {
final GetResponse get = item.getResponse();
if(get.isSourceEmpty()) {
continue;
}
final String json = get.getSourceAsString();
final T entity = deserializer.apply(json);
builder.add((T) entity.withId(get.getId()));
}
return builder.build();
}
示例7: containsKibanaUserIndex
import org.elasticsearch.action.get.MultiGetItemResponse; //导入方法依赖的package包/类
private boolean containsKibanaUserIndex(ActionResponse response) {
String index = "";
if (response instanceof MultiGetResponse) {
for (MultiGetItemResponse item : ((MultiGetResponse) response).getResponses()) {
GetResponse itemResponse = item.getResponse();
Failure itemFailure = item.getFailure();
if (itemResponse == null) {
if (isKibanaUserIndex(itemFailure.getIndex())) {
return true;
}
} else {
if (isKibanaUserIndex(itemResponse.getIndex())) {
return true;
}
}
}
return false;
}
if (response instanceof IndexResponse) {
index = ((IndexResponse) response).getIndex();
} else if (response instanceof GetResponse) {
index = ((GetResponse) response).getIndex();
} else if (response instanceof DeleteResponse) {
index = ((DeleteResponse) response).getIndex();
} else if (response instanceof GetFieldMappingsResponse) {
ImmutableMap<String, ImmutableMap<String, ImmutableMap<String, FieldMappingMetaData>>> mappings = ((GetFieldMappingsResponse) response)
.mappings();
for (String key : mappings.keySet()) {
index = key;
}
}
return isKibanaUserIndex(index);
}
示例8: testMultiGet
import org.elasticsearch.action.get.MultiGetItemResponse; //导入方法依赖的package包/类
@Test
public void testMultiGet() {
MultiGetResponse multiGetItemResponses = client.prepareMultiGet().add("twitter", "tweet", "1").add("twitter", "tweet", "2", "3", "4")
.add("another", "type", "foo").get();
for (MultiGetItemResponse itemResponse : multiGetItemResponses) {
GetResponse response = itemResponse.getResponse();
if (response.isExists()) {
String json = response.getSourceAsString();
System.out.println(json);
}
}
}