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


Java SearchHit.getId方法代碼示例

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


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

示例1: fromSearchHit

import org.elasticsearch.search.SearchHit; //導入方法依賴的package包/類
public static Object fromSearchHit(SearchHit searchHit) {
    ElasticsearchDocumentType dt = ElasticsearchDocumentType.fromSearchHit(searchHit);
    if (dt == null) {
        return null;
    }
    switch (dt) {
        case EDGE:
        case VERTEX:
            return searchHit.getId();
        case EDGE_EXTENDED_DATA:
        case VERTEX_EXTENDED_DATA:
            return ElasticsearchExtendedDataIdUtils.fromSearchHit(searchHit);
        default:
            throw new MemgraphException("Unhandled document type: " + dt);
    }
}
 
開發者ID:mware-solutions,項目名稱:memory-graph,代碼行數:17,代碼來源:ElasticsearchDocIdUtils.java

示例2: convert

import org.elasticsearch.search.SearchHit; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
@Override
protected T convert(SearchHit hit) {
    ElasticsearchDocumentType dt = ElasticsearchDocumentType.fromSearchHit(hit);
    T convertedId = null;
    if (dt != null) {
        String id = hit.getId();
        switch (dt) {
            case VERTEX:
            case EDGE:
                convertedId = (T) id;
                break;
            case VERTEX_EXTENDED_DATA:
            case EDGE_EXTENDED_DATA:
                convertedId = (T) ElasticsearchExtendedDataIdUtils.fromSearchHit(hit);
                break;
            default:
                LOGGER.warn("Unhandled document type: %s", dt);
                break;
        }
    }
    return convertedId;
}
 
開發者ID:mware-solutions,項目名稱:memory-graph,代碼行數:24,代碼來源:ElasticsearchGraphQueryIdIterable.java

示例3: assertRealtimeGetWorks

