mirror of https://github.com/apache/lucene.git
SOLR-7471: Stop requiring docValues for interval faceting
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1675994 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9fe95b08a3
commit
7e4c096642
|
@ -223,6 +223,8 @@ Other Changes
|
|||
|
||||
* SOLR-7467: Upgrade t-digest to 3.1 (hossman)
|
||||
|
||||
* SOLR-7471: Stop requiring docValues for interval faceting (Tomás Fernández Löbbe)
|
||||
|
||||
================== 5.1.0 ==================
|
||||
|
||||
Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release
|
||||
|
|
|
@ -98,7 +98,6 @@ import java.util.concurrent.FutureTask;
|
|||
import java.util.concurrent.RunnableFuture;
|
||||
import java.util.concurrent.Semaphore;
|
||||
import java.util.concurrent.SynchronousQueue;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
|
@ -1733,9 +1732,6 @@ public class SimpleFacets {
|
|||
parseParams(FacetParams.FACET_INTERVAL, field);
|
||||
String[] intervalStrs = required.getFieldParams(facetValue, FacetParams.FACET_INTERVAL_SET);
|
||||
SchemaField schemaField = searcher.getCore().getLatestSchema().getField(facetValue);
|
||||
if (!schemaField.hasDocValues()) {
|
||||
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Interval Faceting only on fields with doc values");
|
||||
}
|
||||
if (params.getBool(GroupParams.GROUP_FACET, false)) {
|
||||
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Interval Faceting can't be used with " + GroupParams.GROUP_FACET);
|
||||
}
|
||||
|
|
|
@ -39,12 +39,15 @@
|
|||
<dynamicField name="*_ss_dv" type="string" indexed="false" stored="false" docValues="true" multiValued="true"/>
|
||||
<dynamicField name="*_f" type="float" indexed="true" stored="false" docValues="false"/>
|
||||
<dynamicField name="*_f_dv" type="float" indexed="true" stored="false" docValues="true"/>
|
||||
<dynamicField name="*_fs" type="float" indexed="true" stored="false" docValues="false" multiValued="true"/>
|
||||
<dynamicField name="*_fs_dv" type="float" indexed="true" stored="false" docValues="true" multiValued="true"/>
|
||||
<dynamicField name="*_l" type="long" indexed="true" stored="false" docValues="false"/>
|
||||
<dynamicField name="*_l_dv" type="long" indexed="true" stored="false" docValues="true"/>
|
||||
<dynamicField name="*_ls" type="long" indexed="true" stored="false" docValues="false" multiValued="true"/>
|
||||
<dynamicField name="*_ls_dv" type="long" indexed="true" stored="false" docValues="true" multiValued="true"/>
|
||||
<dynamicField name="*_d" type="double" indexed="true" stored="false" docValues="false"/>
|
||||
<dynamicField name="*_d_dv" type="double" indexed="true" stored="false" docValues="true"/>
|
||||
<dynamicField name="*_ds" type="double" indexed="true" stored="false" docValues="false" multiValued="true"/>
|
||||
<dynamicField name="*_ds_dv" type="double" indexed="true" stored="false" docValues="true" multiValued="true"/>
|
||||
<dynamicField name="*_dt" type="date" indexed="true" stored="false" docValues="false"/>
|
||||
<dynamicField name="*_dt_dv" type="date" indexed="true" stored="false" docValues="true"/>
|
||||
|
@ -58,6 +61,12 @@
|
|||
<copyField source="*_f" dest="*_f_dv" />
|
||||
<copyField source="*_is" dest="*_is_dv" />
|
||||
<copyField source="*_s" dest="*_s_dv" />
|
||||
<copyField source="*_l" dest="*_l_dv" />
|
||||
<copyField source="*_d" dest="*_d_dv" />
|
||||
<copyField source="*_ss" dest="*_ss_dv" />
|
||||
<copyField source="*_is" dest="*_is_dv" />
|
||||
<copyField source="*_fs" dest="*_fs_dv" />
|
||||
<copyField source="*_ls" dest="*_ls_dv" />
|
||||
<copyField source="*_ds" dest="*_ds_dv" />
|
||||
<copyField source="id" dest="id_dv" />
|
||||
</schema>
|
||||
|
|
|
@ -210,16 +210,41 @@ public class TestIntervalFaceting extends SolrTestCaseJ4 {
|
|||
"//lst[@name='facet_intervals']/lst[@name='test_l_dv']/int[@name='[5,9]'][.=5]");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithFieldCache() {
|
||||
assertU(adoc("id", "1", "test_s", "dog", "test_l", "1"));
|
||||
assertU(adoc("id", "2", "test_s", "cat", "test_l", "2"));
|
||||
assertU(adoc("id", "3", "test_s", "bird", "test_l", "3"));
|
||||
assertU(adoc("id", "4", "test_s", "turtle", "test_l", "4"));
|
||||
assertU(adoc("id", "5", "test_s", "\\goodbye,", "test_l", "5"));
|
||||
assertU(adoc("id", "6", "test_s", ",hello\\", "test_l", "6"));
|
||||
assertU(adoc("id", "7", "test_s", "dog", "test_l", "7"));
|
||||
assertU(adoc("id", "8", "test_s", "dog", "test_l", "8"));
|
||||
assertU(adoc("id", "9", "test_s", "cat", "test_l", "9"));
|
||||
assertU(adoc("id", "10"));
|
||||
assertU(commit());
|
||||
|
||||
assertQ(req("q", "*:*", "facet", "true", "facet.interval", "test_s",
|
||||
"facet.interval", "test_l", "f.test_s.facet.interval.set", "[cat,dog]",
|
||||
"f.test_l.facet.interval.set", "[3,6]",
|
||||
"f.test_l.facet.interval.set", "[5,9]"),
|
||||
"//lst[@name='facet_intervals']/lst[@name='test_s']/int[@name='[cat,dog]'][.=5]",
|
||||
"//lst[@name='facet_intervals']/lst[@name='test_l']/int[@name='[3,6]'][.=4]",
|
||||
"//lst[@name='facet_intervals']/lst[@name='test_l']/int[@name='[5,9]'][.=5]");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@Slow
|
||||
public void testRandom() throws Exception {
|
||||
// All field values will be a number between 0 and cardinality
|
||||
int cardinality = 1000000;
|
||||
int cardinality = 100000;
|
||||
// Fields to use for interval faceting
|
||||
String[] fields = new String[]{"test_s_dv", "test_i_dv", "test_l_dv", "test_f_dv", "test_d_dv",
|
||||
"test_ss_dv", "test_is_dv", "test_fs_dv", "test_ls_dv", "test_ds_dv"};
|
||||
for (int i = 0; i < atLeast(5000); i++) {
|
||||
"test_ss_dv", "test_is_dv", "test_fs_dv", "test_ls_dv", "test_ds_dv", "test_s", "test_i",
|
||||
"test_l", "test_f", "test_d", "test_ss", "test_is", "test_fs", "test_ls", "test_ds"};
|
||||
for (int i = 0; i < atLeast(500); i++) {
|
||||
if (random().nextInt(50) == 0) {
|
||||
//have some empty docs
|
||||
assertU(adoc("id", String.valueOf(i)));
|
||||
|
@ -233,26 +258,26 @@ public class TestIntervalFaceting extends SolrTestCaseJ4 {
|
|||
String[] docFields = new String[(random().nextInt(5)) * 10 + 12];
|
||||
docFields[0] = "id";
|
||||
docFields[1] = String.valueOf(i);
|
||||
docFields[2] = "test_s_dv";
|
||||
docFields[2] = "test_s";
|
||||
docFields[3] = String.valueOf(random().nextInt(cardinality));
|
||||
docFields[4] = "test_i_dv";
|
||||
docFields[4] = "test_i";
|
||||
docFields[5] = String.valueOf(random().nextInt(cardinality));
|
||||
docFields[6] = "test_l_dv";
|
||||
docFields[6] = "test_l";
|
||||
docFields[7] = String.valueOf(random().nextInt(cardinality));
|
||||
docFields[8] = "test_f_dv";
|
||||
docFields[8] = "test_f";
|
||||
docFields[9] = String.valueOf(random().nextFloat() * cardinality);
|
||||
docFields[10] = "test_d_dv";
|
||||
docFields[10] = "test_d";
|
||||
docFields[11] = String.valueOf(random().nextDouble() * cardinality);
|
||||
for (int j = 12; j < docFields.length; ) {
|
||||
docFields[j++] = "test_ss_dv";
|
||||
docFields[j++] = "test_ss";
|
||||
docFields[j++] = String.valueOf(random().nextInt(cardinality));
|
||||
docFields[j++] = "test_is_dv";
|
||||
docFields[j++] = "test_is";
|
||||
docFields[j++] = String.valueOf(random().nextInt(cardinality));
|
||||
docFields[j++] = "test_ls_dv";
|
||||
docFields[j++] = "test_ls";
|
||||
docFields[j++] = String.valueOf(random().nextInt(cardinality));
|
||||
docFields[j++] = "test_fs_dv";
|
||||
docFields[j++] = "test_fs";
|
||||
docFields[j++] = String.valueOf(random().nextFloat() * cardinality);
|
||||
docFields[j++] = "test_ds_dv";
|
||||
docFields[j++] = "test_ds";
|
||||
docFields[j++] = String.valueOf(random().nextDouble() * cardinality);
|
||||
}
|
||||
assertU(adoc(docFields));
|
||||
|
@ -262,7 +287,7 @@ public class TestIntervalFaceting extends SolrTestCaseJ4 {
|
|||
}
|
||||
assertU(commit());
|
||||
|
||||
for (int i = 0; i < atLeast(1000); i++) {
|
||||
for (int i = 0; i < atLeast(100); i++) {
|
||||
doTestQuery(cardinality, fields);
|
||||
}
|
||||
|
||||
|
@ -321,7 +346,7 @@ public class TestIntervalFaceting extends SolrTestCaseJ4 {
|
|||
Integer[] values = new Integer[2];
|
||||
values[0] = random().nextInt(max);
|
||||
values[1] = random().nextInt(max);
|
||||
if ("test_s_dv".equals(fieldName) || "test_ss_dv".equals(fieldName)) {
|
||||
if (fieldName.startsWith("test_s")) {
|
||||
Arrays.sort(values, new Comparator<Integer>() {
|
||||
|
||||
@Override
|
||||
|
@ -795,26 +820,6 @@ public class TestIntervalFaceting extends SolrTestCaseJ4 {
|
|||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNonDocValueFields() {
|
||||
// there is a copyField that will copy to the dv version of the field
|
||||
assertU(adoc("id", "1", "test_s", "dog"));
|
||||
assertU(adoc("id", "2", "test_s", "cat"));
|
||||
assertU(adoc("id", "3", "test_s", "bird"));
|
||||
assertU(adoc("id", "4", "test_s", "cat"));
|
||||
assertU(commit());
|
||||
|
||||
assertQ(req("q", "*:*", "facet", "true", "facet.interval", "test_s_dv",
|
||||
"facet.interval", "test_s_dv", "f.test_s_dv.facet.interval.set", "[cat,dog]"),
|
||||
"//lst[@name='facet_intervals']/lst[@name='test_s_dv']/int[@name='[cat,dog]'][.=3]");
|
||||
|
||||
assertQEx("Interval Faceting only on fields with doc values",
|
||||
req("q", "*:*", "facet", "true", "facet.interval", "test_s",
|
||||
"f.test_s.facet.interval.set", "[cat,dog]"),
|
||||
SolrException.ErrorCode.BAD_REQUEST
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithDeletedDocs() {
|
||||
assertU(adoc("id", "1", "test_s_dv", "dog"));
|
||||
|
|
Loading…
Reference in New Issue