當前位置: 首頁>>代碼示例>>Java>>正文


Java GetResponse.getId方法代碼示例

本文整理匯總了Java中org.elasticsearch.action.get.GetResponse.getId方法的典型用法代碼示例。如果您正苦於以下問題:Java GetResponse.getId方法的具體用法?Java GetResponse.getId怎麽用?Java GetResponse.getId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.elasticsearch.action.get.GetResponse的用法示例。


在下文中一共展示了GetResponse.getId方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getIndex

import org.elasticsearch.action.get.GetResponse; //導入方法依賴的package包/類
/**
 * 獲取索引信息
 * @param index
 * @param type
 * @param id
 */
private static void getIndex(String index, String type, String id){
	Client client = createTransportClient();
	GetResponse response = client.prepareGet(index, type, id)
	        .execute()
	        .actionGet();
	boolean exists = response.isExists();
	System.out.println(exists);// 判斷索引是否存在
	String sourceString = response.getSourceAsString();
	System.out.println(sourceString);// 獲取索引,並且打印出索引內容
	System.out.println("****************index ***********************");
	// Index name
	String _index = response.getIndex();
	// Type name
	String _type = response.getType();
	// Document ID (generated or not)
	String _id = response.getId();
	// Version (if it's the first time you index this document, you will get: 1)
	long _version = response.getVersion();
	System.out.println(_index+","+_type+","+_id+","+_version);
}
 
開發者ID:ameizi,項目名稱:elasticsearch-jest-example,代碼行數:27,代碼來源:TransportClient.java

示例2: executePrimaryKeyLookupQuery

import org.elasticsearch.action.get.GetResponse; //導入方法依賴的package包/類
@Override
protected Row executePrimaryKeyLookupQuery(Table table, List<SelectItem> selectItems, Column primaryKeyColumn,
        Object keyValue) {
    if (keyValue == null) {
        return null;
    }

    final String documentType = table.getName();
    final String id = keyValue.toString();

    final GetResponse response = getElasticSearchClient().prepareGet(indexName, documentType, id).execute().actionGet();

    if (!response.isExists()) {
        return null;
    }

    final Map<String, Object> source = response.getSource();
    final String documentId = response.getId();

    final DataSetHeader header = new SimpleDataSetHeader(selectItems);

    return ElasticSearchUtils.createRow(source, documentId, header);
}
 
開發者ID:apache,項目名稱:metamodel,代碼行數:24,代碼來源:ElasticSearchDataContext.java

示例3: parse

import org.elasticsearch.action.get.GetResponse; //導入方法依賴的package包/類
private ElasticSearchDoc parse(final GetResponse response) {
    ElasticSearchDoc result = null;
    if (response.isExists()) {
        final Map<String, Object> responseMap = response.getSourceAsMap();
        final String user = (String) responseMap.get(ElasticSearchDoc.Field.USER);
        final boolean deleted = (boolean) responseMap.get(ElasticSearchDoc.Field.DELETED);
        final long timestamp = (long) responseMap.get(ElasticSearchDoc.Field.TIMESTAMP);
        @SuppressWarnings("unchecked") final Object dto = metacatJson.parseJsonValue(
            response.getSourceAsBytes(),
            getClass(response.getType())
        );
        result = new ElasticSearchDoc(response.getId(), dto, user, deleted, timestamp);
    }
    return result;
}
 
開發者ID:Netflix,項目名稱:metacat,代碼行數:16,代碼來源:ElasticSearchUtilImpl.java

示例4: getById

import org.elasticsearch.action.get.GetResponse; //導入方法依賴的package包/類
@RequestMapping(apiTemplate + "getDocument/{index}/{type}/{id}")
public Document getById(@PathVariable(value="index") String index, 
		@PathVariable(value="type") String type,
		@PathVariable(value="id") String id) {
	GetResponse response = client.prepareGet(index, type, id).get();
	return new Document(response.getId(), response.getIndex(), response.getType(), response.getSource());
}
 
開發者ID:gov-ithub,項目名稱:romanescU-spring-api,代碼行數:8,代碼來源:ElasticsearchController.java

示例5: getCourse

import org.elasticsearch.action.get.GetResponse; //導入方法依賴的package包/類
private Course getCourse(String courseId, Credentials credentials) {
	GetResponse response = Start.get().getElasticClient()//
			.get(credentials.backendId(), COURSE, courseId);

	Course course = Json7.toPojo(response.getSourceAsString(), Course.class);
	course.meta.id = response.getId();
	course.meta.type = "course";
	course.meta.version = response.getVersion();

	return course;
}
 
開發者ID:spacedog-io,項目名稱:spacedog-server,代碼行數:12,代碼來源:CaremenResource.java

示例6: fromGetResponse

import org.elasticsearch.action.get.GetResponse; //導入方法依賴的package包/類
public static PersistentObject fromGetResponse(PersistentContainer container, GetResponse getResponse) {

        String id = getResponse.getId();
        long persistentVersion = getResponse.getVersion();
        JsonObject document = new JsonObject(getResponse.getSourceAsString());

        return new PersistentObject(container, id, persistentVersion)
                .merge(document);

    }
 
開發者ID:pitchpoint-solutions,項目名稱:sfs,代碼行數:11,代碼來源:PersistentObject.java


注:本文中的org.elasticsearch.action.get.GetResponse.getId方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。