summaryrefslogtreecommitdiff
path: root/core/src
diff options
context:
space:
mode:
authorAdrien Grand <jpountz@gmail.com>2017-06-22 12:35:33 +0200
committerGitHub <noreply@github.com>2017-06-22 12:35:33 +0200
commit44e9c0b9473ffa8ce536953ed886988c7bffc95f (patch)
tree5666f433b35ada8375dee3c47255d891162e2076 /core/src
parenta9775690858e2272f0f00f917ae1d7c25753909b (diff)
Upgrade to lucene-7.0.0-snapshot-ad2cb77. (#25349)
Most notable changes: - better update concurrency: LUCENE-7868 - TopDocs.totalHits is now a long: LUCENE-7872 - QueryBuilder does not remove the boolean query around multi-term synonyms: LUCENE-7878 - removal of Fields: LUCENE-7500 For the `TopDocs.totalHits` change, this PR relies on the fact that the encoding of vInts and vLongs are compatible: you can write and read with any of them as long as the value can be represented by a positive int.
Diffstat (limited to 'core/src')
-rw-r--r--core/src/main/java/org/elasticsearch/common/lucene/Lucene.java10
-rw-r--r--core/src/main/java/org/elasticsearch/common/lucene/uid/PerThreadIDVersionAndSeqNoLookup.java4
-rw-r--r--core/src/main/java/org/elasticsearch/index/fielddata/plain/PagedBytesIndexFieldData.java3
-rw-r--r--core/src/main/java/org/elasticsearch/search/aggregations/metrics/tophits/InternalTopHits.java2
-rw-r--r--core/src/main/java/org/elasticsearch/search/internal/ScrollContext.java2
-rw-r--r--core/src/main/java/org/elasticsearch/search/query/QuerySearchResult.java4
-rw-r--r--core/src/main/java/org/elasticsearch/search/suggest/completion/CompletionFieldStats.java12
-rw-r--r--core/src/main/resources/org/elasticsearch/bootstrap/security.policy4
-rw-r--r--core/src/main/resources/org/elasticsearch/bootstrap/test-framework.policy2
-rw-r--r--core/src/test/java/org/apache/lucene/search/uhighlight/CustomUnifiedHighlighterTests.java2
-rw-r--r--core/src/test/java/org/elasticsearch/common/lucene/all/SimpleAllTests.java26
-rw-r--r--core/src/test/java/org/elasticsearch/deps/lucene/VectorHighlighterTests.java8
-rw-r--r--core/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java12
-rw-r--r--core/src/test/java/org/elasticsearch/index/fielddata/AbstractFieldDataImplTestCase.java12
-rw-r--r--core/src/test/java/org/elasticsearch/index/mapper/DoubleIndexingDocTests.java14
-rw-r--r--core/src/test/java/org/elasticsearch/index/query/QueryStringQueryBuilderTests.java29
-rw-r--r--core/src/test/java/org/elasticsearch/index/search/nested/AbstractNumberNestedSortingTestCase.java14
-rw-r--r--core/src/test/java/org/elasticsearch/index/search/nested/DoubleNestedSortingTests.java2
-rw-r--r--core/src/test/java/org/elasticsearch/index/search/nested/FloatNestedSortingTests.java2
-rw-r--r--core/src/test/java/org/elasticsearch/index/search/nested/NestedSortingTests.java6
-rw-r--r--core/src/test/java/org/elasticsearch/search/query/QueryPhaseTests.java40
21 files changed, 104 insertions, 106 deletions
diff --git a/core/src/main/java/org/elasticsearch/common/lucene/Lucene.java b/core/src/main/java/org/elasticsearch/common/lucene/Lucene.java
index 52550f1ba6..10adf530b1 100644
--- a/core/src/main/java/org/elasticsearch/common/lucene/Lucene.java
+++ b/core/src/main/java/org/elasticsearch/common/lucene/Lucene.java
@@ -272,7 +272,7 @@ public class Lucene {
public static TopDocs readTopDocs(StreamInput in) throws IOException {
byte type = in.readByte();
if (type == 0) {
- int totalHits = in.readVInt();
+ long totalHits = in.readVLong();
float maxScore = in.readFloat();
ScoreDoc[] scoreDocs = new ScoreDoc[in.readVInt()];
@@ -281,7 +281,7 @@ public class Lucene {
}
return new TopDocs(totalHits, scoreDocs, maxScore);
} else if (type == 1) {
- int totalHits = in.readVInt();
+ long totalHits = in.readVLong();
float maxScore = in.readFloat();
SortField[] fields = new SortField[in.readVInt()];
@@ -385,7 +385,7 @@ public class Lucene {
out.writeByte((byte) 2);
CollapseTopFieldDocs collapseDocs = (CollapseTopFieldDocs) topDocs;
- out.writeVInt(topDocs.totalHits);
+ out.writeVLong(topDocs.totalHits);
out.writeFloat(topDocs.getMaxScore());
out.writeString(collapseDocs.field);
@@ -405,7 +405,7 @@ public class Lucene {
out.writeByte((byte) 1);
TopFieldDocs topFieldDocs = (TopFieldDocs) topDocs;
- out.writeVInt(topDocs.totalHits);
+ out.writeVLong(topDocs.totalHits);
out.writeFloat(topDocs.getMaxScore());
out.writeVInt(topFieldDocs.fields.length);
@@ -419,7 +419,7 @@ public class Lucene {
}
} else {
out.writeByte((byte) 0);
- out.writeVInt(topDocs.totalHits);
+ out.writeVLong(topDocs.totalHits);
out.writeFloat(topDocs.getMaxScore());
out.writeVInt(topDocs.scoreDocs.length);
diff --git a/core/src/main/java/org/elasticsearch/common/lucene/uid/PerThreadIDVersionAndSeqNoLookup.java b/core/src/main/java/org/elasticsearch/common/lucene/uid/PerThreadIDVersionAndSeqNoLookup.java
index ae3d978928..2b37c338c9 100644
--- a/core/src/main/java/org/elasticsearch/common/lucene/uid/PerThreadIDVersionAndSeqNoLookup.java
+++ b/core/src/main/java/org/elasticsearch/common/lucene/uid/PerThreadIDVersionAndSeqNoLookup.java
@@ -19,7 +19,6 @@ package org.elasticsearch.common.lucene.uid;
* under the License.
*/
-import org.apache.lucene.index.Fields;
import org.apache.lucene.index.LeafReader;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.index.NumericDocValues;
@@ -67,8 +66,7 @@ final class PerThreadIDVersionAndSeqNoLookup {
*/
PerThreadIDVersionAndSeqNoLookup(LeafReader reader, String uidField) throws IOException {
this.uidField = uidField;
- Fields fields = reader.fields();
- Terms terms = fields.terms(uidField);
+ Terms terms = reader.terms(uidField);
if (terms == null) {
throw new IllegalArgumentException("reader misses the [" + uidField + "] field");
}
diff --git a/core/src/main/java/org/elasticsearch/index/fielddata/plain/PagedBytesIndexFieldData.java b/core/src/main/java/org/elasticsearch/index/fielddata/plain/PagedBytesIndexFieldData.java
index eab98040bb..fa126d6813 100644
--- a/core/src/main/java/org/elasticsearch/index/fielddata/plain/PagedBytesIndexFieldData.java
+++ b/core/src/main/java/org/elasticsearch/index/fielddata/plain/PagedBytesIndexFieldData.java
@@ -180,8 +180,7 @@ public class PagedBytesIndexFieldData extends AbstractIndexOrdinalsFieldData {
LeafReader reader = context.reader();
Terms terms = reader.terms(getFieldName());
- Fields fields = reader.fields();
- final Terms fieldTerms = fields.terms(getFieldName());
+ final Terms fieldTerms = reader.terms(getFieldName());
if (fieldTerms instanceof FieldReader) {
final Stats stats = ((FieldReader) fieldTerms).getStats();
diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/metrics/tophits/InternalTopHits.java b/core/src/main/java/org/elasticsearch/search/aggregations/metrics/tophits/InternalTopHits.java
index d1986f2dd2..e2cb84f03a 100644
--- a/core/src/main/java/org/elasticsearch/search/aggregations/metrics/tophits/InternalTopHits.java
+++ b/core/src/main/java/org/elasticsearch/search/aggregations/metrics/tophits/InternalTopHits.java
@@ -191,7 +191,7 @@ public class InternalTopHits extends InternalAggregation implements TopHits {
protected int doHashCode() {
int hashCode = from;
hashCode = 31 * hashCode + size;
- hashCode = 31 * hashCode + topDocs.totalHits;
+ hashCode = 31 * hashCode + Long.hashCode(topDocs.totalHits);
for (int d = 0; d < topDocs.scoreDocs.length; d++) {
ScoreDoc doc = topDocs.scoreDocs[d];
hashCode = 31 * hashCode + doc.doc;
diff --git a/core/src/main/java/org/elasticsearch/search/internal/ScrollContext.java b/core/src/main/java/org/elasticsearch/search/internal/ScrollContext.java
index 163dbcc73d..75d48d5d63 100644
--- a/core/src/main/java/org/elasticsearch/search/internal/ScrollContext.java
+++ b/core/src/main/java/org/elasticsearch/search/internal/ScrollContext.java
@@ -30,7 +30,7 @@ public final class ScrollContext {
private Map<String, Object> context = null;
- public int totalHits = -1;
+ public long totalHits = -1;
public float maxScore;
public ScoreDoc lastEmittedDoc;
public Scroll scroll;
diff --git a/core/src/main/java/org/elasticsearch/search/query/QuerySearchResult.java b/core/src/main/java/org/elasticsearch/search/query/QuerySearchResult.java
index f071c62f12..8549f42040 100644
--- a/core/src/main/java/org/elasticsearch/search/query/QuerySearchResult.java
+++ b/core/src/main/java/org/elasticsearch/search/query/QuerySearchResult.java
@@ -56,7 +56,7 @@ public final class QuerySearchResult extends SearchPhaseResult {
private ProfileShardResult profileShardResults;
private boolean hasProfileResults;
private boolean hasScoreDocs;
- private int totalHits;
+ private long totalHits;
private float maxScore;
public QuerySearchResult() {
@@ -317,7 +317,7 @@ public final class QuerySearchResult extends SearchPhaseResult {
out.writeOptionalWriteable(profileShardResults);
}
- public int getTotalHits() {
+ public long getTotalHits() {
return totalHits;
}
diff --git a/core/src/main/java/org/elasticsearch/search/suggest/completion/CompletionFieldStats.java b/core/src/main/java/org/elasticsearch/search/suggest/completion/CompletionFieldStats.java
index 8b5761a7e9..c9b8356362 100644
--- a/core/src/main/java/org/elasticsearch/search/suggest/completion/CompletionFieldStats.java
+++ b/core/src/main/java/org/elasticsearch/search/suggest/completion/CompletionFieldStats.java
@@ -20,7 +20,8 @@
package org.elasticsearch.search.suggest.completion;
import com.carrotsearch.hppc.ObjectLongHashMap;
-import org.apache.lucene.index.Fields;
+
+import org.apache.lucene.index.FieldInfo;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.LeafReader;
import org.apache.lucene.index.LeafReaderContext;
@@ -49,14 +50,13 @@ public class CompletionFieldStats {
for (LeafReaderContext atomicReaderContext : indexReader.leaves()) {
LeafReader atomicReader = atomicReaderContext.reader();
try {
- Fields fields = atomicReader.fields();
- for (String fieldName : fields) {
- Terms terms = fields.terms(fieldName);
+ for (FieldInfo info : atomicReader.getFieldInfos()) {
+ Terms terms = atomicReader.terms(info.name);
if (terms instanceof CompletionTerms) {
// TODO: currently we load up the suggester for reporting its size
long fstSize = ((CompletionTerms) terms).suggester().ramBytesUsed();
- if (fieldNamePatterns != null && fieldNamePatterns.length > 0 && Regex.simpleMatch(fieldNamePatterns, fieldName)) {
- completionFields.addTo(fieldName, fstSize);
+ if (fieldNamePatterns != null && fieldNamePatterns.length > 0 && Regex.simpleMatch(fieldNamePatterns, info.name)) {
+ completionFields.addTo(info.name, fstSize);
}
sizeInBytes += fstSize;
}
diff --git a/core/src/main/resources/org/elasticsearch/bootstrap/security.policy b/core/src/main/resources/org/elasticsearch/bootstrap/security.policy
index 722a928f56..8496eaa529 100644
--- a/core/src/main/resources/org/elasticsearch/bootstrap/security.policy
+++ b/core/src/main/resources/org/elasticsearch/bootstrap/security.policy
@@ -31,7 +31,7 @@ grant codeBase "${codebase.securesm-1.1.jar}" {
//// Very special jar permissions:
//// These are dangerous permissions that we don't want to grant to everything.
-grant codeBase "${codebase.lucene-core-7.0.0-snapshot-92b1783.jar}" {
+grant codeBase "${codebase.lucene-core-7.0.0-snapshot-ad2cb77.jar}" {
// needed to allow MMapDirectory's "unmap hack" (die unmap hack, die)
// java 8 package
permission java.lang.RuntimePermission "accessClassInPackage.sun.misc";
@@ -42,7 +42,7 @@ grant codeBase "${codebase.lucene-core-7.0.0-snapshot-92b1783.jar}" {
permission java.lang.RuntimePermission "accessDeclaredMembers";
};
-grant codeBase "${codebase.lucene-misc-7.0.0-snapshot-92b1783.jar}" {
+grant codeBase "${codebase.lucene-misc-7.0.0-snapshot-ad2cb77.jar}" {
// needed to allow shard shrinking to use hard-links if possible via lucenes HardlinkCopyDirectoryWrapper
permission java.nio.file.LinkPermission "hard";
};
diff --git a/core/src/main/resources/org/elasticsearch/bootstrap/test-framework.policy b/core/src/main/resources/org/elasticsearch/bootstrap/test-framework.policy
index 4f10cf6edb..5e40e47b9f 100644
--- a/core/src/main/resources/org/elasticsearch/bootstrap/test-framework.policy
+++ b/core/src/main/resources/org/elasticsearch/bootstrap/test-framework.policy
@@ -33,7 +33,7 @@ grant codeBase "${codebase.securemock-1.2.jar}" {
permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
};
-grant codeBase "${codebase.lucene-test-framework-7.0.0-snapshot-92b1783.jar}" {
+grant codeBase "${codebase.lucene-test-framework-7.0.0-snapshot-ad2cb77.jar}" {
// needed by RamUsageTester
permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
// needed for testing hardlinks in StoreRecoveryTests since we install MockFS
diff --git a/core/src/test/java/org/apache/lucene/search/uhighlight/CustomUnifiedHighlighterTests.java b/core/src/test/java/org/apache/lucene/search/uhighlight/CustomUnifiedHighlighterTests.java
index eec611146a..27544448e0 100644
--- a/core/src/test/java/org/apache/lucene/search/uhighlight/CustomUnifiedHighlighterTests.java
+++ b/core/src/test/java/org/apache/lucene/search/uhighlight/CustomUnifiedHighlighterTests.java
@@ -75,7 +75,7 @@ public class CustomUnifiedHighlighterTests extends ESTestCase {
IndexSearcher searcher = newSearcher(reader);
iw.close();
TopDocs topDocs = searcher.search(new MatchAllDocsQuery(), 1, Sort.INDEXORDER);
- assertThat(topDocs.totalHits, equalTo(1));
+ assertThat(topDocs.totalHits, equalTo(1L));
String rawValue = Strings.arrayToDelimitedString(inputs, String.valueOf(MULTIVAL_SEP_CHAR));
CustomUnifiedHighlighter highlighter = new CustomUnifiedHighlighter(searcher, analyzer,
new CustomPassageFormatter("<b>", "</b>", new DefaultEncoder()), locale, breakIterator, rawValue,
diff --git a/core/src/test/java/org/elasticsearch/common/lucene/all/SimpleAllTests.java b/core/src/test/java/org/elasticsearch/common/lucene/all/SimpleAllTests.java
index ff8b25c796..d067b813d1 100644
--- a/core/src/test/java/org/elasticsearch/common/lucene/all/SimpleAllTests.java
+++ b/core/src/test/java/org/elasticsearch/common/lucene/all/SimpleAllTests.java
@@ -81,7 +81,7 @@ public class SimpleAllTests extends ESTestCase {
Query query = new AllTermQuery(new Term("_all", "else"));
TopDocs docs = searcher.search(query, 10);
- assertThat(docs.totalHits, equalTo(2));
+ assertThat(docs.totalHits, equalTo(2L));
assertThat(docs.scoreDocs[0].doc, equalTo(0));
assertExplanationScore(searcher, query, docs.scoreDocs[0]);
assertThat(docs.scoreDocs[1].doc, equalTo(1));
@@ -89,7 +89,7 @@ public class SimpleAllTests extends ESTestCase {
query = new AllTermQuery(new Term("_all", "something"));
docs = searcher.search(query, 10);
- assertThat(docs.totalHits, equalTo(2));
+ assertThat(docs.totalHits, equalTo(2L));
assertThat(docs.scoreDocs[0].doc, equalTo(0));
assertExplanationScore(searcher, query, docs.scoreDocs[0]);
assertThat(docs.scoreDocs[1].doc, equalTo(1));
@@ -123,7 +123,7 @@ public class SimpleAllTests extends ESTestCase {
// this one is boosted. so the second doc is more relevant
Query query = new AllTermQuery(new Term("_all", "else"));
TopDocs docs = searcher.search(query, 10);
- assertThat(docs.totalHits, equalTo(2));
+ assertThat(docs.totalHits, equalTo(2L));
assertThat(docs.scoreDocs[0].doc, equalTo(1));
assertExplanationScore(searcher, query, docs.scoreDocs[0]);
assertThat(docs.scoreDocs[1].doc, equalTo(0));
@@ -131,7 +131,7 @@ public class SimpleAllTests extends ESTestCase {
query = new AllTermQuery(new Term("_all", "something"));
docs = searcher.search(query, 10);
- assertThat(docs.totalHits, equalTo(2));
+ assertThat(docs.totalHits, equalTo(2L));
assertThat(docs.scoreDocs[0].doc, equalTo(0));
assertExplanationScore(searcher, query, docs.scoreDocs[0]);
assertThat(docs.scoreDocs[1].doc, equalTo(1));
@@ -192,22 +192,22 @@ public class SimpleAllTests extends ESTestCase {
IndexSearcher searcher = new IndexSearcher(reader);
TopDocs docs = searcher.search(new AllTermQuery(new Term("_all", "else")), 10);
- assertThat(docs.totalHits, equalTo(2));
+ assertThat(docs.totalHits, equalTo(2L));
assertThat(docs.scoreDocs[0].doc, equalTo(0));
assertThat(docs.scoreDocs[1].doc, equalTo(1));
docs = searcher.search(new AllTermQuery(new Term("_all", "koo")), 10);
- assertThat(docs.totalHits, equalTo(2));
+ assertThat(docs.totalHits, equalTo(2L));
assertThat(docs.scoreDocs[0].doc, equalTo(0));
assertThat(docs.scoreDocs[1].doc, equalTo(1));
docs = searcher.search(new AllTermQuery(new Term("_all", "something")), 10);
- assertThat(docs.totalHits, equalTo(2));
+ assertThat(docs.totalHits, equalTo(2L));
assertThat(docs.scoreDocs[0].doc, equalTo(0));
assertThat(docs.scoreDocs[1].doc, equalTo(1));
docs = searcher.search(new AllTermQuery(new Term("_all", "moo")), 10);
- assertThat(docs.totalHits, equalTo(2));
+ assertThat(docs.totalHits, equalTo(2L));
assertThat(docs.scoreDocs[0].doc, equalTo(0));
assertThat(docs.scoreDocs[1].doc, equalTo(1));
@@ -237,22 +237,22 @@ public class SimpleAllTests extends ESTestCase {
IndexSearcher searcher = new IndexSearcher(reader);
TopDocs docs = searcher.search(new AllTermQuery(new Term("_all", "else")), 10);
- assertThat(docs.totalHits, equalTo(2));
+ assertThat(docs.totalHits, equalTo(2L));
assertThat(docs.scoreDocs[0].doc, equalTo(1));
assertThat(docs.scoreDocs[1].doc, equalTo(0));
docs = searcher.search(new AllTermQuery(new Term("_all", "koo")), 10);
- assertThat(docs.totalHits, equalTo(2));
+ assertThat(docs.totalHits, equalTo(2L));
assertThat(docs.scoreDocs[0].doc, equalTo(1));
assertThat(docs.scoreDocs[1].doc, equalTo(0));
docs = searcher.search(new AllTermQuery(new Term("_all", "something")), 10);
- assertThat(docs.totalHits, equalTo(2));
+ assertThat(docs.totalHits, equalTo(2L));
assertThat(docs.scoreDocs[0].doc, equalTo(0));
assertThat(docs.scoreDocs[1].doc, equalTo(1));
docs = searcher.search(new AllTermQuery(new Term("_all", "moo")), 10);
- assertThat(docs.totalHits, equalTo(2));
+ assertThat(docs.totalHits, equalTo(2L));
assertThat(docs.scoreDocs[0].doc, equalTo(0));
assertThat(docs.scoreDocs[1].doc, equalTo(1));
@@ -273,7 +273,7 @@ public class SimpleAllTests extends ESTestCase {
IndexSearcher searcher = new IndexSearcher(reader);
TopDocs docs = searcher.search(new MatchAllDocsQuery(), 10);
- assertThat(docs.totalHits, equalTo(1));
+ assertThat(docs.totalHits, equalTo(1L));
assertThat(docs.scoreDocs[0].doc, equalTo(0));
}
}
diff --git a/core/src/test/java/org/elasticsearch/deps/lucene/VectorHighlighterTests.java b/core/src/test/java/org/elasticsearch/deps/lucene/VectorHighlighterTests.java
index 5e02da294c..0475c324f0 100644
--- a/core/src/test/java/org/elasticsearch/deps/lucene/VectorHighlighterTests.java
+++ b/core/src/test/java/org/elasticsearch/deps/lucene/VectorHighlighterTests.java
@@ -62,7 +62,7 @@ public class VectorHighlighterTests extends ESTestCase {
IndexSearcher searcher = new IndexSearcher(reader);
TopDocs topDocs = searcher.search(new TermQuery(new Term("_id", "1")), 1);
- assertThat(topDocs.totalHits, equalTo(1));
+ assertThat(topDocs.totalHits, equalTo(1L));
FastVectorHighlighter highlighter = new FastVectorHighlighter();
String fragment = highlighter.getBestFragment(highlighter.getFieldQuery(new TermQuery(new Term("content", "bad"))),
@@ -88,7 +88,7 @@ public class VectorHighlighterTests extends ESTestCase {
IndexSearcher searcher = new IndexSearcher(reader);
TopDocs topDocs = searcher.search(new TermQuery(new Term("_id", "1")), 1);
- assertThat(topDocs.totalHits, equalTo(1));
+ assertThat(topDocs.totalHits, equalTo(1L));
FastVectorHighlighter highlighter = new FastVectorHighlighter();
@@ -129,7 +129,7 @@ public class VectorHighlighterTests extends ESTestCase {
IndexSearcher searcher = new IndexSearcher(reader);
TopDocs topDocs = searcher.search(new TermQuery(new Term("_id", "1")), 1);
- assertThat(topDocs.totalHits, equalTo(1));
+ assertThat(topDocs.totalHits, equalTo(1L));
FastVectorHighlighter highlighter = new FastVectorHighlighter();
String fragment = highlighter.getBestFragment(highlighter.getFieldQuery(new TermQuery(new Term("content", "bad"))),
@@ -150,7 +150,7 @@ public class VectorHighlighterTests extends ESTestCase {
IndexSearcher searcher = new IndexSearcher(reader);
TopDocs topDocs = searcher.search(new TermQuery(new Term("_id", "1")), 1);
- assertThat(topDocs.totalHits, equalTo(1));
+ assertThat(topDocs.totalHits, equalTo(1L));
FastVectorHighlighter highlighter = new FastVectorHighlighter();
String fragment = highlighter.getBestFragment(highlighter.getFieldQuery(new TermQuery(new Term("content", "bad"))),
diff --git a/core/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java b/core/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java
index 6cd9328558..a955f01991 100644
--- a/core/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java
+++ b/core/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java
@@ -1963,7 +1963,7 @@ public class InternalEngineTests extends ESTestCase {
final String formattedMessage = event.getMessage().getFormattedMessage();
if (event.getLevel() == Level.TRACE && event.getMarker().getName().contains("[index][0] ")) {
if (event.getLoggerName().endsWith(".IW") &&
- formattedMessage.contains("IW: apply all deletes during flush")) {
+ formattedMessage.contains("IW: now apply all deletes")) {
sawIndexWriterMessage = true;
}
if (event.getLoggerName().endsWith(".IFD")) {
@@ -2535,7 +2535,7 @@ public class InternalEngineTests extends ESTestCase {
engine = new InternalEngine(copy(engine.config(), EngineConfig.OpenMode.OPEN_INDEX_CREATE_TRANSLOG));
try (Engine.Searcher searcher = engine.acquireSearcher("test")) {
TopDocs topDocs = searcher.searcher().search(new MatchAllDocsQuery(), randomIntBetween(numDocs, numDocs + 10));
- assertThat(topDocs.totalHits, equalTo(0));
+ assertThat(topDocs.totalHits, equalTo(0L));
}
}
@@ -2626,7 +2626,7 @@ public class InternalEngineTests extends ESTestCase {
engine.refresh("test");
try (Engine.Searcher searcher = engine.acquireSearcher("test")) {
TopDocs topDocs = searcher.searcher().search(new MatchAllDocsQuery(), randomIntBetween(numDocs, numDocs + numExtraDocs));
- assertThat(topDocs.totalHits, equalTo(numDocs + numExtraDocs));
+ assertThat(topDocs.totalHits, equalTo((long) numDocs + numExtraDocs));
}
}
IOUtils.close(store, directory);
@@ -2694,14 +2694,14 @@ public class InternalEngineTests extends ESTestCase {
assertThat(result.getVersion(), equalTo(2L));
try (Engine.Searcher searcher = engine.acquireSearcher("test")) {
TopDocs topDocs = searcher.searcher().search(new MatchAllDocsQuery(), numDocs + 1);
- assertThat(topDocs.totalHits, equalTo(numDocs + 1));
+ assertThat(topDocs.totalHits, equalTo(numDocs + 1L));
}
engine.close();
engine = createEngine(store, primaryTranslogDir);
try (Engine.Searcher searcher = engine.acquireSearcher("test")) {
TopDocs topDocs = searcher.searcher().search(new MatchAllDocsQuery(), numDocs + 1);
- assertThat(topDocs.totalHits, equalTo(numDocs + 1));
+ assertThat(topDocs.totalHits, equalTo(numDocs + 1L));
}
parser = (TranslogHandler) engine.config().getTranslogRecoveryRunner();
assertEquals(flush ? 1 : 2, parser.appliedOperations.get());
@@ -2714,7 +2714,7 @@ public class InternalEngineTests extends ESTestCase {
}
try (Engine.Searcher searcher = engine.acquireSearcher("test")) {
TopDocs topDocs = searcher.searcher().search(new MatchAllDocsQuery(), numDocs);
- assertThat(topDocs.totalHits, equalTo(numDocs));
+ assertThat(topDocs.totalHits, equalTo((long) numDocs));
}
}
diff --git a/core/src/test/java/org/elasticsearch/index/fielddata/AbstractFieldDataImplTestCase.java b/core/src/test/java/org/elasticsearch/index/fielddata/AbstractFieldDataImplTestCase.java
index c22114e28a..df6328feab 100644
--- a/core/src/test/java/org/elasticsearch/index/fielddata/AbstractFieldDataImplTestCase.java
+++ b/core/src/test/java/org/elasticsearch/index/fielddata/AbstractFieldDataImplTestCase.java
@@ -114,7 +114,7 @@ public abstract class AbstractFieldDataImplTestCase extends AbstractFieldDataTes
SortField sortField = indexFieldData.sortField(null, MultiValueMode.MIN, null, false);
topDocs = searcher.search(new MatchAllDocsQuery(), 10,
new Sort(sortField));
- assertThat(topDocs.totalHits, equalTo(3));
+ assertThat(topDocs.totalHits, equalTo(3L));
assertThat(topDocs.scoreDocs[0].doc, equalTo(1));
assertThat(toString(((FieldDoc) topDocs.scoreDocs[0]).fields[0]), equalTo(one()));
assertThat(topDocs.scoreDocs[1].doc, equalTo(0));
@@ -125,7 +125,7 @@ public abstract class AbstractFieldDataImplTestCase extends AbstractFieldDataTes
sortField = indexFieldData.sortField(null, MultiValueMode.MAX, null, true);
topDocs = searcher.search(new MatchAllDocsQuery(), 10,
new Sort(sortField));
- assertThat(topDocs.totalHits, equalTo(3));
+ assertThat(topDocs.totalHits, equalTo(3L));
assertThat(topDocs.scoreDocs[0].doc, equalTo(2));
assertThat(topDocs.scoreDocs[1].doc, equalTo(0));
assertThat(topDocs.scoreDocs[2].doc, equalTo(1));
@@ -191,7 +191,7 @@ public abstract class AbstractFieldDataImplTestCase extends AbstractFieldDataTes
IndexSearcher searcher = new IndexSearcher(DirectoryReader.open(writer));
SortField sortField = indexFieldData.sortField(null, MultiValueMode.MIN, null, false);
TopFieldDocs topDocs = searcher.search(new MatchAllDocsQuery(), 10, new Sort(sortField));
- assertThat(topDocs.totalHits, equalTo(3));
+ assertThat(topDocs.totalHits, equalTo(3L));
assertThat(topDocs.scoreDocs.length, equalTo(3));
assertThat(topDocs.scoreDocs[0].doc, equalTo(1));
assertThat(topDocs.scoreDocs[1].doc, equalTo(0));
@@ -199,7 +199,7 @@ public abstract class AbstractFieldDataImplTestCase extends AbstractFieldDataTes
;
sortField = indexFieldData.sortField(null, MultiValueMode.MAX, null, true);
topDocs = searcher.search(new MatchAllDocsQuery(), 10, new Sort(sortField));
- assertThat(topDocs.totalHits, equalTo(3));
+ assertThat(topDocs.totalHits, equalTo(3L));
assertThat(topDocs.scoreDocs.length, equalTo(3));
assertThat(topDocs.scoreDocs[0].doc, equalTo(0));
assertThat(topDocs.scoreDocs[1].doc, equalTo(2));
@@ -258,7 +258,7 @@ public abstract class AbstractFieldDataImplTestCase extends AbstractFieldDataTes
indexFieldData.sortField(null, MultiValueMode.MIN, null, false);
TopFieldDocs topDocs = searcher.search(new MatchAllDocsQuery(), 10,
new Sort(sortField));
- assertThat(topDocs.totalHits, equalTo(8));
+ assertThat(topDocs.totalHits, equalTo(8L));
assertThat(topDocs.scoreDocs.length, equalTo(8));
assertThat(topDocs.scoreDocs[0].doc, equalTo(7));
assertThat(((BytesRef) ((FieldDoc) topDocs.scoreDocs[0]).fields[0]).utf8ToString(), equalTo("!08"));
@@ -280,7 +280,7 @@ public abstract class AbstractFieldDataImplTestCase extends AbstractFieldDataTes
sortField = indexFieldData.sortField(null, MultiValueMode.MAX, null, true);
topDocs = searcher.search(new MatchAllDocsQuery(), 10,
new Sort(sortField));
- assertThat(topDocs.totalHits, equalTo(8));
+ assertThat(topDocs.totalHits, equalTo(8L));
assertThat(topDocs.scoreDocs.length, equalTo(8));
assertThat(topDocs.scoreDocs[0].doc, equalTo(6));
assertThat(((BytesRef) ((FieldDoc) topDocs.scoreDocs[0]).fields[0]).utf8ToString(), equalTo("10"));
diff --git a/core/src/test/java/org/elasticsearch/index/mapper/DoubleIndexingDocTests.java b/core/src/test/java/org/elasticsearch/index/mapper/DoubleIndexingDocTests.java
index 2acd6b5c98..3f2dc28610 100644
--- a/core/src/test/java/org/elasticsearch/index/mapper/DoubleIndexingDocTests.java
+++ b/core/src/test/java/org/elasticsearch/index/mapper/DoubleIndexingDocTests.java
@@ -70,25 +70,25 @@ public class DoubleIndexingDocTests extends ESSingleNodeTestCase {
IndexSearcher searcher = new IndexSearcher(reader);
TopDocs topDocs = searcher.search(mapper.mappers().smartNameFieldMapper("field1").fieldType().termQuery("value1", context), 10);
- assertThat(topDocs.totalHits, equalTo(2));
+ assertThat(topDocs.totalHits, equalTo(2L));
topDocs = searcher.search(mapper.mappers().smartNameFieldMapper("field2").fieldType().termQuery("1", context), 10);
- assertThat(topDocs.totalHits, equalTo(2));
+ assertThat(topDocs.totalHits, equalTo(2L));
topDocs = searcher.search(mapper.mappers().smartNameFieldMapper("field3").fieldType().termQuery("1.1", context), 10);
- assertThat(topDocs.totalHits, equalTo(2));
+ assertThat(topDocs.totalHits, equalTo(2L));
topDocs = searcher.search(mapper.mappers().smartNameFieldMapper("field4").fieldType().termQuery("2010-01-01", context), 10);
- assertThat(topDocs.totalHits, equalTo(2));
+ assertThat(topDocs.totalHits, equalTo(2L));
topDocs = searcher.search(mapper.mappers().smartNameFieldMapper("field5").fieldType().termQuery("1", context), 10);
- assertThat(topDocs.totalHits, equalTo(2));
+ assertThat(topDocs.totalHits, equalTo(2L));
topDocs = searcher.search(mapper.mappers().smartNameFieldMapper("field5").fieldType().termQuery("2", context), 10);
- assertThat(topDocs.totalHits, equalTo(2));
+ assertThat(topDocs.totalHits, equalTo(2L));
topDocs = searcher.search(mapper.mappers().smartNameFieldMapper("field5").fieldType().termQuery("3", context), 10);
- assertThat(topDocs.totalHits, equalTo(2));
+ assertThat(topDocs.totalHits, equalTo(2L));
writer.close();
reader.close();
dir.close();
diff --git a/core/src/test/java/org/elasticsearch/index/query/QueryStringQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/QueryStringQueryBuilderTests.java
index ca3850c411..038eadeff7 100644
--- a/core/src/test/java/org/elasticsearch/index/query/QueryStringQueryBuilderTests.java
+++ b/core/src/test/java/org/elasticsearch/index/query/QueryStringQueryBuilderTests.java
@@ -62,7 +62,6 @@ import org.joda.time.DateTimeZone;
import java.io.IOException;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@@ -401,12 +400,18 @@ public class QueryStringQueryBuilderTests extends AbstractQueryTestCase<QueryStr
// simple multi-term
Query query = queryParser.parse("guinea pig");
+ Query guineaPig = new BooleanQuery.Builder()
+ .add(new TermQuery(new Term(STRING_FIELD_NAME, "guinea")), Occur.MUST)
+ .add(new TermQuery(new Term(STRING_FIELD_NAME, "pig")), Occur.MUST)
+ .build();
+ TermQuery cavy = new TermQuery(new Term(STRING_FIELD_NAME, "cavy"));
+
Query expectedQuery = new BooleanQuery.Builder()
.add(new BooleanQuery.Builder()
- .add(new TermQuery(new Term(STRING_FIELD_NAME, "guinea")), Occur.MUST)
- .add(new TermQuery(new Term(STRING_FIELD_NAME, "pig")), Occur.MUST).build(), defaultOp)
- .add(new TermQuery(new Term(STRING_FIELD_NAME, "cavy")), defaultOp)
- .build();
+ .add(guineaPig, Occur.SHOULD)
+ .add(cavy, Occur.SHOULD)
+ .build(),
+ defaultOp).build();
assertThat(query, Matchers.equalTo(expectedQuery));
// simple with additional tokens
@@ -414,11 +419,8 @@ public class QueryStringQueryBuilderTests extends AbstractQueryTestCase<QueryStr
expectedQuery = new BooleanQuery.Builder()
.add(new TermQuery(new Term(STRING_FIELD_NAME, "that")), defaultOp)
.add(new BooleanQuery.Builder()
- .add(new BooleanQuery.Builder()
- .add(new BooleanClause(new TermQuery(new Term(STRING_FIELD_NAME, "guinea")), Occur.MUST))
- .add(new BooleanClause(new TermQuery(new Term(STRING_FIELD_NAME, "pig")), Occur.MUST))
- .build(), Occur.SHOULD)
- .add(new TermQuery(new Term(STRING_FIELD_NAME, "cavy")), Occur.SHOULD).build(), defaultOp)
+ .add(guineaPig, Occur.SHOULD)
+ .add(cavy, Occur.SHOULD).build(), defaultOp)
.add(new TermQuery(new Term(STRING_FIELD_NAME, "smells")), defaultOp)
.build();
assertThat(query, Matchers.equalTo(expectedQuery));
@@ -429,10 +431,9 @@ public class QueryStringQueryBuilderTests extends AbstractQueryTestCase<QueryStr
.add(new TermQuery(new Term(STRING_FIELD_NAME, "that")), Occur.MUST)
.add(new BooleanQuery.Builder()
.add(new BooleanQuery.Builder()
- .add(new TermQuery(new Term(STRING_FIELD_NAME, "guinea")), Occur.MUST)
- .add(new TermQuery(new Term(STRING_FIELD_NAME, "pig")), Occur.MUST)
- .build(), defaultOp)
- .add(new TermQuery(new Term(STRING_FIELD_NAME, "cavy")), defaultOp)
+ .add(guineaPig, Occur.SHOULD)
+ .add(cavy, Occur.SHOULD)
+ .build(), defaultOp)
.build(), Occur.MUST_NOT)
.add(new TermQuery(new Term(STRING_FIELD_NAME, "smells")), Occur.MUST)
.build();
diff --git a/core/src/test/java/org/elasticsearch/index/search/nested/AbstractNumberNestedSortingTestCase.java b/core/src/test/java/org/elasticsearch/index/search/nested/AbstractNumberNestedSortingTestCase.java
index 4d73ce48a2..d4dc71388a 100644
--- a/core/src/test/java/org/elasticsearch/index/search/nested/AbstractNumberNestedSortingTestCase.java
+++ b/core/src/test/java/org/elasticsearch/index/search/nested/AbstractNumberNestedSortingTestCase.java
@@ -226,7 +226,7 @@ public abstract class AbstractNumberNestedSortingTestCase extends AbstractFieldD
Sort sort = new Sort(new SortField("field2", nestedComparatorSource));
TopFieldDocs topDocs = searcher.search(query, 5, sort);
- assertThat(topDocs.totalHits, equalTo(7));
+ assertThat(topDocs.totalHits, equalTo(7L));
assertThat(topDocs.scoreDocs.length, equalTo(5));
assertThat(topDocs.scoreDocs[0].doc, equalTo(11));
assertThat(((Number) ((FieldDoc) topDocs.scoreDocs[0]).fields[0]).intValue(), equalTo(7));
@@ -241,7 +241,7 @@ public abstract class AbstractNumberNestedSortingTestCase extends AbstractFieldD
sort = new Sort(new SortField("field2", nestedComparatorSource, true));
topDocs = searcher.search(query, 5, sort);
- assertThat(topDocs.totalHits, equalTo(7));
+ assertThat(topDocs.totalHits, equalTo(7L));
assertThat(topDocs.scoreDocs.length, equalTo(5));
assertThat(topDocs.scoreDocs[0].doc, equalTo(28));
assertThat(((Number) ((FieldDoc) topDocs.scoreDocs[0]).fields[0]).intValue(), equalTo(13));
@@ -263,7 +263,7 @@ public abstract class AbstractNumberNestedSortingTestCase extends AbstractFieldD
);
sort = new Sort(new SortField("field2", nestedComparatorSource, true));
topDocs = searcher.search(query, 5, sort);
- assertThat(topDocs.totalHits, equalTo(6));
+ assertThat(topDocs.totalHits, equalTo(6L));
assertThat(topDocs.scoreDocs.length, equalTo(5));
assertThat(topDocs.scoreDocs[0].doc, equalTo(23));
assertThat(((Number) ((FieldDoc) topDocs.scoreDocs[0]).fields[0]).intValue(), equalTo(12));
@@ -278,7 +278,7 @@ public abstract class AbstractNumberNestedSortingTestCase extends AbstractFieldD
sort = new Sort(new SortField("field2", nestedComparatorSource));
topDocs = searcher.search(query, 5, sort);
- assertThat(topDocs.totalHits, equalTo(6));
+ assertThat(topDocs.totalHits, equalTo(6L));
assertThat(topDocs.scoreDocs.length, equalTo(5));
assertThat(topDocs.scoreDocs[0].doc, equalTo(15));
assertThat(((Number) ((FieldDoc) topDocs.scoreDocs[0]).fields[0]).intValue(), equalTo(3));
@@ -294,7 +294,7 @@ public abstract class AbstractNumberNestedSortingTestCase extends AbstractFieldD
nestedComparatorSource = createFieldComparator("field2", sortMode, 127, createNested(searcher, parentFilter, childFilter));
sort = new Sort(new SortField("field2", nestedComparatorSource, true));
topDocs = searcher.search(new TermQuery(new Term("__type", "parent")), 5, sort);
- assertThat(topDocs.totalHits, equalTo(8));
+ assertThat(topDocs.totalHits, equalTo(8L));
assertThat(topDocs.scoreDocs.length, equalTo(5));
assertThat(topDocs.scoreDocs[0].doc, equalTo(19));
assertThat(((Number) ((FieldDoc) topDocs.scoreDocs[0]).fields[0]).intValue(), equalTo(127));
@@ -310,7 +310,7 @@ public abstract class AbstractNumberNestedSortingTestCase extends AbstractFieldD
nestedComparatorSource = createFieldComparator("field2", sortMode, -127, createNested(searcher, parentFilter, childFilter));
sort = new Sort(new SortField("field2", nestedComparatorSource));
topDocs = searcher.search(new TermQuery(new Term("__type", "parent")), 5, sort);
- assertThat(topDocs.totalHits, equalTo(8));
+ assertThat(topDocs.totalHits, equalTo(8L));
assertThat(topDocs.scoreDocs.length, equalTo(5));
assertThat(topDocs.scoreDocs[0].doc, equalTo(19));
assertThat(((Number) ((FieldDoc) topDocs.scoreDocs[0]).fields[0]).intValue(), equalTo(-127));
@@ -336,7 +336,7 @@ public abstract class AbstractNumberNestedSortingTestCase extends AbstractFieldD
Query query = new ToParentBlockJoinQuery(new ConstantScoreQuery(childFilter), new QueryBitSetProducer(parentFilter), ScoreMode.None);
Sort sort = new Sort(new SortField("field2", nestedComparatorSource));
TopDocs topDocs = searcher.search(query, 5, sort);
- assertThat(topDocs.totalHits, equalTo(7));
+ assertThat(topDocs.totalHits, equalTo(7L));
assertThat(topDocs.scoreDocs.length, equalTo(5));
assertThat(topDocs.scoreDocs[0].doc, equalTo(11));
assertThat(((Number) ((FieldDoc) topDocs.scoreDocs[0]).fields[0]).intValue(), equalTo(2));
diff --git a/core/src/test/java/org/elasticsearch/index/search/nested/DoubleNestedSortingTests.java b/core/src/test/java/org/elasticsearch/index/search/nested/DoubleNestedSortingTests.java
index 1dc982270f..c643ea6cee 100644
--- a/core/src/test/java/org/elasticsearch/index/search/nested/DoubleNestedSortingTests.java
+++ b/core/src/test/java/org/elasticsearch/index/search/nested/DoubleNestedSortingTests.java
@@ -69,7 +69,7 @@ public class DoubleNestedSortingTests extends AbstractNumberNestedSortingTestCas
Query query = new ToParentBlockJoinQuery(new ConstantScoreQuery(childFilter), new QueryBitSetProducer(parentFilter), ScoreMode.None);
Sort sort = new Sort(new SortField("field2", nestedComparatorSource));
TopDocs topDocs = searcher.search(query, 5, sort);
- assertThat(topDocs.totalHits, equalTo(7));
+ assertThat(topDocs.totalHits, equalTo(7L));
assertThat(topDocs.scoreDocs.length, equalTo(5));
assertThat(topDocs.scoreDocs[0].doc, equalTo(11));
assertThat(((Number) ((FieldDoc) topDocs.scoreDocs[0]).fields[0]).intValue(), equalTo(2));
diff --git a/core/src/test/java/org/elasticsearch/index/search/nested/FloatNestedSortingTests.java b/core/src/test/java/org/elasticsearch/index/search/nested/FloatNestedSortingTests.java
index 4262b95909..13d0e83e37 100644
--- a/core/src/test/java/org/elasticsearch/index/search/nested/FloatNestedSortingTests.java
+++ b/core/src/test/java/org/elasticsearch/index/search/nested/FloatNestedSortingTests.java
@@ -68,7 +68,7 @@ public class FloatNestedSortingTests extends DoubleNestedSortingTests {
Query query = new ToParentBlockJoinQuery(new ConstantScoreQuery(childFilter), new QueryBitSetProducer(parentFilter), ScoreMode.None);
Sort sort = new Sort(new SortField("field2", nestedComparatorSource));
TopDocs topDocs = searcher.search(query, 5, sort);
- assertThat(topDocs.totalHits, equalTo(7));
+ assertThat(topDocs.totalHits, equalTo(7L));
assertThat(topDocs.scoreDocs.length, equalTo(5));
assertThat(topDocs.scoreDocs[0].doc, equalTo(11));
assertThat(((Number) ((FieldDoc) topDocs.scoreDocs[0]).fields[0]).intValue(), equalTo(2));
diff --git a/core/src/test/java/org/elasticsearch/index/search/nested/NestedSortingTests.java b/core/src/test/java/org/elasticsearch/index/search/nested/NestedSortingTests.java
index c9c48a9f96..823ccf91d3 100644
--- a/core/src/test/java/org/elasticsearch/index/search/nested/NestedSortingTests.java
+++ b/core/src/test/java/org/elasticsearch/index/search/nested/NestedSortingTests.java
@@ -285,7 +285,7 @@ public class NestedSortingTests extends AbstractFieldDataTestCase {
Sort sort = new Sort(new SortField("field2", nestedComparatorSource));
TopFieldDocs topDocs = searcher.search(query, 5, sort);
- assertThat(topDocs.totalHits, equalTo(7));
+ assertThat(topDocs.totalHits, equalTo(7L));
assertThat(topDocs.scoreDocs.length, equalTo(5));
assertThat(topDocs.scoreDocs[0].doc, equalTo(3));
assertThat(((BytesRef) ((FieldDoc) topDocs.scoreDocs[0]).fields[0]).utf8ToString(), equalTo("a"));
@@ -302,7 +302,7 @@ public class NestedSortingTests extends AbstractFieldDataTestCase {
nestedComparatorSource = new BytesRefFieldComparatorSource(indexFieldData, null, sortMode, createNested(searcher, parentFilter, childFilter));
sort = new Sort(new SortField("field2", nestedComparatorSource, true));
topDocs = searcher.search(query, 5, sort);
- assertThat(topDocs.totalHits, equalTo(7));
+ assertThat(topDocs.totalHits, equalTo(7L));
assertThat(topDocs.scoreDocs.length, equalTo(5));
assertThat(topDocs.scoreDocs[0].doc, equalTo(28));
assertThat(((BytesRef) ((FieldDoc) topDocs.scoreDocs[0]).fields[0]).utf8ToString(), equalTo("o"));
@@ -328,7 +328,7 @@ public class NestedSortingTests extends AbstractFieldDataTestCase {
);
sort = new Sort(new SortField("field2", nestedComparatorSource, true));
topDocs = searcher.search(query, 5, sort);
- assertThat(topDocs.totalHits, equalTo(6));
+ assertThat(topDocs.totalHits, equalTo(6L));
assertThat(topDocs.scoreDocs.length, equalTo(5));
assertThat(topDocs.scoreDocs[0].doc, equalTo(23));
assertThat(((BytesRef) ((FieldDoc) topDocs.scoreDocs[0]).fields[0]).utf8ToString(), equalTo("m"));
diff --git a/core/src/test/java/org/elasticsearch/search/query/QueryPhaseTests.java b/core/src/test/java/org/elasticsearch/search/query/QueryPhaseTests.java
index b05c6dff04..016406c612 100644
--- a/core/src/test/java/org/elasticsearch/search/query/QueryPhaseTests.java
+++ b/core/src/test/java/org/elasticsearch/search/query/QueryPhaseTests.java
@@ -217,18 +217,18 @@ public class QueryPhaseTests extends ESTestCase {
context.setSize(10);
QueryPhase.execute(context, contextSearcher, null);
- assertThat(context.queryResult().topDocs().totalHits, equalTo(numDocs));
+ assertThat(context.queryResult().topDocs().totalHits, equalTo((long) numDocs));
assertTrue(collected.get());
assertNull(context.queryResult().terminatedEarly());
assertThat(context.terminateAfter(), equalTo(0));
- assertThat(context.queryResult().getTotalHits(), equalTo(numDocs));
+ assertThat(context.queryResult().getTotalHits(), equalTo((long) numDocs));
QueryPhase.execute(context, contextSearcher, null);
- assertThat(context.queryResult().topDocs().totalHits, equalTo(numDocs));
+ assertThat(context.queryResult().topDocs().totalHits, equalTo((long) numDocs));
assertTrue(collected.get());
assertTrue(context.queryResult().terminatedEarly());
assertThat(context.terminateAfter(), equalTo(10));
- assertThat(context.queryResult().getTotalHits(), equalTo(numDocs));
+ assertThat(context.queryResult().getTotalHits(), equalTo((long) numDocs));
assertThat(context.queryResult().topDocs().scoreDocs[0].doc, greaterThanOrEqualTo(10));
reader.close();
dir.close();
@@ -270,14 +270,14 @@ public class QueryPhaseTests extends ESTestCase {
QueryPhase.execute(context, contextSearcher, null);
assertTrue(collected.get());
assertTrue(context.queryResult().terminatedEarly());
- assertThat(context.queryResult().topDocs().totalHits, equalTo(1));
+ assertThat(context.queryResult().topDocs().totalHits, equalTo(1L));
assertThat(context.queryResult().topDocs().scoreDocs.length, equalTo(1));
context.setSize(0);
QueryPhase.execute(context, contextSearcher, null);
assertTrue(collected.get());
assertTrue(context.queryResult().terminatedEarly());
- assertThat(context.queryResult().topDocs().totalHits, equalTo(1));
+ assertThat(context.queryResult().topDocs().totalHits, equalTo(1L));
assertThat(context.queryResult().topDocs().scoreDocs.length, equalTo(0));
}
@@ -286,7 +286,7 @@ public class QueryPhaseTests extends ESTestCase {
QueryPhase.execute(context, contextSearcher, null);
assertTrue(collected.get());
assertTrue(context.queryResult().terminatedEarly());
- assertThat(context.queryResult().topDocs().totalHits, equalTo(1));
+ assertThat(context.queryResult().topDocs().totalHits, equalTo(1L));
assertThat(context.queryResult().topDocs().scoreDocs.length, equalTo(1));
}
{
@@ -300,7 +300,7 @@ public class QueryPhaseTests extends ESTestCase {
QueryPhase.execute(context, contextSearcher, null);
assertTrue(collected.get());
assertTrue(context.queryResult().terminatedEarly());
- assertThat(context.queryResult().topDocs().totalHits, equalTo(1));
+ assertThat(context.queryResult().topDocs().totalHits, equalTo(1L));
assertThat(context.queryResult().topDocs().scoreDocs.length, equalTo(1));
context.setSize(0);
@@ -309,7 +309,7 @@ public class QueryPhaseTests extends ESTestCase {
QueryPhase.execute(context, contextSearcher, null);
assertTrue(collected.get());
assertTrue(context.queryResult().terminatedEarly());
- assertThat(context.queryResult().topDocs().totalHits, equalTo(1));
+ assertThat(context.queryResult().topDocs().totalHits, equalTo(1L));
assertThat(context.queryResult().topDocs().scoreDocs.length, equalTo(0));
}
{
@@ -320,7 +320,7 @@ public class QueryPhaseTests extends ESTestCase {
QueryPhase.execute(context, contextSearcher, null);
assertTrue(collected.get());
assertTrue(context.queryResult().terminatedEarly());
- assertThat(context.queryResult().topDocs().totalHits, equalTo(1));
+ assertThat(context.queryResult().topDocs().totalHits, equalTo(1L));
assertThat(context.queryResult().topDocs().scoreDocs.length, equalTo(1));
}
{
@@ -331,7 +331,7 @@ public class QueryPhaseTests extends ESTestCase {
QueryPhase.execute(context, contextSearcher, null);
assertTrue(collected.get());
assertTrue(context.queryResult().terminatedEarly());
- assertThat(context.queryResult().topDocs().totalHits, equalTo(1));
+ assertThat(context.queryResult().topDocs().totalHits, equalTo(1L));
assertThat(context.queryResult().topDocs().scoreDocs.length, equalTo(0));
assertThat(collector.getTotalHits(), equalTo(1));
}
@@ -377,7 +377,7 @@ public class QueryPhaseTests extends ESTestCase {
QueryPhase.execute(context, contextSearcher, sort);
assertTrue(collected.get());
assertTrue(context.queryResult().terminatedEarly());
- assertThat(context.queryResult().topDocs().totalHits, equalTo(numDocs));
+ assertThat(context.queryResult().topDocs().totalHits, equalTo((long) numDocs));
assertThat(context.queryResult().topDocs().scoreDocs.length, equalTo(1));
assertThat(context.queryResult().topDocs().scoreDocs[0], instanceOf(FieldDoc.class));
FieldDoc fieldDoc = (FieldDoc) context.queryResult().topDocs().scoreDocs[0];
@@ -390,7 +390,7 @@ public class QueryPhaseTests extends ESTestCase {
QueryPhase.execute(context, contextSearcher, sort);
assertTrue(collected.get());
assertTrue(context.queryResult().terminatedEarly());
- assertThat(context.queryResult().topDocs().totalHits, equalTo(numDocs - 1));
+ assertThat(context.queryResult().topDocs().totalHits, equalTo(numDocs - 1L));
assertThat(context.queryResult().topDocs().scoreDocs.length, equalTo(1));
assertThat(context.queryResult().topDocs().scoreDocs[0], instanceOf(FieldDoc.class));
assertThat(fieldDoc.fields[0], anyOf(equalTo(1), equalTo(2)));
@@ -402,7 +402,7 @@ public class QueryPhaseTests extends ESTestCase {
QueryPhase.execute(context, contextSearcher, sort);
assertTrue(collected.get());
assertTrue(context.queryResult().terminatedEarly());
- assertThat(context.queryResult().topDocs().totalHits, equalTo(numDocs));
+ assertThat(context.queryResult().topDocs().totalHits, equalTo((long) numDocs));
assertThat(context.queryResult().topDocs().scoreDocs.length, equalTo(1));
assertThat(context.queryResult().topDocs().scoreDocs[0], instanceOf(FieldDoc.class));
assertThat(fieldDoc.fields[0], anyOf(equalTo(1), equalTo(2)));
@@ -416,7 +416,7 @@ public class QueryPhaseTests extends ESTestCase {
QueryPhase.execute(context, contextSearcher, sort);
assertTrue(collected.get());
assertTrue(context.queryResult().terminatedEarly());
- assertThat(context.queryResult().topDocs().totalHits, lessThan(numDocs));
+ assertThat(context.queryResult().topDocs().totalHits, lessThan((long) numDocs));
assertThat(context.queryResult().topDocs().scoreDocs.length, equalTo(1));
assertThat(context.queryResult().topDocs().scoreDocs[0], instanceOf(FieldDoc.class));
assertThat(fieldDoc.fields[0], anyOf(equalTo(1), equalTo(2)));
@@ -427,7 +427,7 @@ public class QueryPhaseTests extends ESTestCase {
QueryPhase.execute(context, contextSearcher, sort);
assertTrue(collected.get());
assertTrue(context.queryResult().terminatedEarly());
- assertThat(context.queryResult().topDocs().totalHits, lessThan(numDocs));
+ assertThat(context.queryResult().topDocs().totalHits, lessThan((long) numDocs));
assertThat(context.queryResult().topDocs().scoreDocs.length, equalTo(1));
assertThat(context.queryResult().topDocs().scoreDocs[0], instanceOf(FieldDoc.class));
assertThat(fieldDoc.fields[0], anyOf(equalTo(1), equalTo(2)));
@@ -475,20 +475,20 @@ public class QueryPhaseTests extends ESTestCase {
};
QueryPhase.execute(context, contextSearcher, sort);
- assertThat(context.queryResult().topDocs().totalHits, equalTo(numDocs));
+ assertThat(context.queryResult().topDocs().totalHits, equalTo((long) numDocs));
assertTrue(collected.get());
assertNull(context.queryResult().terminatedEarly());
assertThat(context.terminateAfter(), equalTo(0));
- assertThat(context.queryResult().getTotalHits(), equalTo(numDocs));
+ assertThat(context.queryResult().getTotalHits(), equalTo((long) numDocs));
int sizeMinus1 = context.queryResult().topDocs().scoreDocs.length - 1;
FieldDoc lastDoc = (FieldDoc) context.queryResult().topDocs().scoreDocs[sizeMinus1];
QueryPhase.execute(context, contextSearcher, sort);
- assertThat(context.queryResult().topDocs().totalHits, equalTo(numDocs));
+ assertThat(context.queryResult().topDocs().totalHits, equalTo((long) numDocs));
assertTrue(collected.get());
assertTrue(context.queryResult().terminatedEarly());
assertThat(context.terminateAfter(), equalTo(0));
- assertThat(context.queryResult().getTotalHits(), equalTo(numDocs));
+ assertThat(context.queryResult().getTotalHits(), equalTo((long) numDocs));
FieldDoc firstDoc = (FieldDoc) context.queryResult().topDocs().scoreDocs[0];
for (int i = 0; i < sort.getSort().length; i++) {
@SuppressWarnings("unchecked")