|
32 | 32 | import java.util.Locale; |
33 | 33 | import java.util.Map; |
34 | 34 | import java.util.Random; |
| 35 | +import org.apache.lucene.document.DoublePoint; |
| 36 | +import org.apache.lucene.document.FloatPoint; |
35 | 37 | import org.apache.lucene.search.BooleanClause; |
36 | 38 | import org.apache.lucene.search.BooleanQuery; |
37 | 39 | import org.apache.lucene.search.BoostQuery; |
|
40 | 42 | import org.apache.lucene.search.IndexOrDocValuesQuery; |
41 | 43 | import org.apache.lucene.search.IndexSearcher; |
42 | 44 | import org.apache.lucene.search.PointInSetQuery; |
| 45 | +import org.apache.lucene.search.PointRangeQuery; |
43 | 46 | import org.apache.lucene.search.Query; |
44 | 47 | import org.apache.lucene.search.TermInSetQuery; |
45 | 48 | import org.apache.lucene.search.TermQuery; |
@@ -1834,29 +1837,55 @@ public void testFieldExistsQueries() throws SyntaxError { |
1834 | 1837 | createdQuery instanceof FieldExistsQuery); |
1835 | 1838 | } else if (schemaField.getType().getNumberType() == NumberType.DOUBLE |
1836 | 1839 | || schemaField.getType().getNumberType() == NumberType.FLOAT) { |
1837 | | - assertTrue( |
1838 | | - "PointField with NaN values must include \"exists or NaN\" if the field doesn't have norms or docValues: \"" |
1839 | | - + query |
1840 | | - + "\".", |
1841 | | - createdQuery instanceof ConstantScoreQuery); |
1842 | | - assertTrue( |
1843 | | - "PointField with NaN values must include \"exists or NaN\" if the field doesn't have norms or docValues: \"" |
1844 | | - + query |
1845 | | - + "\".", |
1846 | | - ((ConstantScoreQuery) createdQuery).getQuery() instanceof BooleanQuery); |
1847 | | - assertEquals( |
1848 | | - "PointField with NaN values must include \"exists or NaN\" if the field doesn't have norms or docValues: \"" |
1849 | | - + query |
1850 | | - + "\". This boolean query must be an OR.", |
1851 | | - 1, |
1852 | | - ((BooleanQuery) ((ConstantScoreQuery) createdQuery).getQuery()) |
1853 | | - .getMinimumNumberShouldMatch()); |
1854 | | - assertEquals( |
1855 | | - "PointField with NaN values must include \"exists or NaN\" if the field doesn't have norms or docValues: \"" |
1856 | | - + query |
1857 | | - + "\". This boolean query must have 2 clauses.", |
1858 | | - 2, |
1859 | | - ((BooleanQuery) ((ConstantScoreQuery) createdQuery).getQuery()).clauses().size()); |
| 1840 | + if (schemaField.getType().isPointField()) { |
| 1841 | + assertTrue( |
| 1842 | + "PointField with NaN values must do a range query with an upper bound of NaN (Sorted higher than +Infinity) if the field doesn't have norms or docValues: \"" |
| 1843 | + + query |
| 1844 | + + "\".", |
| 1845 | + createdQuery instanceof PointRangeQuery); |
| 1846 | + if (schemaField.getType().getNumberType() == NumberType.DOUBLE) { |
| 1847 | + assertEquals( |
| 1848 | + "PointField with NaN values must do a range query with an upper bound of NaN (Sorted higher than +Infinity) if the field doesn't have norms or docValues: \"" |
| 1849 | + + query |
| 1850 | + + "\".", |
| 1851 | + Double.NaN, |
| 1852 | + DoublePoint.decodeDimension( |
| 1853 | + ((PointRangeQuery) createdQuery).getUpperPoint(), 0), |
| 1854 | + 0); |
| 1855 | + } else { |
| 1856 | + assertEquals( |
| 1857 | + "PointField with NaN values must do a range query with an upper bound of NaN (Sorted higher than +Infinity) if the field doesn't have norms or docValues: \"" |
| 1858 | + + query |
| 1859 | + + "\".", |
| 1860 | + Float.NaN, |
| 1861 | + FloatPoint.decodeDimension(((PointRangeQuery) createdQuery).getUpperPoint(), 0), |
| 1862 | + 0); |
| 1863 | + } |
| 1864 | + } else { |
| 1865 | + assertTrue( |
| 1866 | + "PointField with NaN values must include \"exists or NaN\" if the field doesn't have norms or docValues: \"" |
| 1867 | + + query |
| 1868 | + + "\".", |
| 1869 | + createdQuery instanceof ConstantScoreQuery); |
| 1870 | + assertTrue( |
| 1871 | + "NumericField with NaN values must include \"exists or NaN\" if the field doesn't have norms or docValues: \"" |
| 1872 | + + query |
| 1873 | + + "\".", |
| 1874 | + ((ConstantScoreQuery) createdQuery).getQuery() instanceof BooleanQuery); |
| 1875 | + assertEquals( |
| 1876 | + "NumericField with NaN values must include \"exists or NaN\" if the field doesn't have norms or docValues: \"" |
| 1877 | + + query |
| 1878 | + + "\". This boolean query must be an OR.", |
| 1879 | + 1, |
| 1880 | + ((BooleanQuery) ((ConstantScoreQuery) createdQuery).getQuery()) |
| 1881 | + .getMinimumNumberShouldMatch()); |
| 1882 | + assertEquals( |
| 1883 | + "NumericField with NaN values must include \"exists or NaN\" if the field doesn't have norms or docValues: \"" |
| 1884 | + + query |
| 1885 | + + "\". This boolean query must have 2 clauses.", |
| 1886 | + 2, |
| 1887 | + ((BooleanQuery) ((ConstantScoreQuery) createdQuery).getQuery()).clauses().size()); |
| 1888 | + } |
1860 | 1889 | } else { |
1861 | 1890 | assertFalse( |
1862 | 1891 | "Field doesn't have docValues, so existence query \"" |
|
0 commit comments