You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by gs...@apache.org on 2022/06/15 18:59:27 UTC
[lucene] branch branch_9x updated: LUCENE-10584: Properly support #getSpecificValue for hierarchical dims in SSDV faceting
This is an automated email from the ASF dual-hosted git repository.
gsmiller pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/lucene.git
The following commit(s) were added to refs/heads/branch_9x by this push:
new 8888ac5e08b LUCENE-10584: Properly support #getSpecificValue for hierarchical dims in SSDV faceting
8888ac5e08b is described below
commit 8888ac5e08bdf74b1a1b7a45729ce52c48796b62
Author: Greg Miller <gs...@gmail.com>
AuthorDate: Wed Jun 15 11:31:23 2022 -0700
LUCENE-10584: Properly support #getSpecificValue for hierarchical dims in SSDV faceting
---
lucene/CHANGES.txt | 3 +++
.../sortedset/AbstractSortedSetDocValueFacetCounts.java | 5 +++--
.../facet/sortedset/TestSortedSetDocValuesFacets.java | 14 ++++++++++++++
3 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index d9e9ac8b691..1228095b892 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -93,6 +93,9 @@ Bug Fixes
* LUCENE-10574: Prevent pathological O(N^2) merging. (Adrien Grand)
+* LUCENE-10584: Properly support #getSpecificValue for hierarchical dims in SSDV faceting.
+ (Greg Miller)
+
* LUCENE-10582: Fix merging of overridden CollectionStatistics in CombinedFieldQuery (Yannick Welsch)
* LUCENE-10563: Fix failure to tessellate complex polygon (Craig Taverner)
diff --git a/lucene/facet/src/java/org/apache/lucene/facet/sortedset/AbstractSortedSetDocValueFacetCounts.java b/lucene/facet/src/java/org/apache/lucene/facet/sortedset/AbstractSortedSetDocValueFacetCounts.java
index 30fddc734b9..7bc00281293 100644
--- a/lucene/facet/src/java/org/apache/lucene/facet/sortedset/AbstractSortedSetDocValueFacetCounts.java
+++ b/lucene/facet/src/java/org/apache/lucene/facet/sortedset/AbstractSortedSetDocValueFacetCounts.java
@@ -75,8 +75,9 @@ abstract class AbstractSortedSetDocValueFacetCounts extends Facets {
@Override
public Number getSpecificValue(String dim, String... path) throws IOException {
- if (path.length != 1) {
- throw new IllegalArgumentException("path must be length=1");
+ if (stateConfig.getDimConfig(dim).hierarchical == false && path.length != 1) {
+ throw new IllegalArgumentException(
+ dim + " is not configured as hierarchical, path must be length=1");
}
int ord = (int) dv.lookupTerm(new BytesRef(FacetsConfig.pathToString(dim, path)));
if (ord < 0) {
diff --git a/lucene/facet/src/test/org/apache/lucene/facet/sortedset/TestSortedSetDocValuesFacets.java b/lucene/facet/src/test/org/apache/lucene/facet/sortedset/TestSortedSetDocValuesFacets.java
index 8b68db01db4..b893e3884fe 100644
--- a/lucene/facet/src/test/org/apache/lucene/facet/sortedset/TestSortedSetDocValuesFacets.java
+++ b/lucene/facet/src/test/org/apache/lucene/facet/sortedset/TestSortedSetDocValuesFacets.java
@@ -147,6 +147,11 @@ public class TestSortedSetDocValuesFacets extends FacetTestCase {
facets.getAllDims(0);
});
+ // test getSpecificValue
+ assertEquals(2, facets.getSpecificValue("a", "foo"));
+ expectThrows(
+ IllegalArgumentException.class, () -> facets.getSpecificValue("a", "foo", "bar"));
+
// DrillDown:
DrillDownQuery q = new DrillDownQuery(config);
q.add("a", "foo");
@@ -358,6 +363,15 @@ public class TestSortedSetDocValuesFacets extends FacetTestCase {
assertEquals(
"dim=c path=[buzz, bif] value=2 childCount=1\n baf (2)\n",
facets.getTopChildren(10, "c", "buzz", "bif").toString());
+
+ // test getSpecificValue (and make sure hierarchical dims are supported: LUCENE-10584):
+ assertEquals(2, facets.getSpecificValue("c", "buzz"));
+ // should be able to request deeper paths on hierarchical dims:
+ assertEquals(1, facets.getSpecificValue("c", "buzz", "bee"));
+ // ... but not on non-hierarchical dims:
+ expectThrows(
+ IllegalArgumentException.class, () -> facets.getSpecificValue("a", "foo", "bar)"));
+
// DrillDown:
DrillDownQuery q = new DrillDownQuery(config);
q.add("a", "foo");