lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject [04/19] lucene-solr:jira/solr-9854: LUCENE-5325: Add test for missing values in sorts
Date Mon, 02 Jan 2017 10:18:25 GMT
LUCENE-5325: Add test for missing values in sorts


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/a4335c0e
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/a4335c0e
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/a4335c0e

Branch: refs/heads/jira/solr-9854
Commit: a4335c0e9f01275c7d6e807813d9818b6e59d76e
Parents: 0072382
Author: Alan Woodward <romseygeek@apache.org>
Authored: Thu Dec 29 14:44:11 2016 +0000
Committer: Alan Woodward <romseygeek@apache.org>
Committed: Thu Dec 29 20:26:36 2016 +0000

----------------------------------------------------------------------
 .../org/apache/lucene/search/TestDoubleValuesSource.java    | 9 +++++++++
 .../test/org/apache/lucene/search/TestLongValuesSource.java | 9 +++++++++
 2 files changed, 18 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/a4335c0e/lucene/core/src/test/org/apache/lucene/search/TestDoubleValuesSource.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/test/org/apache/lucene/search/TestDoubleValuesSource.java b/lucene/core/src/test/org/apache/lucene/search/TestDoubleValuesSource.java
index 3860963..13a5168 100644
--- a/lucene/core/src/test/org/apache/lucene/search/TestDoubleValuesSource.java
+++ b/lucene/core/src/test/org/apache/lucene/search/TestDoubleValuesSource.java
@@ -53,6 +53,8 @@ public class TestDoubleValuesSource extends LuceneTestCase {
       document.add(new NumericDocValuesField("long", random().nextLong()));
       document.add(new FloatDocValuesField("float", random().nextFloat()));
       document.add(new DoubleDocValuesField("double", random().nextDouble()));
+      if (i == 545)
+        document.add(new DoubleDocValuesField("onefield", 45.72));
       iw.addDocument(document);
     }
     reader = iw.getReader();
@@ -67,6 +69,13 @@ public class TestDoubleValuesSource extends LuceneTestCase {
     super.tearDown();
   }
 
+  public void testSortMissing() throws Exception {
+    DoubleValuesSource onefield = DoubleValuesSource.fromDoubleField("onefield");
+    TopDocs results = searcher.search(new MatchAllDocsQuery(), 1, new Sort(onefield.getSortField(true)));
+    FieldDoc first = (FieldDoc) results.scoreDocs[0];
+    assertEquals(45.72, first.fields[0]);
+  }
+
   public void testSimpleFieldEquivalences() throws Exception {
     checkSorts(new MatchAllDocsQuery(), new Sort(new SortField("int", SortField.Type.INT,
random().nextBoolean())));
     checkSorts(new MatchAllDocsQuery(), new Sort(new SortField("long", SortField.Type.LONG,
random().nextBoolean())));

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/a4335c0e/lucene/core/src/test/org/apache/lucene/search/TestLongValuesSource.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/test/org/apache/lucene/search/TestLongValuesSource.java b/lucene/core/src/test/org/apache/lucene/search/TestLongValuesSource.java
index 9148ad5..8b20be5 100644
--- a/lucene/core/src/test/org/apache/lucene/search/TestLongValuesSource.java
+++ b/lucene/core/src/test/org/apache/lucene/search/TestLongValuesSource.java
@@ -49,6 +49,8 @@ public class TestLongValuesSource extends LuceneTestCase {
       document.add(newTextField("oddeven", (i % 2 == 0) ? "even" : "odd", Field.Store.NO));
       document.add(new NumericDocValuesField("int", random().nextInt()));
       document.add(new NumericDocValuesField("long", random().nextLong()));
+      if (i == 545)
+        document.add(new NumericDocValuesField("onefield", 45));
       iw.addDocument(document);
     }
     reader = iw.getReader();
@@ -63,6 +65,13 @@ public class TestLongValuesSource extends LuceneTestCase {
     super.tearDown();
   }
 
+  public void testSortMissing() throws Exception {
+    LongValuesSource onefield = LongValuesSource.fromLongField("onefield");
+    TopDocs results = searcher.search(new MatchAllDocsQuery(), 1, new Sort(onefield.getSortField(true)));
+    FieldDoc first = (FieldDoc) results.scoreDocs[0];
+    assertEquals(45L, first.fields[0]);
+  }
+
   public void testSimpleFieldEquivalences() throws Exception {
     checkSorts(new MatchAllDocsQuery(), new Sort(new SortField("int", SortField.Type.INT,
random().nextBoolean())));
     checkSorts(new MatchAllDocsQuery(), new Sort(new SortField("long", SortField.Type.LONG,
random().nextBoolean())));


Mime
View raw message