本文整理汇总了Java中org.elasticsearch.search.internal.InternalSearchHits类的典型用法代码示例。如果您正苦于以下问题:Java InternalSearchHits类的具体用法?Java InternalSearchHits怎么用?Java InternalSearchHits使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
InternalSearchHits类属于org.elasticsearch.search.internal包,在下文中一共展示了InternalSearchHits类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: mockClient
import org.elasticsearch.search.internal.InternalSearchHits; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static Client mockClient(List<Map<String, Object>> dataToReturn,
SearchRequestBuilder builder) {
Client client = mock(Client.class);
InternalSearchHit[] internalHitsArr = new InternalSearchHit[dataToReturn.size()];
for (int i = 0; i < dataToReturn.size(); i++) {
Map<String, Object> data = dataToReturn.get(i);
InternalSearchHit hit = mock(InternalSearchHit.class);
internalHitsArr[i] = hit;
when(hit.getSource()).thenReturn(data);
when(hit.getId()).thenReturn(Integer.toString(i));
}
InternalSearchHits hits = new InternalSearchHits(internalHitsArr, internalHitsArr.length,
0);
SearchResponse response = mock(SearchResponse.class);
when(response.getHits()).thenReturn(hits);
ListenableActionFuture<SearchResponse> action = mock(ListenableActionFuture.class);
when(builder.execute()).thenReturn(action);
when(builder.setQuery(any(QueryBuilder.class))).thenReturn(builder);
when(action.actionGet()).thenReturn(response);
when(client.prepareSearch(anyString())).thenReturn(builder);
return client;
}
开发者ID:Hevelian,项目名称:hevelian-olastic,代码行数:27,代码来源:BaseProcessorTest.java
示例2: InternalTopHits
import org.elasticsearch.search.internal.InternalSearchHits; //导入依赖的package包/类
public InternalTopHits(String name, int from, int size, TopDocs topDocs, InternalSearchHits searchHits,
List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData) {
super(name, pipelineAggregators, metaData);
this.from = from;
this.size = size;
this.topDocs = topDocs;
this.searchHits = searchHits;
}
开发者ID:baidu,项目名称:Elasticsearch,代码行数:9,代码来源:InternalTopHits.java
示例3: run
import org.elasticsearch.search.internal.InternalSearchHits; //导入依赖的package包/类
@Override
public void run() throws IOException, SqlParseException {
SearchResponse firstResponse = this.multiQueryBuilder.getFirstSearchRequest().get();
SearchHit[] hits = firstResponse.getHits().hits();
List<InternalSearchHit> unionHits = new ArrayList<>(hits.length);
fillInternalSearchHits(unionHits,hits,this.multiQueryBuilder.getFirstTableFieldToAlias());
SearchResponse secondResponse = this.multiQueryBuilder.getSecondSearchRequest().get();
fillInternalSearchHits(unionHits,secondResponse.getHits().hits(),this.multiQueryBuilder.getSecondTableFieldToAlias());
int totalSize = unionHits.size();
InternalSearchHit[] unionHitsArr = unionHits.toArray(new InternalSearchHit[totalSize]);
this.results = new InternalSearchHits(unionHitsArr, totalSize,1.0f);
}
开发者ID:mazhou,项目名称:es-sql,代码行数:13,代码来源:UnionExecutor.java
示例4: run
import org.elasticsearch.search.internal.InternalSearchHits; //导入依赖的package包/类
public void run() throws IOException, SqlParseException {
long timeBefore = System.currentTimeMillis();
List<InternalSearchHit> combinedSearchHits = innerRun();
int resultsSize = combinedSearchHits.size();
InternalSearchHit[] hits = combinedSearchHits.toArray(new InternalSearchHit[resultsSize]);
this.results = new InternalSearchHits(hits, resultsSize,1.0f);
long joinTimeInMilli = System.currentTimeMillis() - timeBefore;
this.metaResults.setTookImMilli(joinTimeInMilli);
}
开发者ID:mazhou,项目名称:es-sql,代码行数:10,代码来源:ElasticJoinExecutor.java
示例5: topHitTest_WithInclude
import org.elasticsearch.search.internal.InternalSearchHits; //导入依赖的package包/类
@Test
public void topHitTest_WithInclude() throws IOException, SqlParseException, SQLFeatureNotSupportedException {
Aggregations result = query(String.format("select topHits('size'=3,age='desc',include=age) from %s/account group by gender ", TEST_INDEX));
List<Terms.Bucket> buckets = ((Terms) (result.asList().get(0))).getBuckets();
for (Terms.Bucket bucket : buckets){
InternalSearchHits hits = (InternalSearchHits) ((InternalTopHits) bucket.getAggregations().asList().get(0)).getHits();
for(SearchHit hit: hits ){
Set<String> fields = hit.sourceAsMap().keySet();
Assert.assertEquals(1,fields.size());
Assert.assertEquals("age",fields.toArray()[0]);
}
}
}
开发者ID:mazhou,项目名称:es-sql,代码行数:14,代码来源:AggregationTest.java
示例6: topHitTest_WithIncludeTwoFields
import org.elasticsearch.search.internal.InternalSearchHits; //导入依赖的package包/类
@Test
public void topHitTest_WithIncludeTwoFields() throws IOException, SqlParseException, SQLFeatureNotSupportedException {
Aggregations result = query(String.format("select topHits('size'=3,'include'='age,firstname',age='desc') from %s/account group by gender ", TEST_INDEX));
List<Terms.Bucket> buckets = ((Terms) (result.asList().get(0))).getBuckets();
for (Terms.Bucket bucket : buckets){
InternalSearchHits hits = (InternalSearchHits) ((InternalTopHits) bucket.getAggregations().asList().get(0)).getHits();
for(SearchHit hit: hits ){
Set<String> fields = hit.sourceAsMap().keySet();
Assert.assertEquals(2,fields.size());
Assert.assertTrue(fields.contains("age"));
Assert.assertTrue(fields.contains("firstname"));
}
}
}
开发者ID:mazhou,项目名称:es-sql,代码行数:15,代码来源:AggregationTest.java
示例7: topHitTest_WithExclude
import org.elasticsearch.search.internal.InternalSearchHits; //导入依赖的package包/类
@Test
public void topHitTest_WithExclude() throws IOException, SqlParseException, SQLFeatureNotSupportedException {
Aggregations result = query(String.format("select topHits('size'=3,'exclude'='lastname',age='desc') from %s/account group by gender ", TEST_INDEX));
List<Terms.Bucket> buckets = ((Terms) (result.asList().get(0))).getBuckets();
for (Terms.Bucket bucket : buckets){
InternalSearchHits hits = (InternalSearchHits) ((InternalTopHits) bucket.getAggregations().asList().get(0)).getHits();
for(SearchHit hit: hits ){
Set<String> fields = hit.sourceAsMap().keySet();
Assert.assertTrue(!fields.contains("lastname"));
}
}
}
开发者ID:mazhou,项目名称:es-sql,代码行数:13,代码来源:AggregationTest.java
示例8: topHitTest_WithIncludeAndExclude
import org.elasticsearch.search.internal.InternalSearchHits; //导入依赖的package包/类
@Test
public void topHitTest_WithIncludeAndExclude() throws IOException, SqlParseException, SQLFeatureNotSupportedException {
Aggregations result = query(String.format("select topHits('size'=3,'exclude'='lastname','include'='firstname,lastname',age='desc') from %s/account group by gender ", TEST_INDEX));
List<Terms.Bucket> buckets = ((Terms) (result.asList().get(0))).getBuckets();
for (Terms.Bucket bucket : buckets) {
InternalSearchHits hits = (InternalSearchHits) ((InternalTopHits) bucket.getAggregations().asList().get(0)).getHits();
for (SearchHit hit : hits) {
Set<String> fields = hit.sourceAsMap().keySet();
Assert.assertEquals(1, fields.size());
Assert.assertTrue(fields.contains("firstname"));
}
}
}
开发者ID:mazhou,项目名称:es-sql,代码行数:14,代码来源:AggregationTest.java
示例9: parseInternalSearchResponse
import org.elasticsearch.search.internal.InternalSearchHits; //导入依赖的package包/类
private InternalSearchResponse parseInternalSearchResponse(Map<String, ?> map) {
InternalSearchHits internalSearchHits = parseInternalSearchHits(map);
InternalAggregations internalAggregations = null;
Suggest suggest = null;
InternalProfileShardResults internalProfileShardResults = null;
Boolean timeout = false;
Boolean terminatedEarly = false;
return new InternalSearchResponse(internalSearchHits,
internalAggregations,
suggest,
internalProfileShardResults,
timeout,
terminatedEarly);
}
开发者ID:jprante,项目名称:elasticsearch-client-http,代码行数:15,代码来源:HttpSearchAction.java
示例10: parseInternalSearchHits
import org.elasticsearch.search.internal.InternalSearchHits; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private InternalSearchHits parseInternalSearchHits(Map<String, ?> map) {
// InternalSearchHits(InternalSearchHit[] hits, long totalHits, float maxScore)
InternalSearchHit[] internalSearchHits = parseInternalSearchHit();
Map<String, ?> internalMap = (Map<String, ?>) map.get(HITS);
long totalHits = internalMap != null && internalMap.containsKey(TOTAL) ? (Integer) internalMap.get(TOTAL) : -1L;
double maxScore = internalMap != null && internalMap.containsKey(MAXSCORE) ? (Double) internalMap.get(MAXSCORE) : 0.0f;
return new InternalSearchHits(internalSearchHits, totalHits, (float) maxScore);
}
开发者ID:jprante,项目名称:elasticsearch-client-http,代码行数:10,代码来源:HttpSearchAction.java
示例11: pollDataToIndexed
import org.elasticsearch.search.internal.InternalSearchHits; //导入依赖的package包/类
public SearchHits pollDataToIndexed() throws InterruptedException {
SearchHits polled = dataQueue.poll(queuePollTimeout, TimeUnit.SECONDS);
if (didTimeout(polled)) {
return InternalSearchHits.empty();
}
return polled;
}
开发者ID:allegro,项目名称:elasticsearch-reindex-tool,代码行数:8,代码来源:ProcessSynchronizer.java
示例12: search
import org.elasticsearch.search.internal.InternalSearchHits; //导入依赖的package包/类
@Override
public SearchResponse search(String searchTerms, List<String> references, List<String> siteIds, int start, int end, Map<String,String> additionalSearchInfromation) {
return new SearchResponse(
new InternalSearchResponse(new InternalSearchHits(new InternalSearchHit[0], 0, 0.0f), new InternalFacets(Collections.EMPTY_LIST), new InternalAggregations(Collections.EMPTY_LIST), new Suggest(), false, false),
"no-op",
1,
1,
1,
new ShardSearchFailure[0]
);
}
开发者ID:sakaiproject,项目名称:sakai,代码行数:12,代码来源:ElasticSearchService.java
示例13: parseInternalSearchResponse
import org.elasticsearch.search.internal.InternalSearchHits; //导入依赖的package包/类
private InternalSearchResponse parseInternalSearchResponse(Map<String,?> map) {
InternalSearchHits internalSearchHits = parseInternalSearchHits(map);
InternalAggregations internalAggregations = parseInternalAggregations(map);
Suggest suggest = parseSuggest(map);
InternalProfileShardResults internalProfileShardResults = null;
Boolean timeout = false;
Boolean terminatedEarly = false;
return new InternalSearchResponse(internalSearchHits,
internalAggregations,
suggest,
internalProfileShardResults,
timeout,
terminatedEarly);
}
开发者ID:jprante,项目名称:elasticsearch-helper,代码行数:15,代码来源:HttpSearchAction.java
示例14: parseInternalSearchHits
import org.elasticsearch.search.internal.InternalSearchHits; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private InternalSearchHits parseInternalSearchHits(Map<String,?> map) {
// InternalSearchHits(InternalSearchHit[] hits, long totalHits, float maxScore)
InternalSearchHit[] internalSearchHits = parseInternalSearchHit(map);
map = (Map<String, ?>) map.get(HITS);
long totalHits = map.containsKey(TOTAL) ? (Integer)map.get(TOTAL) : -1L;
double maxScore = map.containsKey(MAXSCORE) ? (Double)map.get(MAXSCORE) : 0.0f;
return new InternalSearchHits(internalSearchHits, totalHits, (float)maxScore);
}
开发者ID:jprante,项目名称:elasticsearch-helper,代码行数:10,代码来源:HttpSearchAction.java
示例15: hits
import org.elasticsearch.search.internal.InternalSearchHits; //导入依赖的package包/类
public InternalSearchHits hits() {
return hits;
}
开发者ID:baidu,项目名称:Elasticsearch,代码行数:4,代码来源:FetchSearchResult.java
示例16: readFrom
import org.elasticsearch.search.internal.InternalSearchHits; //导入依赖的package包/类
@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
id = in.readLong();
hits = InternalSearchHits.readSearchHits(in, InternalSearchHits.streamContext().streamShardTarget(StreamContext.ShardTargetType.NO_STREAM));
}
开发者ID:baidu,项目名称:Elasticsearch,代码行数:7,代码来源:FetchSearchResult.java
示例17: writeTo
import org.elasticsearch.search.internal.InternalSearchHits; //导入依赖的package包/类
@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
out.writeLong(id);
hits.writeTo(out, InternalSearchHits.streamContext().streamShardTarget(StreamContext.ShardTargetType.NO_STREAM));
}
开发者ID:baidu,项目名称:Elasticsearch,代码行数:7,代码来源:FetchSearchResult.java
示例18: prepareSearchResponse
import org.elasticsearch.search.internal.InternalSearchHits; //导入依赖的package包/类
private SearchResponse prepareSearchResponse(String scrollId, InternalSearchHit... hits) {
InternalSearchHits hitsi = new InternalSearchHits(hits, hits.length, 10f);
InternalSearchResponse sr1i = new InternalSearchResponse(hitsi, null, null, null, false, null);
SearchResponse sr1 = new SearchResponse(sr1i, scrollId, 1, 1, 100, null);
return sr1;
}
开发者ID:searchisko,项目名称:elasticsearch-river-remote,代码行数:7,代码来源:SpaceByLastUpdateTimestampIndexerTest.java
注:本文中的org.elasticsearch.search.internal.InternalSearchHits类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论