import org.elasticsearch.search.SearchHit; //導入方法依賴的package包/類
void assertRealtimeGetWorks(String indexName) {
    assertAcked(client().admin().indices().prepareUpdateSettings(indexName).setSettings(Settings.builder()
            .put("refresh_interval", -1)
            .build()));
    SearchRequestBuilder searchReq = client().prepareSearch(indexName).setQuery(QueryBuilders.matchAllQuery());
    SearchHit hit = searchReq.get().getHits().getAt(0);
    String docId = hit.getId();
    // foo is new, it is not a field in the generated index
    client().prepareUpdate(indexName, "doc", docId).setDoc(Requests.INDEX_CONTENT_TYPE, "foo", "bar").get();
    GetResponse getRsp = client().prepareGet(indexName, "doc", docId).get();
    Map<String, Object> source = getRsp.getSourceAsMap();
    assertThat(source, Matchers.hasKey("foo"));

    assertAcked(client().admin().indices().prepareUpdateSettings(indexName).setSettings(Settings.builder()
            .put("refresh_interval", IndexSettings.DEFAULT_REFRESH_INTERVAL)
            .build()));
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:18,代碼來源:OldIndexBackwardsCompatibilityIT.java

示例4: deleteAllByQuery

import org.elasticsearch.search.SearchHit; //導入方法依賴的package包/類
public void deleteAllByQuery(String index, String type, QueryBuilder query) {
  createBulkProcessor();
  SearchResponse scrollResp = getClient().prepareSearch(index).setSearchType(SearchType.QUERY_AND_FETCH).setTypes(type).setScroll(new TimeValue(60000)).setQuery(query).setSize(10000).execute()
      .actionGet();

  while (true) {
    for (SearchHit hit : scrollResp.getHits().getHits()) {
      DeleteRequest deleteRequest = new DeleteRequest(index, type, hit.getId());
      getBulkProcessor().add(deleteRequest);
    }

    scrollResp = getClient().prepareSearchScroll(scrollResp.getScrollId()).setScroll(new TimeValue(600000)).execute().actionGet();
    if (scrollResp.getHits().getHits().length == 0) {
      break;
    }

  }
  destroyBulkProcessor();
}
 
開發者ID:apache,項目名稱:incubator-sdap-mudrod,代碼行數:20,代碼來源:ESDriver.java

示例5: deleteES

import org.elasticsearch.search.SearchHit; //導入方法依賴的package包/類
private static void deleteES(Client client) {
  BulkRequestBuilder bulkRequest = client.prepareBulk();
  SearchResponse response = client.prepareSearch(index).setTypes(type)
      .setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
      .setQuery(QueryBuilders.matchAllQuery())
      .setFrom(0).setSize(20).setExplain(true).execute().actionGet();
  System.out.println("length: " + response.getHits().getHits().length);
  if (response.getHits().getHits().length != 0) {
    for (SearchHit hit : response.getHits()) {
      String id = hit.getId();
      System.out.println("id: " + id);
      bulkRequest.add(client.prepareDelete(index, type, id).request());
    }
    BulkResponse bulkResponse = bulkRequest.get();
    if (bulkResponse.hasFailures()) {
      for (BulkItemResponse item : bulkResponse.getItems()) {
        System.out.println(item.getFailureMessage());
      }
    } else {
      System.out.println("delete ok");
    }
  } else {
    System.out.println("delete ok");
  }
}
 
開發者ID:MoneZhao,項目名稱:elasticsearch,代碼行數:26,代碼來源:App.java

示例6: Ids

import org.elasticsearch.search.SearchHit; //導入方法依賴的package包/類
public Ids(SearchHits hits) {
    vertexIds = new ArrayList<>();
    edgeIds = new ArrayList<>();
    extendedDataIds = new ArrayList<>();
    ids = new ArrayList<>();
    for (SearchHit hit : hits) {
        ElasticsearchDocumentType dt = ElasticsearchDocumentType.fromSearchHit(hit);
        if (dt == null) {
            continue;
        }
        String id = hit.getId();
        switch (dt) {
            case VERTEX:
                ids.add(id);
                vertexIds.add(id);
                break;
            case EDGE:
                ids.add(id);
                edgeIds.add(id);
                break;
            case VERTEX_EXTENDED_DATA:
            case EDGE_EXTENDED_DATA:
                ids.add(id);
                extendedDataIds.add(ElasticsearchExtendedDataIdUtils.fromSearchHit(hit));
                break;
            default:
                LOGGER.warn("Unhandled document type: %s", dt);
                break;
        }
    }
}
 
開發者ID:mware-solutions,項目名稱:memory-graph,代碼行數:32,代碼來源:ElasticsearchSearchQueryBase.java

示例7: getMergedHit

import org.elasticsearch.search.SearchHit; //導入方法依賴的package包/類
private InternalSearchHit getMergedHit(int currentCombinedResults, String t1Alias, String t2Alias, SearchHit hitFromFirstTable, SearchHit matchedHit) {
    onlyReturnedFields(matchedHit.sourceAsMap(), nestedLoopsRequest.getSecondTable().getReturnedFields(),nestedLoopsRequest.getSecondTable().getOriginalSelect().isSelectAll());
    InternalSearchHit searchHit = new InternalSearchHit(currentCombinedResults, hitFromFirstTable.id() + "|" + matchedHit.getId(), new Text(hitFromFirstTable.getType() + "|" + matchedHit.getType()), hitFromFirstTable.getFields());
    searchHit.sourceRef(hitFromFirstTable.getSourceRef());
    searchHit.sourceAsMap().clear();
    searchHit.sourceAsMap().putAll(hitFromFirstTable.sourceAsMap());

    mergeSourceAndAddAliases(matchedHit.getSource(), searchHit, t1Alias, t2Alias);
    return searchHit;
}
 
開發者ID:mazhou,項目名稱:es-sql,代碼行數:11,代碼來源:NestedLoopsElasticExecutor.java


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