From ad01a67c5193329c0cd74ef5b304aad99edfa1ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20B=C3=BCscher?= Date: Wed, 12 Jul 2017 10:01:18 +0200 Subject: [PATCH] Remove SearchHit#internalHits (#25653) This method does exactly what getHits() does and is used in only a few places, so it can safely be removed. It seems to be a left-over from when InternalSearchHits was folded into the SearchHits interface, which didn't contain this method. --- .../action/search/SearchPhaseController.java | 13 +++++++------ .../java/org/elasticsearch/search/SearchHits.java | 4 ---- .../metrics/tophits/TopHitsAggregator.java | 6 +++--- .../fetch/subphase/InnerHitsFetchSubPhase.java | 2 +- .../action/search/FetchSearchPhaseTests.java | 2 +- .../metrics/tophits/InternalTopHitsTests.java | 4 ++-- 6 files changed, 14 insertions(+), 17 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/action/search/SearchPhaseController.java b/core/src/main/java/org/elasticsearch/action/search/SearchPhaseController.java index 879607d059e..6149bd9db34 100644 --- a/core/src/main/java/org/elasticsearch/action/search/SearchPhaseController.java +++ b/core/src/main/java/org/elasticsearch/action/search/SearchPhaseController.java @@ -21,6 +21,7 @@ package org.elasticsearch.action.search; import com.carrotsearch.hppc.IntArrayList; import com.carrotsearch.hppc.ObjectObjectHashMap; + import org.apache.lucene.index.Term; import org.apache.lucene.search.CollectionStatistics; import org.apache.lucene.search.FieldDoc; @@ -329,9 +330,9 @@ public final class SearchPhaseController extends AbstractComponent { } FetchSearchResult fetchResult = searchResultProvider.fetchResult(); final int index = fetchResult.counterGetAndIncrement(); - assert index < fetchResult.hits().internalHits().length : "not enough hits fetched. index [" + index + "] length: " - + fetchResult.hits().internalHits().length; - SearchHit hit = fetchResult.hits().internalHits()[index]; + assert index < fetchResult.hits().getHits().length : "not enough hits fetched. index [" + index + "] length: " + + fetchResult.hits().getHits().length; + SearchHit hit = fetchResult.hits().getHits()[index]; CompletionSuggestion.Entry.Option suggestOption = suggestionOptions.get(scoreDocIndex - currentOffset); hit.score(shardDoc.score); @@ -381,9 +382,9 @@ public final class SearchPhaseController extends AbstractComponent { } FetchSearchResult fetchResult = fetchResultProvider.fetchResult(); final int index = fetchResult.counterGetAndIncrement(); - assert index < fetchResult.hits().internalHits().length : "not enough hits fetched. index [" + index + "] length: " - + fetchResult.hits().internalHits().length; - SearchHit searchHit = fetchResult.hits().internalHits()[index]; + assert index < fetchResult.hits().getHits().length : "not enough hits fetched. index [" + index + "] length: " + + fetchResult.hits().getHits().length; + SearchHit searchHit = fetchResult.hits().getHits()[index]; searchHit.score(shardDoc.score); searchHit.shard(fetchResult.getSearchShardTarget()); if (sorted) { diff --git a/core/src/main/java/org/elasticsearch/search/SearchHits.java b/core/src/main/java/org/elasticsearch/search/SearchHits.java index aef585ca2a2..cc1aae79736 100644 --- a/core/src/main/java/org/elasticsearch/search/SearchHits.java +++ b/core/src/main/java/org/elasticsearch/search/SearchHits.java @@ -95,10 +95,6 @@ public final class SearchHits implements Streamable, ToXContent, Iterable(doc, internalHits.internalHits()[i])); + allHits.add(new Tuple<>(doc, internalHits.getHits()[i])); } } allHits.sort(comparing(Tuple::v1, scoreDocComparator()));