本文整理汇总了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);
}
}
示例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;
}
示例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()));
}
示例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();
}
示例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");
}
}
示例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;
}
}
}
示例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;
}