mirror of https://github.com/apache/lucene.git
SOLR-5222: test proving that dynamicField's using docValues work as expected with missing values
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1521304 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7ccb123261
commit
54427466aa
|
@ -54,6 +54,33 @@
|
|||
<field name="stringdv" type="string" indexed="false" stored="false" docValues="true"/>
|
||||
<field name="stringdv_missingfirst" type="string" indexed="false" stored="false" docValues="true" sortMissingFirst="true"/>
|
||||
<field name="stringdv_missinglast" type="string" indexed="false" stored="false" docValues="true" sortMissingLast="true"/>
|
||||
|
||||
|
||||
<dynamicField name="*_floatdv" type="float" indexed="false" stored="false" docValues="true"/>
|
||||
<dynamicField name="*_floatdv_missingfirst" type="float" indexed="false" stored="false" docValues="true" sortMissingFirst="true"/>
|
||||
<dynamicField name="*_floatdv_missinglast" type="float" indexed="false" stored="false" docValues="true" sortMissingLast="true"/>
|
||||
|
||||
<dynamicField name="*_intdv" type="int" indexed="false" stored="false" docValues="true"/>
|
||||
<dynamicField name="*_intdv_missingfirst" type="int" indexed="false" stored="false" docValues="true" sortMissingFirst="true"/>
|
||||
<dynamicField name="*_intdv_missinglast" type="int" indexed="false" stored="false" docValues="true" sortMissingLast="true"/>
|
||||
|
||||
<dynamicField name="*_doubledv" type="double" indexed="false" stored="false" docValues="true"/>
|
||||
<dynamicField name="*_doubledv_missingfirst" type="double" indexed="false" stored="false" docValues="true" sortMissingFirst="true"/>
|
||||
<dynamicField name="*_doubledv_missinglast" type="double" indexed="false" stored="false" docValues="true" sortMissingLast="true"/>
|
||||
|
||||
<dynamicField name="*_longdv" type="long" indexed="false" stored="false" docValues="true"/>
|
||||
<dynamicField name="*_longdv_missingfirst" type="long" indexed="false" stored="false" docValues="true" sortMissingFirst="true"/>
|
||||
<dynamicField name="*_longdv_missinglast" type="long" indexed="false" stored="false" docValues="true" sortMissingLast="true"/>
|
||||
|
||||
<dynamicField name="*_datedv" type="date" indexed="false" stored="false" docValues="true"/>
|
||||
<dynamicField name="*_datedv_missingfirst" type="date" indexed="false" stored="false" docValues="true" sortMissingFirst="true"/>
|
||||
<dynamicField name="*_datedv_missinglast" type="date" indexed="false" stored="false" docValues="true" sortMissingLast="true"/>
|
||||
|
||||
<dynamicField name="*_stringdv" type="string" indexed="false" stored="false" docValues="true"/>
|
||||
<dynamicField name="*_stringdv_missingfirst" type="string" indexed="false" stored="false" docValues="true" sortMissingFirst="true"/>
|
||||
<dynamicField name="*_stringdv_missinglast" type="string" indexed="false" stored="false" docValues="true" sortMissingLast="true"/>
|
||||
|
||||
|
||||
</fields>
|
||||
|
||||
<uniqueKey>id</uniqueKey>
|
||||
|
|
|
@ -39,429 +39,371 @@ public class DocValuesMissingTest extends SolrTestCaseJ4 {
|
|||
assertU(commit());
|
||||
}
|
||||
|
||||
/** float with default lucene sort (treats as 0) */
|
||||
public void testFloatSort() throws Exception {
|
||||
/** numeric default lucene sort (relative to presumed default value of 0) */
|
||||
private void checkSortMissingDefault(final String field,
|
||||
final String negative,
|
||||
final String positive) {
|
||||
assertU(adoc("id", "0")); // missing
|
||||
assertU(adoc("id", "1", "floatdv", "-1.3"));
|
||||
assertU(adoc("id", "2", "floatdv", "4.2"));
|
||||
assertU(adoc("id", "1", field, negative));
|
||||
assertU(adoc("id", "2", field, positive));
|
||||
assertU(commit());
|
||||
assertQ(req("q", "*:*", "sort", "floatdv asc"),
|
||||
assertQ(req("q", "*:*", "sort", field+" asc"),
|
||||
"//result/doc[1]/str[@name='id'][.=1]",
|
||||
"//result/doc[2]/str[@name='id'][.=0]",
|
||||
"//result/doc[3]/str[@name='id'][.=2]");
|
||||
assertQ(req("q", "*:*", "sort", "floatdv desc"),
|
||||
assertQ(req("q", "*:*", "sort", field+" desc"),
|
||||
"//result/doc[1]/str[@name='id'][.=2]",
|
||||
"//result/doc[2]/str[@name='id'][.=0]",
|
||||
"//result/doc[3]/str[@name='id'][.=1]");
|
||||
}
|
||||
|
||||
/** sort missing always first */
|
||||
private void checkSortMissingFirst(final String field,
|
||||
final String low,
|
||||
final String high) {
|
||||
assertU(adoc("id", "0")); // missing
|
||||
assertU(adoc("id", "1", field, low));
|
||||
assertU(adoc("id", "2", field, high));
|
||||
assertU(commit());
|
||||
assertQ(req("q", "*:*", "sort", field+" asc"),
|
||||
"//result/doc[1]/str[@name='id'][.=0]",
|
||||
"//result/doc[2]/str[@name='id'][.=1]",
|
||||
"//result/doc[3]/str[@name='id'][.=2]");
|
||||
assertQ(req("q", "*:*", "sort", field+" desc"),
|
||||
"//result/doc[1]/str[@name='id'][.=0]",
|
||||
"//result/doc[2]/str[@name='id'][.=2]",
|
||||
"//result/doc[3]/str[@name='id'][.=1]");
|
||||
}
|
||||
|
||||
/** sort missing always last */
|
||||
private void checkSortMissingLast(final String field,
|
||||
final String low,
|
||||
final String high) {
|
||||
|
||||
assertU(adoc("id", "0")); // missing
|
||||
assertU(adoc("id", "1", field, low));
|
||||
assertU(adoc("id", "2", field, high));
|
||||
assertU(commit());
|
||||
assertQ(req("q", "*:*", "sort", field+" asc"),
|
||||
"//result/doc[1]/str[@name='id'][.=1]",
|
||||
"//result/doc[2]/str[@name='id'][.=2]",
|
||||
"//result/doc[3]/str[@name='id'][.=0]");
|
||||
assertQ(req("q", "*:*", "sort", field+" desc"),
|
||||
"//result/doc[1]/str[@name='id'][.=2]",
|
||||
"//result/doc[2]/str[@name='id'][.=1]",
|
||||
"//result/doc[3]/str[@name='id'][.=0]");
|
||||
|
||||
}
|
||||
|
||||
/** function query based on missing */
|
||||
private void checkSortMissingFunction(final String field,
|
||||
final String low,
|
||||
final String high) {
|
||||
assertU(adoc("id", "0")); // missing
|
||||
assertU(adoc("id", "1", field, low));
|
||||
assertU(adoc("id", "2", field, high));
|
||||
assertU(commit());
|
||||
assertQ(req("q", "*:*", "fl", "e:exists("+field+")", "sort", "id asc"),
|
||||
"//result/doc[1]/bool[@name='e'][.='false']",
|
||||
"//result/doc[2]/bool[@name='e'][.='true']",
|
||||
"//result/doc[3]/bool[@name='e'][.='true']");
|
||||
}
|
||||
|
||||
/** missing facet count */
|
||||
private void checkSortMissingFacet(final String field,
|
||||
final String low,
|
||||
final String high) {
|
||||
assertU(adoc("id", "0")); // missing
|
||||
assertU(adoc("id", "1")); // missing
|
||||
assertU(adoc("id", "2", field, low));
|
||||
assertU(adoc("id", "3", field, high));
|
||||
assertU(commit());
|
||||
assertQ(req("q", "*:*", "facet", "true", "facet.field", field,
|
||||
"facet.mincount", "1", "facet.missing", "true"),
|
||||
"//lst[@name='facet_fields']/lst[@name='"+field+"']/int[@name='"+low+"'][.=1]",
|
||||
"//lst[@name='facet_fields']/lst[@name='"+field+"']/int[@name='"+high+"'][.=1]",
|
||||
"//lst[@name='facet_fields']/lst[@name='"+field+"']/int[.=2]");
|
||||
}
|
||||
|
||||
/** float with default lucene sort (treats as 0) */
|
||||
public void testFloatSort() throws Exception {
|
||||
checkSortMissingDefault("floatdv", "-1.3", "4.2");
|
||||
}
|
||||
/** dynamic float with default lucene sort (treats as 0) */
|
||||
public void testDynFloatSort() throws Exception {
|
||||
checkSortMissingDefault("dyn_floatdv", "-1.3", "4.2");
|
||||
}
|
||||
|
||||
/** float with sort missing always first */
|
||||
public void testFloatSortMissingFirst() throws Exception {
|
||||
assertU(adoc("id", "0")); // missing
|
||||
assertU(adoc("id", "1", "floatdv_missingfirst", "-1.3"));
|
||||
assertU(adoc("id", "2", "floatdv_missingfirst", "4.2"));
|
||||
assertU(commit());
|
||||
assertQ(req("q", "*:*", "sort", "floatdv_missingfirst asc"),
|
||||
"//result/doc[1]/str[@name='id'][.=0]",
|
||||
"//result/doc[2]/str[@name='id'][.=1]",
|
||||
"//result/doc[3]/str[@name='id'][.=2]");
|
||||
assertQ(req("q", "*:*", "sort", "floatdv_missingfirst desc"),
|
||||
"//result/doc[1]/str[@name='id'][.=0]",
|
||||
"//result/doc[2]/str[@name='id'][.=2]",
|
||||
"//result/doc[3]/str[@name='id'][.=1]");
|
||||
checkSortMissingFirst("floatdv_missingfirst", "-1.3", "4.2");
|
||||
}
|
||||
/** dynamic float with sort missing always first */
|
||||
public void testDynFloatSortMissingFirst() throws Exception {
|
||||
checkSortMissingFirst("dyn_floatdv_missingfirst", "-1.3", "4.2");
|
||||
}
|
||||
|
||||
/** float with sort missing always last */
|
||||
public void testFloatSortMissingLast() throws Exception {
|
||||
assertU(adoc("id", "0")); // missing
|
||||
assertU(adoc("id", "1", "floatdv_missinglast", "-1.3"));
|
||||
assertU(adoc("id", "2", "floatdv_missinglast", "4.2"));
|
||||
assertU(commit());
|
||||
assertQ(req("q", "*:*", "sort", "floatdv_missinglast asc"),
|
||||
"//result/doc[1]/str[@name='id'][.=1]",
|
||||
"//result/doc[2]/str[@name='id'][.=2]",
|
||||
"//result/doc[3]/str[@name='id'][.=0]");
|
||||
assertQ(req("q", "*:*", "sort", "floatdv_missinglast desc"),
|
||||
"//result/doc[1]/str[@name='id'][.=2]",
|
||||
"//result/doc[2]/str[@name='id'][.=1]",
|
||||
"//result/doc[3]/str[@name='id'][.=0]");
|
||||
checkSortMissingLast("floatdv_missinglast", "-1.3", "4.2");
|
||||
}
|
||||
/** dynamic float with sort missing always last */
|
||||
public void testDynFloatSortMissingLast() throws Exception {
|
||||
checkSortMissingLast("dyn_floatdv_missinglast", "-1.3", "4.2");
|
||||
}
|
||||
|
||||
/** float function query based on missing */
|
||||
public void testFloatMissingFunction() throws Exception {
|
||||
assertU(adoc("id", "0")); // missing
|
||||
assertU(adoc("id", "1", "floatdv", "-1.3"));
|
||||
assertU(adoc("id", "2", "floatdv", "4.2"));
|
||||
assertU(commit());
|
||||
assertQ(req("q", "*:*", "fl", "e:exists(floatdv)", "sort", "id asc"),
|
||||
"//result/doc[1]/bool[@name='e'][.='false']",
|
||||
"//result/doc[2]/bool[@name='e'][.='true']",
|
||||
"//result/doc[3]/bool[@name='e'][.='true']");
|
||||
checkSortMissingFunction("floatdv", "-1.3", "4.2");
|
||||
}
|
||||
/** dyanmic float function query based on missing */
|
||||
public void testDynFloatMissingFunction() throws Exception {
|
||||
checkSortMissingFunction("dyn_floatdv", "-1.3", "4.2");
|
||||
}
|
||||
|
||||
/** float missing facet count */
|
||||
public void testFloatMissingFacet() throws Exception {
|
||||
assertU(adoc("id", "0")); // missing
|
||||
assertU(adoc("id", "1")); // missing
|
||||
assertU(adoc("id", "2", "floatdv", "-1.3"));
|
||||
assertU(adoc("id", "3", "floatdv", "4.2"));
|
||||
assertU(commit());
|
||||
assertQ(req("q", "*:*", "facet", "true", "facet.field", "floatdv", "facet.mincount", "1", "facet.missing", "true"),
|
||||
"//lst[@name='facet_fields']/lst[@name='floatdv']/int[@name='-1.3'][.=1]",
|
||||
"//lst[@name='facet_fields']/lst[@name='floatdv']/int[@name='4.2'][.=1]",
|
||||
"//lst[@name='facet_fields']/lst[@name='floatdv']/int[.=2]");
|
||||
checkSortMissingFacet("floatdv", "-1.3", "4.2");
|
||||
}
|
||||
/** dynamic float missing facet count */
|
||||
public void testDynFloatMissingFacet() throws Exception {
|
||||
checkSortMissingFacet("dyn_floatdv", "-1.3", "4.2");
|
||||
}
|
||||
|
||||
/** int with default lucene sort (treats as 0) */
|
||||
public void testIntSort() throws Exception {
|
||||
assertU(adoc("id", "0")); // missing
|
||||
assertU(adoc("id", "1", "intdv", "-1"));
|
||||
assertU(adoc("id", "2", "intdv", "4"));
|
||||
assertU(commit());
|
||||
assertQ(req("q", "*:*", "sort", "intdv asc"),
|
||||
"//result/doc[1]/str[@name='id'][.=1]",
|
||||
"//result/doc[2]/str[@name='id'][.=0]",
|
||||
"//result/doc[3]/str[@name='id'][.=2]");
|
||||
assertQ(req("q", "*:*", "sort", "intdv desc"),
|
||||
"//result/doc[1]/str[@name='id'][.=2]",
|
||||
"//result/doc[2]/str[@name='id'][.=0]",
|
||||
"//result/doc[3]/str[@name='id'][.=1]");
|
||||
checkSortMissingDefault("intdv", "-1", "4");
|
||||
}
|
||||
/** dynamic int with default lucene sort (treats as 0) */
|
||||
public void testDynIntSort() throws Exception {
|
||||
checkSortMissingDefault("dyn_intdv", "-1", "4");
|
||||
}
|
||||
|
||||
/** int with sort missing always first */
|
||||
public void testIntSortMissingFirst() throws Exception {
|
||||
assertU(adoc("id", "0")); // missing
|
||||
assertU(adoc("id", "1", "intdv_missingfirst", "-1"));
|
||||
assertU(adoc("id", "2", "intdv_missingfirst", "4"));
|
||||
assertU(commit());
|
||||
assertQ(req("q", "*:*", "sort", "intdv_missingfirst asc"),
|
||||
"//result/doc[1]/str[@name='id'][.=0]",
|
||||
"//result/doc[2]/str[@name='id'][.=1]",
|
||||
"//result/doc[3]/str[@name='id'][.=2]");
|
||||
assertQ(req("q", "*:*", "sort", "intdv_missingfirst desc"),
|
||||
"//result/doc[1]/str[@name='id'][.=0]",
|
||||
"//result/doc[2]/str[@name='id'][.=2]",
|
||||
"//result/doc[3]/str[@name='id'][.=1]");
|
||||
checkSortMissingFirst("intdv_missingfirst", "-1", "4");
|
||||
}
|
||||
/** dynamic int with sort missing always first */
|
||||
public void testDynIntSortMissingFirst() throws Exception {
|
||||
checkSortMissingFirst("dyn_intdv_missingfirst", "-1", "4");
|
||||
}
|
||||
|
||||
/** int with sort missing always last */
|
||||
public void testIntSortMissingLast() throws Exception {
|
||||
assertU(adoc("id", "0")); // missing
|
||||
assertU(adoc("id", "1", "intdv_missinglast", "-1"));
|
||||
assertU(adoc("id", "2", "intdv_missinglast", "4"));
|
||||
assertU(commit());
|
||||
assertQ(req("q", "*:*", "sort", "intdv_missinglast asc"),
|
||||
"//result/doc[1]/str[@name='id'][.=1]",
|
||||
"//result/doc[2]/str[@name='id'][.=2]",
|
||||
"//result/doc[3]/str[@name='id'][.=0]");
|
||||
assertQ(req("q", "*:*", "sort", "intdv_missinglast desc"),
|
||||
"//result/doc[1]/str[@name='id'][.=2]",
|
||||
"//result/doc[2]/str[@name='id'][.=1]",
|
||||
"//result/doc[3]/str[@name='id'][.=0]");
|
||||
checkSortMissingLast("intdv_missinglast", "-1", "4");
|
||||
}
|
||||
/** dynamic int with sort missing always last */
|
||||
public void testDynIntSortMissingLast() throws Exception {
|
||||
checkSortMissingLast("dyn_intdv_missinglast", "-1", "4");
|
||||
}
|
||||
|
||||
/** int function query based on missing */
|
||||
public void testIntMissingFunction() throws Exception {
|
||||
assertU(adoc("id", "0")); // missing
|
||||
assertU(adoc("id", "1", "intdv", "-1"));
|
||||
assertU(adoc("id", "2", "intdv", "4"));
|
||||
assertU(commit());
|
||||
assertQ(req("q", "*:*", "fl", "e:exists(intdv)", "sort", "id asc"),
|
||||
"//result/doc[1]/bool[@name='e'][.='false']",
|
||||
"//result/doc[2]/bool[@name='e'][.='true']",
|
||||
"//result/doc[3]/bool[@name='e'][.='true']");
|
||||
checkSortMissingFunction("intdv", "-1", "4");
|
||||
}
|
||||
/** dynamic int function query based on missing */
|
||||
public void testDynIntMissingFunction() throws Exception {
|
||||
checkSortMissingFunction("dyn_intdv", "-1", "4");
|
||||
}
|
||||
|
||||
/** int missing facet count */
|
||||
public void testIntMissingFacet() throws Exception {
|
||||
assertU(adoc("id", "0")); // missing
|
||||
assertU(adoc("id", "1")); // missing
|
||||
assertU(adoc("id", "2", "intdv", "-1"));
|
||||
assertU(adoc("id", "3", "intdv", "4"));
|
||||
assertU(commit());
|
||||
assertQ(req("q", "*:*", "facet", "true", "facet.field", "intdv", "facet.mincount", "1", "facet.missing", "true"),
|
||||
"//lst[@name='facet_fields']/lst[@name='intdv']/int[@name='-1'][.=1]",
|
||||
"//lst[@name='facet_fields']/lst[@name='intdv']/int[@name='4'][.=1]",
|
||||
"//lst[@name='facet_fields']/lst[@name='intdv']/int[.=2]");
|
||||
checkSortMissingFacet("intdv", "-1", "4");
|
||||
}
|
||||
/** dynamic int missing facet count */
|
||||
public void testDynIntMissingFacet() throws Exception {
|
||||
checkSortMissingFacet("dyn_intdv", "-1", "4");
|
||||
}
|
||||
|
||||
/** double with default lucene sort (treats as 0) */
|
||||
public void testDoubleSort() throws Exception {
|
||||
assertU(adoc("id", "0")); // missing
|
||||
assertU(adoc("id", "1", "doubledv", "-1.3"));
|
||||
assertU(adoc("id", "2", "doubledv", "4.2"));
|
||||
assertU(commit());
|
||||
assertQ(req("q", "*:*", "sort", "doubledv asc"),
|
||||
"//result/doc[1]/str[@name='id'][.=1]",
|
||||
"//result/doc[2]/str[@name='id'][.=0]",
|
||||
"//result/doc[3]/str[@name='id'][.=2]");
|
||||
assertQ(req("q", "*:*", "sort", "doubledv desc"),
|
||||
"//result/doc[1]/str[@name='id'][.=2]",
|
||||
"//result/doc[2]/str[@name='id'][.=0]",
|
||||
"//result/doc[3]/str[@name='id'][.=1]");
|
||||
checkSortMissingDefault("doubledv", "-1.3", "4.2");
|
||||
}
|
||||
/** dynamic double with default lucene sort (treats as 0) */
|
||||
public void testDynDoubleSort() throws Exception {
|
||||
checkSortMissingDefault("dyn_doubledv", "-1.3", "4.2");
|
||||
}
|
||||
|
||||
/** double with sort missing always first */
|
||||
public void testDoubleSortMissingFirst() throws Exception {
|
||||
assertU(adoc("id", "0")); // missing
|
||||
assertU(adoc("id", "1", "doubledv_missingfirst", "-1.3"));
|
||||
assertU(adoc("id", "2", "doubledv_missingfirst", "4.2"));
|
||||
assertU(commit());
|
||||
assertQ(req("q", "*:*", "sort", "doubledv_missingfirst asc"),
|
||||
"//result/doc[1]/str[@name='id'][.=0]",
|
||||
"//result/doc[2]/str[@name='id'][.=1]",
|
||||
"//result/doc[3]/str[@name='id'][.=2]");
|
||||
assertQ(req("q", "*:*", "sort", "doubledv_missingfirst desc"),
|
||||
"//result/doc[1]/str[@name='id'][.=0]",
|
||||
"//result/doc[2]/str[@name='id'][.=2]",
|
||||
"//result/doc[3]/str[@name='id'][.=1]");
|
||||
checkSortMissingFirst("doubledv_missingfirst", "-1.3", "4.2");
|
||||
}
|
||||
/** dynamic double with sort missing always first */
|
||||
public void testDynDoubleSortMissingFirst() throws Exception {
|
||||
checkSortMissingFirst("dyn_doubledv_missingfirst", "-1.3", "4.2");
|
||||
}
|
||||
|
||||
/** double with sort missing always last */
|
||||
public void testDoubleSortMissingLast() throws Exception {
|
||||
assertU(adoc("id", "0")); // missing
|
||||
assertU(adoc("id", "1", "doubledv_missinglast", "-1.3"));
|
||||
assertU(adoc("id", "2", "doubledv_missinglast", "4.2"));
|
||||
assertU(commit());
|
||||
assertQ(req("q", "*:*", "sort", "doubledv_missinglast asc"),
|
||||
"//result/doc[1]/str[@name='id'][.=1]",
|
||||
"//result/doc[2]/str[@name='id'][.=2]",
|
||||
"//result/doc[3]/str[@name='id'][.=0]");
|
||||
assertQ(req("q", "*:*", "sort", "doubledv_missinglast desc"),
|
||||
"//result/doc[1]/str[@name='id'][.=2]",
|
||||
"//result/doc[2]/str[@name='id'][.=1]",
|
||||
"//result/doc[3]/str[@name='id'][.=0]");
|
||||
checkSortMissingLast("doubledv_missinglast", "-1.3", "4.2");
|
||||
}
|
||||
/** dynamic double with sort missing always last */
|
||||
public void testDynDoubleSortMissingLast() throws Exception {
|
||||
checkSortMissingLast("dyn_doubledv_missinglast", "-1.3", "4.2");
|
||||
}
|
||||
|
||||
/** double function query based on missing */
|
||||
public void testDoubleMissingFunction() throws Exception {
|
||||
assertU(adoc("id", "0")); // missing
|
||||
assertU(adoc("id", "1", "doubledv", "-1.3"));
|
||||
assertU(adoc("id", "2", "doubledv", "4.2"));
|
||||
assertU(commit());
|
||||
assertQ(req("q", "*:*", "fl", "e:exists(doubledv)", "sort", "id asc"),
|
||||
"//result/doc[1]/bool[@name='e'][.='false']",
|
||||
"//result/doc[2]/bool[@name='e'][.='true']",
|
||||
"//result/doc[3]/bool[@name='e'][.='true']");
|
||||
checkSortMissingFunction("doubledv", "-1.3", "4.2");
|
||||
}
|
||||
/** dyanmic double function query based on missing */
|
||||
public void testDynDoubleMissingFunction() throws Exception {
|
||||
checkSortMissingFunction("dyn_doubledv", "-1.3", "4.2");
|
||||
}
|
||||
|
||||
/** double missing facet count */
|
||||
public void testDoubleMissingFacet() throws Exception {
|
||||
assertU(adoc("id", "0")); // missing
|
||||
assertU(adoc("id", "1")); // missing
|
||||
assertU(adoc("id", "2", "doubledv", "-1.3"));
|
||||
assertU(adoc("id", "3", "doubledv", "4.2"));
|
||||
assertU(commit());
|
||||
assertQ(req("q", "*:*", "facet", "true", "facet.field", "doubledv", "facet.mincount", "1", "facet.missing", "true"),
|
||||
"//lst[@name='facet_fields']/lst[@name='doubledv']/int[@name='-1.3'][.=1]",
|
||||
"//lst[@name='facet_fields']/lst[@name='doubledv']/int[@name='4.2'][.=1]",
|
||||
"//lst[@name='facet_fields']/lst[@name='doubledv']/int[.=2]");
|
||||
checkSortMissingFacet("doubledv", "-1.3", "4.2");
|
||||
}
|
||||
/** dynamic double missing facet count */
|
||||
public void testDynDoubleMissingFacet() throws Exception {
|
||||
checkSortMissingFacet("dyn_doubledv", "-1.3", "4.2");
|
||||
}
|
||||
|
||||
/** long with default lucene sort (treats as 0) */
|
||||
public void testLongSort() throws Exception {
|
||||
assertU(adoc("id", "0")); // missing
|
||||
assertU(adoc("id", "1", "longdv", "-1"));
|
||||
assertU(adoc("id", "2", "longdv", "4"));
|
||||
assertU(commit());
|
||||
assertQ(req("q", "*:*", "sort", "longdv asc"),
|
||||
"//result/doc[1]/str[@name='id'][.=1]",
|
||||
"//result/doc[2]/str[@name='id'][.=0]",
|
||||
"//result/doc[3]/str[@name='id'][.=2]");
|
||||
assertQ(req("q", "*:*", "sort", "longdv desc"),
|
||||
"//result/doc[1]/str[@name='id'][.=2]",
|
||||
"//result/doc[2]/str[@name='id'][.=0]",
|
||||
"//result/doc[3]/str[@name='id'][.=1]");
|
||||
checkSortMissingDefault("longdv", "-1", "4");
|
||||
}
|
||||
/** dynamic long with default lucene sort (treats as 0) */
|
||||
public void testDynLongSort() throws Exception {
|
||||
checkSortMissingDefault("dyn_longdv", "-1", "4");
|
||||
}
|
||||
|
||||
/** long with sort missing always first */
|
||||
public void testLongSortMissingFirst() throws Exception {
|
||||
assertU(adoc("id", "0")); // missing
|
||||
assertU(adoc("id", "1", "longdv_missingfirst", "-1"));
|
||||
assertU(adoc("id", "2", "longdv_missingfirst", "4"));
|
||||
assertU(commit());
|
||||
assertQ(req("q", "*:*", "sort", "longdv_missingfirst asc"),
|
||||
"//result/doc[1]/str[@name='id'][.=0]",
|
||||
"//result/doc[2]/str[@name='id'][.=1]",
|
||||
"//result/doc[3]/str[@name='id'][.=2]");
|
||||
assertQ(req("q", "*:*", "sort", "longdv_missingfirst desc"),
|
||||
"//result/doc[1]/str[@name='id'][.=0]",
|
||||
"//result/doc[2]/str[@name='id'][.=2]",
|
||||
"//result/doc[3]/str[@name='id'][.=1]");
|
||||
checkSortMissingFirst("longdv_missingfirst", "-1", "4");
|
||||
}
|
||||
/** dynamic long with sort missing always first */
|
||||
public void testDynLongSortMissingFirst() throws Exception {
|
||||
checkSortMissingFirst("dyn_longdv_missingfirst", "-1", "4");
|
||||
}
|
||||
|
||||
/** long with sort missing always last */
|
||||
public void testLongSortMissingLast() throws Exception {
|
||||
assertU(adoc("id", "0")); // missing
|
||||
assertU(adoc("id", "1", "longdv_missinglast", "-1"));
|
||||
assertU(adoc("id", "2", "longdv_missinglast", "4"));
|
||||
assertU(commit());
|
||||
assertQ(req("q", "*:*", "sort", "longdv_missinglast asc"),
|
||||
"//result/doc[1]/str[@name='id'][.=1]",
|
||||
"//result/doc[2]/str[@name='id'][.=2]",
|
||||
"//result/doc[3]/str[@name='id'][.=0]");
|
||||
assertQ(req("q", "*:*", "sort", "longdv_missinglast desc"),
|
||||
"//result/doc[1]/str[@name='id'][.=2]",
|
||||
"//result/doc[2]/str[@name='id'][.=1]",
|
||||
"//result/doc[3]/str[@name='id'][.=0]");
|
||||
checkSortMissingLast("longdv_missinglast", "-1", "4");
|
||||
}
|
||||
/** dynamic long with sort missing always last */
|
||||
public void testDynLongSortMissingLast() throws Exception {
|
||||
checkSortMissingLast("dyn_longdv_missinglast", "-1", "4");
|
||||
}
|
||||
|
||||
/** long function query based on missing */
|
||||
public void testLongMissingFunction() throws Exception {
|
||||
assertU(adoc("id", "0")); // missing
|
||||
assertU(adoc("id", "1", "longdv", "-1"));
|
||||
assertU(adoc("id", "2", "longdv", "4"));
|
||||
assertU(commit());
|
||||
assertQ(req("q", "*:*", "fl", "e:exists(longdv)", "sort", "id asc"),
|
||||
"//result/doc[1]/bool[@name='e'][.='false']",
|
||||
"//result/doc[2]/bool[@name='e'][.='true']",
|
||||
"//result/doc[3]/bool[@name='e'][.='true']");
|
||||
checkSortMissingFunction("longdv", "-1", "4");
|
||||
}
|
||||
/** dynamic long function query based on missing */
|
||||
public void testDynLongMissingFunction() throws Exception {
|
||||
checkSortMissingFunction("dyn_longdv", "-1", "4");
|
||||
}
|
||||
|
||||
/** long missing facet count */
|
||||
public void testLongMissingFacet() throws Exception {
|
||||
assertU(adoc("id", "0")); // missing
|
||||
assertU(adoc("id", "1")); // missing
|
||||
assertU(adoc("id", "2", "longdv", "-1"));
|
||||
assertU(adoc("id", "3", "longdv", "4"));
|
||||
assertU(commit());
|
||||
assertQ(req("q", "*:*", "facet", "true", "facet.field", "longdv", "facet.mincount", "1", "facet.missing", "true"),
|
||||
"//lst[@name='facet_fields']/lst[@name='longdv']/int[@name='-1'][.=1]",
|
||||
"//lst[@name='facet_fields']/lst[@name='longdv']/int[@name='4'][.=1]",
|
||||
"//lst[@name='facet_fields']/lst[@name='longdv']/int[.=2]");
|
||||
checkSortMissingFacet("longdv", "-1", "4");
|
||||
}
|
||||
/** dynamic long missing facet count */
|
||||
public void testDynLongMissingFacet() throws Exception {
|
||||
checkSortMissingFacet("dyn_longdv", "-1", "4");
|
||||
}
|
||||
|
||||
/** date with default lucene sort (treats as 1970) */
|
||||
public void testDateSort() throws Exception {
|
||||
assertU(adoc("id", "0")); // missing
|
||||
assertU(adoc("id", "1", "datedv", "1900-12-31T23:59:59.999Z"));
|
||||
assertU(adoc("id", "2", "datedv", "2005-12-31T23:59:59.999Z"));
|
||||
assertU(commit());
|
||||
assertQ(req("q", "*:*", "sort", "datedv asc"),
|
||||
"//result/doc[1]/str[@name='id'][.=1]",
|
||||
"//result/doc[2]/str[@name='id'][.=0]",
|
||||
"//result/doc[3]/str[@name='id'][.=2]");
|
||||
assertQ(req("q", "*:*", "sort", "datedv desc"),
|
||||
"//result/doc[1]/str[@name='id'][.=2]",
|
||||
"//result/doc[2]/str[@name='id'][.=0]",
|
||||
"//result/doc[3]/str[@name='id'][.=1]");
|
||||
checkSortMissingDefault("datedv", "1900-12-31T23:59:59.999Z", "2005-12-31T23:59:59.999Z");
|
||||
}
|
||||
/** dynamic date with default lucene sort (treats as 1970) */
|
||||
public void testDynDateSort() throws Exception {
|
||||
checkSortMissingDefault("dyn_datedv", "1900-12-31T23:59:59.999Z", "2005-12-31T23:59:59.999Z");
|
||||
}
|
||||
|
||||
/** date with sort missing always first */
|
||||
public void testDateSortMissingFirst() throws Exception {
|
||||
assertU(adoc("id", "0")); // missing
|
||||
assertU(adoc("id", "1", "datedv_missingfirst", "1900-12-31T23:59:59.999Z"));
|
||||
assertU(adoc("id", "2", "datedv_missingfirst", "2005-12-31T23:59:59.999Z"));
|
||||
assertU(commit());
|
||||
assertQ(req("q", "*:*", "sort", "datedv_missingfirst asc"),
|
||||
"//result/doc[1]/str[@name='id'][.=0]",
|
||||
"//result/doc[2]/str[@name='id'][.=1]",
|
||||
"//result/doc[3]/str[@name='id'][.=2]");
|
||||
assertQ(req("q", "*:*", "sort", "datedv_missingfirst desc"),
|
||||
"//result/doc[1]/str[@name='id'][.=0]",
|
||||
"//result/doc[2]/str[@name='id'][.=2]",
|
||||
"//result/doc[3]/str[@name='id'][.=1]");
|
||||
checkSortMissingFirst("datedv_missingfirst",
|
||||
"1900-12-31T23:59:59.999Z", "2005-12-31T23:59:59.999Z");
|
||||
}
|
||||
/** dynamic date with sort missing always first */
|
||||
public void testDynDateSortMissingFirst() throws Exception {
|
||||
checkSortMissingFirst("dyn_datedv_missingfirst",
|
||||
"1900-12-31T23:59:59.999Z", "2005-12-31T23:59:59.999Z");
|
||||
}
|
||||
|
||||
/** date with sort missing always last */
|
||||
public void testDateSortMissingLast() throws Exception {
|
||||
assertU(adoc("id", "0")); // missing
|
||||
assertU(adoc("id", "1", "datedv_missinglast", "1900-12-31T23:59:59.999Z"));
|
||||
assertU(adoc("id", "2", "datedv_missinglast", "2005-12-31T23:59:59.999Z"));
|
||||
assertU(commit());
|
||||
assertQ(req("q", "*:*", "sort", "datedv_missinglast asc"),
|
||||
"//result/doc[1]/str[@name='id'][.=1]",
|
||||
"//result/doc[2]/str[@name='id'][.=2]",
|
||||
"//result/doc[3]/str[@name='id'][.=0]");
|
||||
assertQ(req("q", "*:*", "sort", "datedv_missinglast desc"),
|
||||
"//result/doc[1]/str[@name='id'][.=2]",
|
||||
"//result/doc[2]/str[@name='id'][.=1]",
|
||||
"//result/doc[3]/str[@name='id'][.=0]");
|
||||
checkSortMissingLast("datedv_missinglast",
|
||||
"1900-12-31T23:59:59.999Z", "2005-12-31T23:59:59.999Z");
|
||||
}
|
||||
/** dynamic date with sort missing always last */
|
||||
public void testDynDateSortMissingLast() throws Exception {
|
||||
checkSortMissingLast("dyn_datedv_missinglast",
|
||||
"1900-12-31T23:59:59.999Z", "2005-12-31T23:59:59.999Z");
|
||||
}
|
||||
|
||||
/** date function query based on missing */
|
||||
public void testDateMissingFunction() throws Exception {
|
||||
assertU(adoc("id", "0")); // missing
|
||||
assertU(adoc("id", "1", "datedv", "1900-12-31T23:59:59.999Z"));
|
||||
assertU(adoc("id", "2", "datedv", "2005-12-31T23:59:59.999Z"));
|
||||
assertU(commit());
|
||||
assertQ(req("q", "*:*", "fl", "e:exists(datedv)", "sort", "id asc"),
|
||||
"//result/doc[1]/bool[@name='e'][.='false']",
|
||||
"//result/doc[2]/bool[@name='e'][.='true']",
|
||||
"//result/doc[3]/bool[@name='e'][.='true']");
|
||||
checkSortMissingFunction("datedv",
|
||||
"1900-12-31T23:59:59.999Z", "2005-12-31T23:59:59.999Z");
|
||||
}
|
||||
/** dynamic date function query based on missing */
|
||||
public void testDynDateMissingFunction() throws Exception {
|
||||
checkSortMissingFunction("dyn_datedv",
|
||||
"1900-12-31T23:59:59.999Z", "2005-12-31T23:59:59.999Z");
|
||||
}
|
||||
|
||||
/** date missing facet count */
|
||||
public void testDateMissingFacet() throws Exception {
|
||||
assertU(adoc("id", "0")); // missing
|
||||
assertU(adoc("id", "1")); // missing
|
||||
assertU(adoc("id", "2", "datedv", "1900-12-31T23:59:59.999Z"));
|
||||
assertU(adoc("id", "3", "datedv", "2005-12-31T23:59:59.999Z"));
|
||||
assertU(commit());
|
||||
assertQ(req("q", "*:*", "facet", "true", "facet.field", "datedv", "facet.mincount", "1", "facet.missing", "true"),
|
||||
"//lst[@name='facet_fields']/lst[@name='datedv']/int[@name='1900-12-31T23:59:59.999Z'][.=1]",
|
||||
"//lst[@name='facet_fields']/lst[@name='datedv']/int[@name='2005-12-31T23:59:59.999Z'][.=1]",
|
||||
"//lst[@name='facet_fields']/lst[@name='datedv']/int[.=2]");
|
||||
checkSortMissingFacet("datedv",
|
||||
"1900-12-31T23:59:59.999Z", "2005-12-31T23:59:59.999Z");
|
||||
}
|
||||
/** dynamic date missing facet count */
|
||||
public void testDynDateMissingFacet() throws Exception {
|
||||
checkSortMissingFacet("dyn_datedv",
|
||||
"1900-12-31T23:59:59.999Z", "2005-12-31T23:59:59.999Z");
|
||||
}
|
||||
|
||||
/** string with default lucene sort (treats as "") */
|
||||
/** string (and dynamic string) with default lucene sort (treats as "") */
|
||||
public void testStringSort() throws Exception {
|
||||
|
||||
// note: cant use checkSortMissingDefault because
|
||||
// nothing sorts lower then the default of ""
|
||||
for (String field : new String[] {"stringdv","dyn_stringdv"}) {
|
||||
assertU(adoc("id", "0")); // missing
|
||||
assertU(adoc("id", "1", "stringdv", "a"));
|
||||
assertU(adoc("id", "2", "stringdv", "z"));
|
||||
assertU(adoc("id", "1", field, "a"));
|
||||
assertU(adoc("id", "2", field, "z"));
|
||||
assertU(commit());
|
||||
assertQ(req("q", "*:*", "sort", "stringdv asc"),
|
||||
assertQ(req("q", "*:*", "sort", field+" asc"),
|
||||
"//result/doc[1]/str[@name='id'][.=0]",
|
||||
"//result/doc[2]/str[@name='id'][.=1]",
|
||||
"//result/doc[3]/str[@name='id'][.=2]");
|
||||
assertQ(req("q", "*:*", "sort", "stringdv desc"),
|
||||
assertQ(req("q", "*:*", "sort", field+" desc"),
|
||||
"//result/doc[1]/str[@name='id'][.=2]",
|
||||
"//result/doc[2]/str[@name='id'][.=1]",
|
||||
"//result/doc[3]/str[@name='id'][.=0]");
|
||||
}
|
||||
}
|
||||
|
||||
/** string with sort missing always first */
|
||||
public void testStringSortMissingFirst() throws Exception {
|
||||
assertU(adoc("id", "0")); // missing
|
||||
assertU(adoc("id", "1", "stringdv_missingfirst", "a"));
|
||||
assertU(adoc("id", "2", "stringdv_missingfirst", "z"));
|
||||
assertU(commit());
|
||||
assertQ(req("q", "*:*", "sort", "stringdv_missingfirst asc"),
|
||||
"//result/doc[1]/str[@name='id'][.=0]",
|
||||
"//result/doc[2]/str[@name='id'][.=1]",
|
||||
"//result/doc[3]/str[@name='id'][.=2]");
|
||||
assertQ(req("q", "*:*", "sort", "stringdv_missingfirst desc"),
|
||||
"//result/doc[1]/str[@name='id'][.=0]",
|
||||
"//result/doc[2]/str[@name='id'][.=2]",
|
||||
"//result/doc[3]/str[@name='id'][.=1]");
|
||||
checkSortMissingFirst("stringdv_missingfirst", "a", "z");
|
||||
}
|
||||
/** dynamic string with sort missing always first */
|
||||
public void testDynStringSortMissingFirst() throws Exception {
|
||||
checkSortMissingFirst("dyn_stringdv_missingfirst", "a", "z");
|
||||
}
|
||||
|
||||
/** string with sort missing always last */
|
||||
public void testStringSortMissingLast() throws Exception {
|
||||
assertU(adoc("id", "0")); // missing
|
||||
assertU(adoc("id", "1", "stringdv_missinglast", "a"));
|
||||
assertU(adoc("id", "2", "stringdv_missinglast", "z"));
|
||||
assertU(commit());
|
||||
assertQ(req("q", "*:*", "sort", "stringdv_missinglast asc"),
|
||||
"//result/doc[1]/str[@name='id'][.=1]",
|
||||
"//result/doc[2]/str[@name='id'][.=2]",
|
||||
"//result/doc[3]/str[@name='id'][.=0]");
|
||||
assertQ(req("q", "*:*", "sort", "stringdv_missinglast desc"),
|
||||
"//result/doc[1]/str[@name='id'][.=2]",
|
||||
"//result/doc[2]/str[@name='id'][.=1]",
|
||||
"//result/doc[3]/str[@name='id'][.=0]");
|
||||
checkSortMissingLast("stringdv_missinglast", "a", "z");
|
||||
}
|
||||
/** dynamic string with sort missing always last */
|
||||
public void testDynStringSortMissingLast() throws Exception {
|
||||
checkSortMissingLast("dyn_stringdv_missinglast", "a", "z");
|
||||
}
|
||||
|
||||
/** string function query based on missing */
|
||||
public void testStringMissingFunction() throws Exception {
|
||||
assertU(adoc("id", "0")); // missing
|
||||
assertU(adoc("id", "1", "stringdv", "a"));
|
||||
assertU(adoc("id", "2", "stringdv", "z"));
|
||||
assertU(commit());
|
||||
assertQ(req("q", "*:*", "fl", "e:exists(stringdv)", "sort", "id asc"),
|
||||
"//result/doc[1]/bool[@name='e'][.='false']",
|
||||
"//result/doc[2]/bool[@name='e'][.='true']",
|
||||
"//result/doc[3]/bool[@name='e'][.='true']");
|
||||
checkSortMissingFunction("stringdv", "a", "z");
|
||||
}
|
||||
/** dynamic string function query based on missing */
|
||||
public void testDynStringMissingFunction() throws Exception {
|
||||
checkSortMissingFunction("dyn_stringdv", "a", "z");
|
||||
}
|
||||
|
||||
/** string missing facet count */
|
||||
|
|
Loading…
Reference in New Issue