You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by rm...@apache.org on 2013/11/14 21:38:45 UTC
svn commit: r1542065 [3/5] - in /lucene/dev/branches/lucene5339/lucene:
benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/
benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/
demo/src/java/org/apache/lucene/demo/facet/ demo/src/test/...
Modified: lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/complements/TestTotalFacetCounts.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/complements/TestTotalFacetCounts.java?rev=1542065&r1=1542064&r2=1542065&view=diff
==============================================================================
--- lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/complements/TestTotalFacetCounts.java (original)
+++ lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/complements/TestTotalFacetCounts.java Thu Nov 14 20:38:42 2013
@@ -12,7 +12,7 @@ import org.apache.lucene.facet.complemen
import org.apache.lucene.facet.index.FacetFields;
import org.apache.lucene.facet.params.CategoryListParams;
import org.apache.lucene.facet.params.FacetIndexingParams;
-import org.apache.lucene.facet.taxonomy.CategoryPath;
+import org.apache.lucene.facet.taxonomy.FacetLabel;
import org.apache.lucene.facet.taxonomy.TaxonomyReader;
import org.apache.lucene.facet.taxonomy.TaxonomyWriter;
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyReader;
@@ -72,7 +72,7 @@ public class TestTotalFacetCounts extend
}
@Override
- public CategoryListParams getCategoryListParams(CategoryPath category) {
+ public CategoryListParams getCategoryListParams(FacetLabel category) {
return new CategoryListParams() {
@Override
public OrdinalPolicy getOrdinalPolicy(String dimension) {
@@ -89,7 +89,7 @@ public class TestTotalFacetCounts extend
FacetFields facetFields = new FacetFields(taxoWriter, iParams);
for (String cat : categories) {
Document doc = new Document();
- facetFields.addFields(doc, Collections.singletonList(new CategoryPath(cat, '/')));
+ facetFields.addFields(doc, Collections.singletonList(new FacetLabel(cat, '/')));
indexWriter.addDocument(doc);
}
Modified: lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/complements/TestTotalFacetCountsCache.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/complements/TestTotalFacetCountsCache.java?rev=1542065&r1=1542064&r2=1542065&view=diff
==============================================================================
--- lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/complements/TestTotalFacetCountsCache.java (original)
+++ lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/complements/TestTotalFacetCountsCache.java Thu Nov 14 20:38:42 2013
@@ -21,7 +21,7 @@ import org.apache.lucene.facet.search.Co
import org.apache.lucene.facet.search.FacetResult;
import org.apache.lucene.facet.search.FacetResultNode;
import org.apache.lucene.facet.search.FacetsCollector;
-import org.apache.lucene.facet.taxonomy.CategoryPath;
+import org.apache.lucene.facet.taxonomy.FacetLabel;
import org.apache.lucene.facet.taxonomy.TaxonomyReader;
import org.apache.lucene.facet.taxonomy.TaxonomyWriter;
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyReader;
@@ -91,7 +91,7 @@ public class TestTotalFacetCountsCache e
TaxonomyWriter tw, String... strings) throws IOException {
Document doc = new Document();
FacetFields facetFields = new FacetFields(tw, iParams);
- facetFields.addFields(doc, Collections.singletonList(new CategoryPath(strings)));
+ facetFields.addFields(doc, Collections.singletonList(new FacetLabel(strings)));
iw.addDocument(doc);
}
@@ -129,7 +129,7 @@ public class TestTotalFacetCountsCache e
for (String cat : CATEGORIES) {
Document doc = new Document();
- facetFields.addFields(doc, Collections.singletonList(new CategoryPath(cat, '/')));
+ facetFields.addFields(doc, Collections.singletonList(new FacetLabel(cat, '/')));
indexWriter.addDocument(doc);
}
@@ -173,8 +173,8 @@ public class TestTotalFacetCountsCache e
@Override
public void run() {
try {
- FacetSearchParams fsp = new FacetSearchParams(iParams, new CountFacetRequest(new CategoryPath("a"), 10),
- new CountFacetRequest(new CategoryPath("b"), 10));
+ FacetSearchParams fsp = new FacetSearchParams(iParams, new CountFacetRequest(new FacetLabel("a"), 10),
+ new CountFacetRequest(new FacetLabel("b"), 10));
IndexSearcher searcher = new IndexSearcher(indexReader);
FacetsCollector fc = FacetsCollector.create(fsp, indexReader, taxoReader);
searcher.search(new MatchAllDocsQuery(), fc);
@@ -352,7 +352,7 @@ public class TestTotalFacetCountsCache e
// Make the taxonomy grow without touching the index
for (int i = 0; i < 10; i++) {
- taxoWriter.addCategory(new CategoryPath("foo", Integer.toString(i)));
+ taxoWriter.addCategory(new FacetLabel("foo", Integer.toString(i)));
}
taxoWriter.commit();
TaxonomyReader newTaxoReader = TaxonomyReader.openIfChanged(taxoReader);
Modified: lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/params/FacetIndexingParamsTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/params/FacetIndexingParamsTest.java?rev=1542065&r1=1542064&r2=1542065&view=diff
==============================================================================
--- lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/params/FacetIndexingParamsTest.java (original)
+++ lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/params/FacetIndexingParamsTest.java Thu Nov 14 20:38:42 2013
@@ -4,7 +4,7 @@ import org.apache.lucene.facet.FacetTest
import org.apache.lucene.facet.params.CategoryListParams;
import org.apache.lucene.facet.params.FacetIndexingParams;
import org.apache.lucene.facet.search.DrillDownQuery;
-import org.apache.lucene.facet.taxonomy.CategoryPath;
+import org.apache.lucene.facet.taxonomy.FacetLabel;
import org.apache.lucene.facet.util.PartitionsUtils;
import org.apache.lucene.index.Term;
import org.junit.Test;
@@ -33,11 +33,11 @@ public class FacetIndexingParamsTest ext
FacetIndexingParams dfip = FacetIndexingParams.DEFAULT;
assertNotNull("Missing default category list", dfip.getAllCategoryListParams());
assertEquals("all categories have the same CategoryListParams by default",
- dfip.getCategoryListParams(null), dfip.getCategoryListParams(new CategoryPath("a")));
+ dfip.getCategoryListParams(null), dfip.getCategoryListParams(new FacetLabel("a")));
assertEquals("Expected default category list field is $facets", "$facets", dfip.getCategoryListParams(null).field);
String expectedDDText = "a"
+ dfip.getFacetDelimChar() + "b";
- CategoryPath cp = new CategoryPath("a", "b");
+ FacetLabel cp = new FacetLabel("a", "b");
assertEquals("wrong drill-down term", new Term("$facets",
expectedDDText), DrillDownQuery.term(dfip,cp));
char[] buf = new char[20];
Modified: lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/params/PerDimensionIndexingParamsTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/params/PerDimensionIndexingParamsTest.java?rev=1542065&r1=1542064&r2=1542065&view=diff
==============================================================================
--- lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/params/PerDimensionIndexingParamsTest.java (original)
+++ lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/params/PerDimensionIndexingParamsTest.java Thu Nov 14 20:38:42 2013
@@ -7,7 +7,7 @@ import org.apache.lucene.facet.params.Ca
import org.apache.lucene.facet.params.FacetIndexingParams;
import org.apache.lucene.facet.params.PerDimensionIndexingParams;
import org.apache.lucene.facet.search.DrillDownQuery;
-import org.apache.lucene.facet.taxonomy.CategoryPath;
+import org.apache.lucene.facet.taxonomy.FacetLabel;
import org.apache.lucene.facet.util.PartitionsUtils;
import org.apache.lucene.index.Term;
import org.junit.Test;
@@ -33,11 +33,11 @@ public class PerDimensionIndexingParamsT
@Test
public void testTopLevelSettings() {
- FacetIndexingParams ifip = new PerDimensionIndexingParams(Collections.<CategoryPath, CategoryListParams>emptyMap());
+ FacetIndexingParams ifip = new PerDimensionIndexingParams(Collections.<FacetLabel, CategoryListParams>emptyMap());
assertNotNull("Missing default category list", ifip.getAllCategoryListParams());
assertEquals("Expected default category list field is $facets", "$facets", ifip.getCategoryListParams(null).field);
String expectedDDText = "a" + ifip.getFacetDelimChar() + "b";
- CategoryPath cp = new CategoryPath("a", "b");
+ FacetLabel cp = new FacetLabel("a", "b");
assertEquals("wrong drill-down term", new Term("$facets", expectedDDText), DrillDownQuery.term(ifip,cp));
char[] buf = new char[20];
int numchars = ifip.drillDownTermText(cp, buf);
@@ -55,9 +55,9 @@ public class PerDimensionIndexingParamsT
public void testCategoryListParamsAddition() {
CategoryListParams clp = new CategoryListParams("clp");
PerDimensionIndexingParams tlfip = new PerDimensionIndexingParams(
- Collections.<CategoryPath,CategoryListParams> singletonMap(new CategoryPath("a"), clp));
+ Collections.<FacetLabel,CategoryListParams> singletonMap(new FacetLabel("a"), clp));
assertEquals("Expected category list field is " + clp.field,
- clp.field, tlfip.getCategoryListParams(new CategoryPath("a")).field);
+ clp.field, tlfip.getCategoryListParams(new FacetLabel("a")).field);
assertNotSame("Unexpected default category list " + clp.field, clp, tlfip.getCategoryListParams(null));
}
Modified: lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/range/TestRangeAccumulator.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/range/TestRangeAccumulator.java?rev=1542065&r1=1542064&r2=1542065&view=diff
==============================================================================
--- lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/range/TestRangeAccumulator.java (original)
+++ lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/range/TestRangeAccumulator.java Thu Nov 14 20:38:42 2013
@@ -47,7 +47,7 @@ import org.apache.lucene.facet.search.Fa
import org.apache.lucene.facet.search.FacetsCollector;
import org.apache.lucene.facet.sortedset.SortedSetDocValuesFacetFields;
import org.apache.lucene.facet.sortedset.SortedSetDocValuesReaderState;
-import org.apache.lucene.facet.taxonomy.CategoryPath;
+import org.apache.lucene.facet.taxonomy.FacetLabel;
import org.apache.lucene.facet.taxonomy.TaxonomyReader;
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyReader;
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter;
@@ -114,11 +114,11 @@ public class TestRangeAccumulator extend
// For drill down by numeric range:
doc.add(new LongField("field", l, Field.Store.NO));
- CategoryPath cp;
+ FacetLabel cp;
if ((l&3) == 0) {
- cp = new CategoryPath("dim", "a");
+ cp = new FacetLabel("dim", "a");
} else {
- cp = new CategoryPath("dim", "b");
+ cp = new FacetLabel("dim", "b");
}
ff.addFields(doc, Collections.singletonList(cp));
w.addDocument(doc);
@@ -132,7 +132,7 @@ public class TestRangeAccumulator extend
IndexSearcher s = newSearcher(r);
- final CountFacetRequest countRequest = new CountFacetRequest(new CategoryPath("dim"), 2);
+ final CountFacetRequest countRequest = new CountFacetRequest(new FacetLabel("dim"), 2);
final RangeFacetRequest<LongRange> rangeRequest = new RangeFacetRequest<LongRange>("field",
new LongRange("less than 10", 0L, true, 10L, false),
new LongRange("less than or equal to 10", 0L, true, 10L, true),
@@ -183,7 +183,7 @@ public class TestRangeAccumulator extend
// Second search, drill down on dim=b:
ddq = new DrillDownQuery(FacetIndexingParams.DEFAULT, new MatchAllDocsQuery());
- ddq.add(new CategoryPath("dim", "b"));
+ ddq.add(new FacetLabel("dim", "b"));
dimSeen.clear();
dsr = ds.search(null, ddq, 10, fsp);
@@ -221,11 +221,11 @@ public class TestRangeAccumulator extend
// For drill down by numeric range:
doc.add(new LongField("field", l, Field.Store.NO));
- CategoryPath cp;
+ FacetLabel cp;
if ((l&3) == 0) {
- cp = new CategoryPath("dim", "a");
+ cp = new FacetLabel("dim", "a");
} else {
- cp = new CategoryPath("dim", "b");
+ cp = new FacetLabel("dim", "b");
}
ff.addFields(doc, Collections.singletonList(cp));
w.addDocument(doc);
@@ -237,7 +237,7 @@ public class TestRangeAccumulator extend
IndexSearcher s = newSearcher(r);
final SortedSetDocValuesReaderState state = new SortedSetDocValuesReaderState(s.getIndexReader());
- final CountFacetRequest countRequest = new CountFacetRequest(new CategoryPath("dim"), 2);
+ final CountFacetRequest countRequest = new CountFacetRequest(new FacetLabel("dim"), 2);
final RangeFacetRequest<LongRange> rangeRequest = new RangeFacetRequest<LongRange>("field",
new LongRange("less than 10", 0L, true, 10L, false),
new LongRange("less than or equal to 10", 0L, true, 10L, true),
@@ -288,7 +288,7 @@ public class TestRangeAccumulator extend
// Second search, drill down on dim=b:
ddq = new DrillDownQuery(FacetIndexingParams.DEFAULT, new MatchAllDocsQuery());
- ddq.add(new CategoryPath("dim", "b"));
+ ddq.add(new FacetLabel("dim", "b"));
dimSeen.clear();
dsr = ds.search(null, ddq, 10, fsp);
Modified: lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/sampling/OversampleWithDepthTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/sampling/OversampleWithDepthTest.java?rev=1542065&r1=1542064&r2=1542065&view=diff
==============================================================================
--- lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/sampling/OversampleWithDepthTest.java (original)
+++ lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/sampling/OversampleWithDepthTest.java Thu Nov 14 20:38:42 2013
@@ -15,7 +15,7 @@ import org.apache.lucene.facet.search.Fa
import org.apache.lucene.facet.search.FacetResult;
import org.apache.lucene.facet.search.FacetResultNode;
import org.apache.lucene.facet.search.FacetsCollector;
-import org.apache.lucene.facet.taxonomy.CategoryPath;
+import org.apache.lucene.facet.taxonomy.FacetLabel;
import org.apache.lucene.facet.taxonomy.TaxonomyReader;
import org.apache.lucene.facet.taxonomy.TaxonomyWriter;
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyReader;
@@ -63,7 +63,7 @@ public class OversampleWithDepthTest ext
DirectoryReader r = DirectoryReader.open(indexDir);
TaxonomyReader tr = new DirectoryTaxonomyReader(taxoDir);
- CountFacetRequest facetRequest = new CountFacetRequest(new CategoryPath("root"), 10);
+ CountFacetRequest facetRequest = new CountFacetRequest(new FacetLabel("root"), 10);
// Setting the depth to '2', should potentially get all categories
facetRequest.setDepth(2);
facetRequest.setResultMode(ResultMode.PER_NODE_IN_TREE);
@@ -100,7 +100,7 @@ public class OversampleWithDepthTest ext
FacetFields facetFields = new FacetFields(tw, fip);
for (int i = 0; i < 100; i++) {
Document doc = new Document();
- CategoryPath cp = new CategoryPath("root",Integer.toString(i / 10), Integer.toString(i));
+ FacetLabel cp = new FacetLabel("root",Integer.toString(i / 10), Integer.toString(i));
facetFields.addFields(doc, Collections.singletonList(cp));
w.addDocument(doc);
}
Modified: lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/sampling/SamplerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/sampling/SamplerTest.java?rev=1542065&r1=1542064&r2=1542065&view=diff
==============================================================================
--- lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/sampling/SamplerTest.java (original)
+++ lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/sampling/SamplerTest.java Thu Nov 14 20:38:42 2013
@@ -10,7 +10,7 @@ import org.apache.lucene.facet.params.Fa
import org.apache.lucene.facet.search.CountFacetRequest;
import org.apache.lucene.facet.search.FacetResultNode;
import org.apache.lucene.facet.search.FacetsCollector;
-import org.apache.lucene.facet.taxonomy.CategoryPath;
+import org.apache.lucene.facet.taxonomy.FacetLabel;
import org.apache.lucene.search.MatchAllDocsQuery;
import org.junit.After;
import org.junit.Before;
@@ -50,10 +50,10 @@ public class SamplerTest extends FacetTe
}
@Override
- protected List<CategoryPath> getCategories(final int doc) {
- return new ArrayList<CategoryPath>() {
+ protected List<FacetLabel> getCategories(final int doc) {
+ return new ArrayList<FacetLabel>() {
{
- add(new CategoryPath("root", "a", Integer.toString(doc % 10)));
+ add(new FacetLabel("root", "a", Integer.toString(doc % 10)));
}
};
}
@@ -93,7 +93,7 @@ public class SamplerTest extends FacetTe
assertNull("Fixer should be null as the test is for no-fixing",
sp.getSampleFixer());
FacetSearchParams fsp = new FacetSearchParams(fip, new CountFacetRequest(
- new CategoryPath("root", "a"), 1));
+ new FacetLabel("root", "a"), 1));
SamplingAccumulator accumulator = new SamplingAccumulator(
new RandomSampler(sp, random()), fsp, indexReader, taxoReader);
Modified: lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/search/BaseTestTopK.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/search/BaseTestTopK.java?rev=1542065&r1=1542064&r2=1542065&view=diff
==============================================================================
--- lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/search/BaseTestTopK.java (original)
+++ lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/search/BaseTestTopK.java Thu Nov 14 20:38:42 2013
@@ -13,7 +13,7 @@ import org.apache.lucene.analysis.Analyz
import org.apache.lucene.facet.FacetTestBase;
import org.apache.lucene.facet.params.FacetIndexingParams;
import org.apache.lucene.facet.params.FacetSearchParams;
-import org.apache.lucene.facet.taxonomy.CategoryPath;
+import org.apache.lucene.facet.taxonomy.FacetLabel;
import org.apache.lucene.facet.taxonomy.TaxonomyWriter;
/*
@@ -78,9 +78,9 @@ public abstract class BaseTestTopK exten
}
@Override
- protected List<CategoryPath> getCategories(int doc) {
+ protected List<FacetLabel> getCategories(int doc) {
nextInt(doc);
- CategoryPath cp = new CategoryPath(
+ FacetLabel cp = new FacetLabel(
"a",
Integer.toString(nextInt / 1000),
Integer.toString(nextInt / 100),
@@ -93,10 +93,10 @@ public abstract class BaseTestTopK exten
protected FacetSearchParams searchParamsWithRequests(int numResults, FacetIndexingParams fip) {
List<FacetRequest> facetRequests = new ArrayList<FacetRequest>();
- facetRequests.add(new CountFacetRequest(new CategoryPath("a"), numResults));
- facetRequests.add(new CountFacetRequest(new CategoryPath("a", "1"), numResults));
- facetRequests.add(new CountFacetRequest(new CategoryPath("a", "1", "10"), numResults));
- facetRequests.add(new CountFacetRequest(new CategoryPath("a", "2", "26", "267"), numResults));
+ facetRequests.add(new CountFacetRequest(new FacetLabel("a"), numResults));
+ facetRequests.add(new CountFacetRequest(new FacetLabel("a", "1"), numResults));
+ facetRequests.add(new CountFacetRequest(new FacetLabel("a", "1", "10"), numResults));
+ facetRequests.add(new CountFacetRequest(new FacetLabel("a", "2", "26", "267"), numResults));
return getFacetSearchParams(facetRequests, fip);
}
Modified: lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/search/CountingFacetsAggregatorTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/search/CountingFacetsAggregatorTest.java?rev=1542065&r1=1542064&r2=1542065&view=diff
==============================================================================
--- lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/search/CountingFacetsAggregatorTest.java (original)
+++ lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/search/CountingFacetsAggregatorTest.java Thu Nov 14 20:38:42 2013
@@ -21,7 +21,7 @@ import org.apache.lucene.facet.params.Fa
import org.apache.lucene.facet.params.FacetSearchParams;
import org.apache.lucene.facet.params.PerDimensionOrdinalPolicy;
import org.apache.lucene.facet.params.CategoryListParams.OrdinalPolicy;
-import org.apache.lucene.facet.taxonomy.CategoryPath;
+import org.apache.lucene.facet.taxonomy.FacetLabel;
import org.apache.lucene.facet.taxonomy.TaxonomyReader;
import org.apache.lucene.facet.taxonomy.TaxonomyWriter;
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyReader;
@@ -61,38 +61,38 @@ import org.junit.Test;
public class CountingFacetsAggregatorTest extends FacetTestCase {
private static final Term A = new Term("f", "a");
- private static final CategoryPath CP_A = new CategoryPath("A"), CP_B = new CategoryPath("B");
- private static final CategoryPath CP_C = new CategoryPath("C"), CP_D = new CategoryPath("D"); // indexed w/ NO_PARENTS
+ private static final FacetLabel CP_A = new FacetLabel("A"), CP_B = new FacetLabel("B");
+ private static final FacetLabel CP_C = new FacetLabel("C"), CP_D = new FacetLabel("D"); // indexed w/ NO_PARENTS
private static final int NUM_CHILDREN_CP_A = 5, NUM_CHILDREN_CP_B = 3;
private static final int NUM_CHILDREN_CP_C = 5, NUM_CHILDREN_CP_D = 5;
- private static final CategoryPath[] CATEGORIES_A, CATEGORIES_B;
- private static final CategoryPath[] CATEGORIES_C, CATEGORIES_D;
+ private static final FacetLabel[] CATEGORIES_A, CATEGORIES_B;
+ private static final FacetLabel[] CATEGORIES_C, CATEGORIES_D;
static {
- CATEGORIES_A = new CategoryPath[NUM_CHILDREN_CP_A];
+ CATEGORIES_A = new FacetLabel[NUM_CHILDREN_CP_A];
for (int i = 0; i < NUM_CHILDREN_CP_A; i++) {
- CATEGORIES_A[i] = new CategoryPath(CP_A.components[0], Integer.toString(i));
+ CATEGORIES_A[i] = new FacetLabel(CP_A.components[0], Integer.toString(i));
}
- CATEGORIES_B = new CategoryPath[NUM_CHILDREN_CP_B];
+ CATEGORIES_B = new FacetLabel[NUM_CHILDREN_CP_B];
for (int i = 0; i < NUM_CHILDREN_CP_B; i++) {
- CATEGORIES_B[i] = new CategoryPath(CP_B.components[0], Integer.toString(i));
+ CATEGORIES_B[i] = new FacetLabel(CP_B.components[0], Integer.toString(i));
}
// NO_PARENTS categories
- CATEGORIES_C = new CategoryPath[NUM_CHILDREN_CP_C];
+ CATEGORIES_C = new FacetLabel[NUM_CHILDREN_CP_C];
for (int i = 0; i < NUM_CHILDREN_CP_C; i++) {
- CATEGORIES_C[i] = new CategoryPath(CP_C.components[0], Integer.toString(i));
+ CATEGORIES_C[i] = new FacetLabel(CP_C.components[0], Integer.toString(i));
}
// Multi-level categories
- CATEGORIES_D = new CategoryPath[NUM_CHILDREN_CP_D];
+ CATEGORIES_D = new FacetLabel[NUM_CHILDREN_CP_D];
for (int i = 0; i < NUM_CHILDREN_CP_D; i++) {
String val = Integer.toString(i);
- CATEGORIES_D[i] = new CategoryPath(CP_D.components[0], val, val + val); // e.g. D/1/11, D/2/22...
+ CATEGORIES_D[i] = new FacetLabel(CP_D.components[0], val, val + val); // e.g. D/1/11, D/2/22...
}
}
private static Directory indexDir, taxoDir;
- private static ObjectToIntMap<CategoryPath> allExpectedCounts, termExpectedCounts;
+ private static ObjectToIntMap<FacetLabel> allExpectedCounts, termExpectedCounts;
private static FacetIndexingParams fip;
@AfterClass
@@ -100,19 +100,19 @@ public class CountingFacetsAggregatorTes
IOUtils.close(indexDir, taxoDir);
}
- private static List<CategoryPath> randomCategories(Random random) {
+ private static List<FacetLabel> randomCategories(Random random) {
// add random categories from the two dimensions, ensuring that the same
// category is not added twice.
int numFacetsA = random.nextInt(3) + 1; // 1-3
int numFacetsB = random.nextInt(2) + 1; // 1-2
- ArrayList<CategoryPath> categories_a = new ArrayList<CategoryPath>();
+ ArrayList<FacetLabel> categories_a = new ArrayList<FacetLabel>();
categories_a.addAll(Arrays.asList(CATEGORIES_A));
- ArrayList<CategoryPath> categories_b = new ArrayList<CategoryPath>();
+ ArrayList<FacetLabel> categories_b = new ArrayList<FacetLabel>();
categories_b.addAll(Arrays.asList(CATEGORIES_B));
Collections.shuffle(categories_a, random);
Collections.shuffle(categories_b, random);
- ArrayList<CategoryPath> categories = new ArrayList<CategoryPath>();
+ ArrayList<FacetLabel> categories = new ArrayList<FacetLabel>();
categories.addAll(categories_a.subList(0, numFacetsA));
categories.addAll(categories_b.subList(0, numFacetsB));
@@ -129,8 +129,8 @@ public class CountingFacetsAggregatorTes
private static void addFacets(Document doc, FacetFields facetFields, boolean updateTermExpectedCounts)
throws IOException {
- List<CategoryPath> docCategories = randomCategories(random());
- for (CategoryPath cp : docCategories) {
+ List<FacetLabel> docCategories = randomCategories(random());
+ for (FacetLabel cp : docCategories) {
if (cp.components[0].equals(CP_D.components[0])) {
cp = cp.subpath(2); // we'll get counts for the 2nd level only
}
@@ -163,7 +163,7 @@ public class CountingFacetsAggregatorTes
}
private static void indexDocsWithFacetsNoTerms(IndexWriter indexWriter, TaxonomyWriter taxoWriter,
- ObjectToIntMap<CategoryPath> expectedCounts) throws IOException {
+ ObjectToIntMap<FacetLabel> expectedCounts) throws IOException {
Random random = random();
int numDocs = atLeast(random, 2);
FacetFields facetFields = new FacetFields(taxoWriter, fip);
@@ -176,7 +176,7 @@ public class CountingFacetsAggregatorTes
}
private static void indexDocsWithFacetsAndTerms(IndexWriter indexWriter, TaxonomyWriter taxoWriter,
- ObjectToIntMap<CategoryPath> expectedCounts) throws IOException {
+ ObjectToIntMap<FacetLabel> expectedCounts) throws IOException {
Random random = random();
int numDocs = atLeast(random, 2);
FacetFields facetFields = new FacetFields(taxoWriter, fip);
@@ -190,7 +190,7 @@ public class CountingFacetsAggregatorTes
}
private static void indexDocsWithFacetsAndSomeTerms(IndexWriter indexWriter, TaxonomyWriter taxoWriter,
- ObjectToIntMap<CategoryPath> expectedCounts) throws IOException {
+ ObjectToIntMap<FacetLabel> expectedCounts) throws IOException {
Random random = random();
int numDocs = atLeast(random, 2);
FacetFields facetFields = new FacetFields(taxoWriter, fip);
@@ -207,22 +207,22 @@ public class CountingFacetsAggregatorTes
}
// initialize expectedCounts w/ 0 for all categories
- private static ObjectToIntMap<CategoryPath> newCounts() {
- ObjectToIntMap<CategoryPath> counts = new ObjectToIntMap<CategoryPath>();
+ private static ObjectToIntMap<FacetLabel> newCounts() {
+ ObjectToIntMap<FacetLabel> counts = new ObjectToIntMap<FacetLabel>();
counts.put(CP_A, 0);
counts.put(CP_B, 0);
counts.put(CP_C, 0);
counts.put(CP_D, 0);
- for (CategoryPath cp : CATEGORIES_A) {
+ for (FacetLabel cp : CATEGORIES_A) {
counts.put(cp, 0);
}
- for (CategoryPath cp : CATEGORIES_B) {
+ for (FacetLabel cp : CATEGORIES_B) {
counts.put(cp, 0);
}
- for (CategoryPath cp : CATEGORIES_C) {
+ for (FacetLabel cp : CATEGORIES_C) {
counts.put(cp, 0);
}
- for (CategoryPath cp : CATEGORIES_D) {
+ for (FacetLabel cp : CATEGORIES_D) {
counts.put(cp.subpath(2), 0);
}
return counts;
Modified: lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/search/DrillDownQueryTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/search/DrillDownQueryTest.java?rev=1542065&r1=1542064&r2=1542065&view=diff
==============================================================================
--- lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/search/DrillDownQueryTest.java (original)
+++ lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/search/DrillDownQueryTest.java Thu Nov 14 20:38:42 2013
@@ -33,7 +33,7 @@ import org.apache.lucene.facet.index.Fac
import org.apache.lucene.facet.params.CategoryListParams;
import org.apache.lucene.facet.params.FacetIndexingParams;
import org.apache.lucene.facet.params.PerDimensionIndexingParams;
-import org.apache.lucene.facet.taxonomy.CategoryPath;
+import org.apache.lucene.facet.taxonomy.FacetLabel;
import org.apache.lucene.facet.taxonomy.TaxonomyWriter;
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyReader;
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter;
@@ -83,7 +83,7 @@ public class DrillDownQueryTest extends
TaxonomyWriter taxoWriter = new DirectoryTaxonomyWriter(taxoDir);
for (int i = 0; i < 100; i++) {
- ArrayList<CategoryPath> paths = new ArrayList<CategoryPath>();
+ ArrayList<FacetLabel> paths = new ArrayList<FacetLabel>();
Document doc = new Document();
if (i % 2 == 0) { // 50
doc.add(new TextField("content", "foo", Field.Store.NO));
@@ -93,13 +93,13 @@ public class DrillDownQueryTest extends
}
if (i % 4 == 0) { // 25
if (r.nextBoolean()) {
- paths.add(new CategoryPath("a/1", '/'));
+ paths.add(new FacetLabel("a/1", '/'));
} else {
- paths.add(new CategoryPath("a/2", '/'));
+ paths.add(new FacetLabel("a/2", '/'));
}
}
if (i % 5 == 0) { // 20
- paths.add(new CategoryPath("b"));
+ paths.add(new FacetLabel("b"));
}
FacetFields facetFields = new FacetFields(taxoWriter);
if (paths.size() > 0) {
@@ -116,9 +116,9 @@ public class DrillDownQueryTest extends
}
public DrillDownQueryTest() {
- Map<CategoryPath,CategoryListParams> paramsMap = new HashMap<CategoryPath,CategoryListParams>();
- paramsMap.put(new CategoryPath("a"), randomCategoryListParams("testing_facets_a"));
- paramsMap.put(new CategoryPath("b"), randomCategoryListParams("testing_facets_b"));
+ Map<FacetLabel,CategoryListParams> paramsMap = new HashMap<FacetLabel,CategoryListParams>();
+ paramsMap.put(new FacetLabel("a"), randomCategoryListParams("testing_facets_a"));
+ paramsMap.put(new FacetLabel("b"), randomCategoryListParams("testing_facets_b"));
nonDefaultParams = new PerDimensionIndexingParams(paramsMap);
defaultParams = new FacetIndexingParams(randomCategoryListParams(CategoryListParams.DEFAULT_FIELD));
}
@@ -127,10 +127,10 @@ public class DrillDownQueryTest extends
public void testDefaultField() {
String defaultField = CategoryListParams.DEFAULT_FIELD;
- Term termA = DrillDownQuery.term(defaultParams, new CategoryPath("a"));
+ Term termA = DrillDownQuery.term(defaultParams, new FacetLabel("a"));
assertEquals(new Term(defaultField, "a"), termA);
- Term termB = DrillDownQuery.term(defaultParams, new CategoryPath("b"));
+ Term termB = DrillDownQuery.term(defaultParams, new FacetLabel("b"));
assertEquals(new Term(defaultField, "b"), termB);
}
@@ -140,8 +140,8 @@ public class DrillDownQueryTest extends
// test (a/1 OR a/2) AND b
DrillDownQuery q = new DrillDownQuery(defaultParams);
- q.add(new CategoryPath("a/1", '/'), new CategoryPath("a/2", '/'));
- q.add(new CategoryPath("b"));
+ q.add(new FacetLabel("a/1", '/'), new FacetLabel("a/2", '/'));
+ q.add(new FacetLabel("b"));
TopDocs docs = searcher.search(q, 100);
assertEquals(5, docs.totalHits);
}
@@ -152,7 +152,7 @@ public class DrillDownQueryTest extends
// Making sure the query yields 25 documents with the facet "a"
DrillDownQuery q = new DrillDownQuery(defaultParams);
- q.add(new CategoryPath("a"));
+ q.add(new FacetLabel("a"));
QueryUtils.check(q);
TopDocs docs = searcher.search(q, 100);
assertEquals(25, docs.totalHits);
@@ -160,14 +160,14 @@ public class DrillDownQueryTest extends
// Making sure the query yields 5 documents with the facet "b" and the
// previous (facet "a") query as a base query
DrillDownQuery q2 = new DrillDownQuery(defaultParams, q);
- q2.add(new CategoryPath("b"));
+ q2.add(new FacetLabel("b"));
docs = searcher.search(q2, 100);
assertEquals(5, docs.totalHits);
// Making sure that a query of both facet "a" and facet "b" yields 5 results
DrillDownQuery q3 = new DrillDownQuery(defaultParams);
- q3.add(new CategoryPath("a"));
- q3.add(new CategoryPath("b"));
+ q3.add(new FacetLabel("a"));
+ q3.add(new FacetLabel("b"));
docs = searcher.search(q3, 100);
assertEquals(5, docs.totalHits);
@@ -175,7 +175,7 @@ public class DrillDownQueryTest extends
// would gather together 10 results (10%..)
Query fooQuery = new TermQuery(new Term("content", "foo"));
DrillDownQuery q4 = new DrillDownQuery(defaultParams, fooQuery);
- q4.add(new CategoryPath("b"));
+ q4.add(new FacetLabel("b"));
docs = searcher.search(q4, 100);
assertEquals(10, docs.totalHits);
}
@@ -186,12 +186,12 @@ public class DrillDownQueryTest extends
// Create the base query to start with
DrillDownQuery q = new DrillDownQuery(defaultParams);
- q.add(new CategoryPath("a"));
+ q.add(new FacetLabel("a"));
// Making sure the query yields 5 documents with the facet "b" and the
// previous (facet "a") query as a base query
DrillDownQuery q2 = new DrillDownQuery(defaultParams, q);
- q2.add(new CategoryPath("b"));
+ q2.add(new FacetLabel("b"));
TopDocs docs = searcher.search(q2, 100);
assertEquals(5, docs.totalHits);
@@ -199,7 +199,7 @@ public class DrillDownQueryTest extends
// would gather together 10 results (10%..)
Query fooQuery = new TermQuery(new Term("content", "foo"));
DrillDownQuery q4 = new DrillDownQuery(defaultParams, fooQuery);
- q4.add(new CategoryPath("b"));
+ q4.add(new FacetLabel("b"));
docs = searcher.search(q4, 100);
assertEquals(10, docs.totalHits);
}
@@ -219,7 +219,7 @@ public class DrillDownQueryTest extends
// create a drill-down query with category "a", scores should not change
DrillDownQuery q2 = new DrillDownQuery(defaultParams, q);
- q2.add(new CategoryPath("a"));
+ q2.add(new FacetLabel("a"));
docs = searcher.search(q2, reader.maxDoc()); // fetch all available docs to this query
for (ScoreDoc sd : docs.scoreDocs) {
assertEquals("score of doc=" + sd.doc + " modified", scores[sd.doc], sd.score, 0f);
@@ -232,7 +232,7 @@ public class DrillDownQueryTest extends
IndexSearcher searcher = newSearcher(reader);
DrillDownQuery q = new DrillDownQuery(defaultParams);
- q.add(new CategoryPath("a"));
+ q.add(new FacetLabel("a"));
TopDocs docs = searcher.search(q, reader.maxDoc()); // fetch all available docs to this query
for (ScoreDoc sd : docs.scoreDocs) {
assertEquals(0f, sd.score, 0f);
@@ -241,20 +241,20 @@ public class DrillDownQueryTest extends
@Test
public void testTermNonDefault() {
- Term termA = DrillDownQuery.term(nonDefaultParams, new CategoryPath("a"));
+ Term termA = DrillDownQuery.term(nonDefaultParams, new FacetLabel("a"));
assertEquals(new Term("testing_facets_a", "a"), termA);
- Term termB = DrillDownQuery.term(nonDefaultParams, new CategoryPath("b"));
+ Term termB = DrillDownQuery.term(nonDefaultParams, new FacetLabel("b"));
assertEquals(new Term("testing_facets_b", "b"), termB);
}
@Test
public void testClone() throws Exception {
DrillDownQuery q = new DrillDownQuery(defaultParams, new MatchAllDocsQuery());
- q.add(new CategoryPath("a"));
+ q.add(new FacetLabel("a"));
DrillDownQuery clone = q.clone();
- clone.add(new CategoryPath("b"));
+ clone.add(new FacetLabel("b"));
assertFalse("query wasn't cloned: source=" + q + " clone=" + clone, q.toString().equals(clone.toString()));
}
Modified: lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/search/FacetRequestTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/search/FacetRequestTest.java?rev=1542065&r1=1542064&r2=1542065&view=diff
==============================================================================
--- lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/search/FacetRequestTest.java (original)
+++ lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/search/FacetRequestTest.java Thu Nov 14 20:38:42 2013
@@ -2,7 +2,7 @@ package org.apache.lucene.facet.search;
import org.apache.lucene.facet.FacetTestCase;
import org.apache.lucene.facet.search.CountFacetRequest;
-import org.apache.lucene.facet.taxonomy.CategoryPath;
+import org.apache.lucene.facet.taxonomy.FacetLabel;
import org.junit.Test;
/*
@@ -26,7 +26,7 @@ public class FacetRequestTest extends Fa
@Test(expected=IllegalArgumentException.class)
public void testIllegalNumResults() throws Exception {
- assertNotNull(new CountFacetRequest(new CategoryPath("a", "b"), 0));
+ assertNotNull(new CountFacetRequest(new FacetLabel("a", "b"), 0));
}
@Test(expected=IllegalArgumentException.class)
@@ -36,8 +36,8 @@ public class FacetRequestTest extends Fa
@Test
public void testHashAndEquals() {
- CountFacetRequest fr1 = new CountFacetRequest(new CategoryPath("a"), 8);
- CountFacetRequest fr2 = new CountFacetRequest(new CategoryPath("a"), 8);
+ CountFacetRequest fr1 = new CountFacetRequest(new FacetLabel("a"), 8);
+ CountFacetRequest fr2 = new CountFacetRequest(new FacetLabel("a"), 8);
assertEquals("hashCode() should agree on both objects", fr1.hashCode(), fr2.hashCode());
assertTrue("equals() should return true", fr1.equals(fr2));
fr1.setDepth(10);
Modified: lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/search/FacetResultTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/search/FacetResultTest.java?rev=1542065&r1=1542064&r2=1542065&view=diff
==============================================================================
--- lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/search/FacetResultTest.java (original)
+++ lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/search/FacetResultTest.java Thu Nov 14 20:38:42 2013
@@ -32,7 +32,7 @@ import org.apache.lucene.facet.index.Fac
import org.apache.lucene.facet.params.FacetIndexingParams;
import org.apache.lucene.facet.params.FacetSearchParams;
import org.apache.lucene.facet.search.DrillSideways.DrillSidewaysResult;
-import org.apache.lucene.facet.taxonomy.CategoryPath;
+import org.apache.lucene.facet.taxonomy.FacetLabel;
import org.apache.lucene.facet.taxonomy.TaxonomyReader;
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyReader;
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter;
@@ -51,9 +51,9 @@ public class FacetResultTest extends Fac
private Document newDocument(FacetFields facetFields, String... categories) throws IOException {
Document doc = new Document();
- List<CategoryPath> cats = new ArrayList<CategoryPath>();
+ List<FacetLabel> cats = new ArrayList<FacetLabel>();
for (String cat : categories) {
- cats.add(new CategoryPath(cat, '/'));
+ cats.add(new FacetLabel(cat, '/'));
}
facetFields.addFields(doc, cats);
return doc;
@@ -80,22 +80,22 @@ public class FacetResultTest extends Fac
private void searchIndex(TaxonomyReader taxoReader, IndexSearcher searcher, boolean fillMissingCounts, String[] exp,
String[][] drillDowns, int[] numResults) throws IOException {
- CategoryPath[][] cps = new CategoryPath[drillDowns.length][];
+ FacetLabel[][] cps = new FacetLabel[drillDowns.length][];
for (int i = 0; i < cps.length; i++) {
- cps[i] = new CategoryPath[drillDowns[i].length];
+ cps[i] = new FacetLabel[drillDowns[i].length];
for (int j = 0; j < cps[i].length; j++) {
- cps[i][j] = new CategoryPath(drillDowns[i][j], '/');
+ cps[i][j] = new FacetLabel(drillDowns[i][j], '/');
}
}
DrillDownQuery ddq = new DrillDownQuery(FacetIndexingParams.DEFAULT, new MatchAllDocsQuery());
- for (CategoryPath[] cats : cps) {
+ for (FacetLabel[] cats : cps) {
ddq.add(cats);
}
List<FacetRequest> facetRequests = new ArrayList<FacetRequest>();
- for (CategoryPath[] cats : cps) {
+ for (FacetLabel[] cats : cps) {
for (int i = 0; i < cats.length; i++) {
- CategoryPath cp = cats[i];
+ FacetLabel cp = cats[i];
int numres = numResults == null ? 2 : numResults[i];
// for each drill-down, add itself as well as its parent as requests, so
// we get the drill-sideways
Modified: lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/search/MultiCategoryListIteratorTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/search/MultiCategoryListIteratorTest.java?rev=1542065&r1=1542064&r2=1542065&view=diff
==============================================================================
--- lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/search/MultiCategoryListIteratorTest.java (original)
+++ lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/search/MultiCategoryListIteratorTest.java Thu Nov 14 20:38:42 2013
@@ -12,7 +12,7 @@ import org.apache.lucene.facet.params.Ca
import org.apache.lucene.facet.params.PerDimensionIndexingParams;
import org.apache.lucene.facet.search.CategoryListIterator;
import org.apache.lucene.facet.search.DocValuesCategoryListIterator;
-import org.apache.lucene.facet.taxonomy.CategoryPath;
+import org.apache.lucene.facet.taxonomy.FacetLabel;
import org.apache.lucene.facet.taxonomy.TaxonomyReader;
import org.apache.lucene.facet.taxonomy.TaxonomyWriter;
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyReader;
@@ -55,9 +55,9 @@ public class MultiCategoryListIteratorTe
}
// build the PerDimensionIndexingParams
- HashMap<CategoryPath,CategoryListParams> clps = new HashMap<CategoryPath,CategoryListParams>();
+ HashMap<FacetLabel,CategoryListParams> clps = new HashMap<FacetLabel,CategoryListParams>();
for (String dim : dimensions) {
- CategoryPath cp = new CategoryPath(dim);
+ FacetLabel cp = new FacetLabel(dim);
CategoryListParams clp = randomCategoryListParams("$" + dim);
clps.put(cp, clp);
}
@@ -73,10 +73,10 @@ public class MultiCategoryListIteratorTe
for (int i = 0; i < ndocs; i++) {
Document doc = new Document();
int numCategories = random.nextInt(numDimensions) + 1;
- ArrayList<CategoryPath> categories = new ArrayList<CategoryPath>();
+ ArrayList<FacetLabel> categories = new ArrayList<FacetLabel>();
for (int j = 0; j < numCategories; j++) {
String dimension = dimensions[random.nextInt(dimensions.length)];
- categories.add(new CategoryPath(dimension, Integer.toString(i)));
+ categories.add(new FacetLabel(dimension, Integer.toString(i)));
}
facetFields.addFields(doc, categories);
indexWriter.addDocument(doc);
@@ -88,7 +88,7 @@ public class MultiCategoryListIteratorTe
TaxonomyReader taxoReader = new DirectoryTaxonomyReader(taxoDir);
CategoryListIterator[] iterators = new CategoryListIterator[numDimensions];
for (int i = 0; i < iterators.length; i++) {
- CategoryListParams clp = indexingParams.getCategoryListParams(new CategoryPath(dimensions[i]));
+ CategoryListParams clp = indexingParams.getCategoryListParams(new FacetLabel(dimensions[i]));
IntDecoder decoder = clp.createEncoder().createMatchingDecoder();
iterators[i] = new DocValuesCategoryListIterator(clp.field, decoder);
}
@@ -101,7 +101,7 @@ public class MultiCategoryListIteratorTe
cli.getOrdinals(i, ordinals);
assertTrue("document " + i + " does not have categories", ordinals.length > 0);
for (int j = 0; j < ordinals.length; j++) {
- CategoryPath cp = taxoReader.getPath(ordinals.ints[j]);
+ FacetLabel cp = taxoReader.getPath(ordinals.ints[j]);
assertNotNull("ordinal " + ordinals.ints[j] + " not found in taxonomy", cp);
if (cp.length == 2) {
int globalDoc = i + context.docBase;
Modified: lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/search/OrdinalsCacheTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/search/OrdinalsCacheTest.java?rev=1542065&r1=1542064&r2=1542065&view=diff
==============================================================================
--- lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/search/OrdinalsCacheTest.java (original)
+++ lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/search/OrdinalsCacheTest.java Thu Nov 14 20:38:42 2013
@@ -8,7 +8,7 @@ import org.apache.lucene.document.Docume
import org.apache.lucene.facet.FacetTestCase;
import org.apache.lucene.facet.index.FacetFields;
import org.apache.lucene.facet.params.FacetIndexingParams;
-import org.apache.lucene.facet.taxonomy.CategoryPath;
+import org.apache.lucene.facet.taxonomy.FacetLabel;
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter;
import org.apache.lucene.index.AtomicReaderContext;
import org.apache.lucene.index.DirectoryReader;
@@ -48,10 +48,10 @@ public class OrdinalsCacheTest extends F
FacetFields facetFields = new FacetFields(taxoWriter);
Document doc = new Document();
- facetFields.addFields(doc, Arrays.asList(new CategoryPath("A", "1")));
+ facetFields.addFields(doc, Arrays.asList(new FacetLabel("A", "1")));
writer.addDocument(doc);
doc = new Document();
- facetFields.addFields(doc, Arrays.asList(new CategoryPath("A", "2")));
+ facetFields.addFields(doc, Arrays.asList(new FacetLabel("A", "2")));
writer.addDocument(doc);
writer.close();
taxoWriter.close();
@@ -64,7 +64,7 @@ public class OrdinalsCacheTest extends F
public void run() {
for (AtomicReaderContext context : reader.leaves()) {
try {
- OrdinalsCache.getCachedOrds(context, FacetIndexingParams.DEFAULT.getCategoryListParams(new CategoryPath("A")));
+ OrdinalsCache.getCachedOrds(context, FacetIndexingParams.DEFAULT.getCategoryListParams(new FacetLabel("A")));
} catch (IOException e) {
throw new RuntimeException(e);
}
Modified: lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/search/TestDemoFacets.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/search/TestDemoFacets.java?rev=1542065&r1=1542064&r2=1542065&view=diff
==============================================================================
--- lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/search/TestDemoFacets.java (original)
+++ lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/search/TestDemoFacets.java Thu Nov 14 20:38:42 2013
@@ -35,7 +35,7 @@ import org.apache.lucene.facet.index.Fac
import org.apache.lucene.facet.params.CategoryListParams;
import org.apache.lucene.facet.params.FacetIndexingParams;
import org.apache.lucene.facet.params.FacetSearchParams;
-import org.apache.lucene.facet.taxonomy.CategoryPath;
+import org.apache.lucene.facet.taxonomy.FacetLabel;
import org.apache.lucene.facet.taxonomy.TaxonomyReader;
import org.apache.lucene.facet.taxonomy.TaxonomyWriter;
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyReader;
@@ -62,9 +62,9 @@ public class TestDemoFacets extends Face
private void add(String ... categoryPaths) throws IOException {
Document doc = new Document();
- List<CategoryPath> paths = new ArrayList<CategoryPath>();
+ List<FacetLabel> paths = new ArrayList<FacetLabel>();
for(String categoryPath : categoryPaths) {
- paths.add(new CategoryPath(categoryPath, '/'));
+ paths.add(new FacetLabel(categoryPath, '/'));
}
facetFields.addFields(doc, paths);
writer.addDocument(doc);
@@ -99,8 +99,8 @@ public class TestDemoFacets extends Face
// Count both "Publish Date" and "Author" dimensions:
FacetSearchParams fsp = new FacetSearchParams(
- new CountFacetRequest(new CategoryPath("Publish Date"), 10),
- new CountFacetRequest(new CategoryPath("Author"), 10));
+ new CountFacetRequest(new FacetLabel("Publish Date"), 10),
+ new CountFacetRequest(new FacetLabel("Author"), 10));
// Aggregate the facet counts:
FacetsCollector c = FacetsCollector.create(fsp, searcher.getIndexReader(), taxoReader);
@@ -121,9 +121,9 @@ public class TestDemoFacets extends Face
// Now user drills down on Publish Date/2010:
- fsp = new FacetSearchParams(new CountFacetRequest(new CategoryPath("Author"), 10));
+ fsp = new FacetSearchParams(new CountFacetRequest(new FacetLabel("Author"), 10));
DrillDownQuery q2 = new DrillDownQuery(fsp.indexingParams, new MatchAllDocsQuery());
- q2.add(new CategoryPath("Publish Date/2010", '/'));
+ q2.add(new FacetLabel("Publish Date/2010", '/'));
c = FacetsCollector.create(fsp, searcher.getIndexReader(), taxoReader);
searcher.search(q2, c);
results = c.getFacetResults();
@@ -167,7 +167,7 @@ public class TestDemoFacets extends Face
Document doc = new Document();
doc.add(newTextField("field", "text", Field.Store.NO));
- facetFields.addFields(doc, Collections.singletonList(new CategoryPath("a/path", '/')));
+ facetFields.addFields(doc, Collections.singletonList(new FacetLabel("a/path", '/')));
writer.addDocument(doc);
writer.close();
taxoWriter.close();
@@ -193,7 +193,7 @@ public class TestDemoFacets extends Face
Document doc = new Document();
doc.add(newTextField("field", "text", Field.Store.NO));
- facetFields.addFields(doc, Collections.singletonList(new CategoryPath("a/path", '/')));
+ facetFields.addFields(doc, Collections.singletonList(new FacetLabel("a/path", '/')));
writer.addDocument(doc);
// NRT open
@@ -205,7 +205,7 @@ public class TestDemoFacets extends Face
taxoWriter.close();
FacetSearchParams fsp = new FacetSearchParams(fip,
- new CountFacetRequest(new CategoryPath("a", '/'), 10));
+ new CountFacetRequest(new FacetLabel("a", '/'), 10));
// Aggregate the facet counts:
FacetsCollector c = FacetsCollector.create(fsp, searcher.getIndexReader(), taxoReader);
@@ -241,7 +241,7 @@ public class TestDemoFacets extends Face
Document doc = new Document();
doc.add(newTextField("field", "text", Field.Store.NO));
BytesRef br = new BytesRef(new byte[] {(byte) 0xee, (byte) 0x92, (byte) 0xaa, (byte) 0xef, (byte) 0x9d, (byte) 0x89});
- facetFields.addFields(doc, Collections.singletonList(new CategoryPath("dim/" + br.utf8ToString(), '/')));
+ facetFields.addFields(doc, Collections.singletonList(new FacetLabel("dim/" + br.utf8ToString(), '/')));
try {
writer.addDocument(doc);
} catch (IllegalArgumentException iae) {
@@ -269,9 +269,9 @@ public class TestDemoFacets extends Face
Document doc = new Document();
doc.add(newTextField("field", "text", Field.Store.NO));
- List<CategoryPath> paths = new ArrayList<CategoryPath>();
+ List<FacetLabel> paths = new ArrayList<FacetLabel>();
for (int i = 0; i < numLabels; i++) {
- paths.add(new CategoryPath("dim", "" + i));
+ paths.add(new FacetLabel("dim", "" + i));
}
facetFields.addFields(doc, paths);
writer.addDocument(doc);
@@ -284,7 +284,7 @@ public class TestDemoFacets extends Face
TaxonomyReader taxoReader = new DirectoryTaxonomyReader(taxoWriter);
taxoWriter.close();
- FacetSearchParams fsp = new FacetSearchParams(new CountFacetRequest(new CategoryPath("dim"), Integer.MAX_VALUE));
+ FacetSearchParams fsp = new FacetSearchParams(new CountFacetRequest(new FacetLabel("dim"), Integer.MAX_VALUE));
// Aggregate the facet counts:
FacetsCollector c = FacetsCollector.create(fsp, searcher.getIndexReader(), taxoReader);
Modified: lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/search/TestDrillSideways.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/search/TestDrillSideways.java?rev=1542065&r1=1542064&r2=1542065&view=diff
==============================================================================
--- lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/search/TestDrillSideways.java (original)
+++ lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/search/TestDrillSideways.java Thu Nov 14 20:38:42 2013
@@ -39,7 +39,7 @@ import org.apache.lucene.facet.params.Fa
import org.apache.lucene.facet.search.DrillSideways.DrillSidewaysResult;
import org.apache.lucene.facet.sortedset.SortedSetDocValuesFacetFields;
import org.apache.lucene.facet.sortedset.SortedSetDocValuesReaderState;
-import org.apache.lucene.facet.taxonomy.CategoryPath;
+import org.apache.lucene.facet.taxonomy.FacetLabel;
import org.apache.lucene.facet.taxonomy.TaxonomyReader;
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyReader;
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter;
@@ -79,9 +79,9 @@ public class TestDrillSideways extends F
private void add(String ... categoryPaths) throws IOException {
Document doc = new Document();
- List<CategoryPath> paths = new ArrayList<CategoryPath>();
+ List<FacetLabel> paths = new ArrayList<FacetLabel>();
for(String categoryPath : categoryPaths) {
- paths.add(new CategoryPath(categoryPath, '/'));
+ paths.add(new FacetLabel(categoryPath, '/'));
}
facetFields.addFields(doc, paths);
writer.addDocument(doc);
@@ -119,8 +119,8 @@ public class TestDrillSideways extends F
// Count both "Publish Date" and "Author" dimensions, in
// drill-down:
FacetSearchParams fsp = new FacetSearchParams(
- new CountFacetRequest(new CategoryPath("Publish Date"), 10),
- new CountFacetRequest(new CategoryPath("Author"), 10));
+ new CountFacetRequest(new FacetLabel("Publish Date"), 10),
+ new CountFacetRequest(new FacetLabel("Author"), 10));
DrillSideways ds = new DrillSideways(searcher, taxoReader);
@@ -128,7 +128,7 @@ public class TestDrillSideways extends F
// case the drill-sideways + drill-down counts ==
// drill-down of just the query:
DrillDownQuery ddq = new DrillDownQuery(fsp.indexingParams, new MatchAllDocsQuery());
- ddq.add(new CategoryPath("Author", "Lisa"));
+ ddq.add(new FacetLabel("Author", "Lisa"));
DrillSidewaysResult r = ds.search(null, ddq, 10, fsp);
assertEquals(2, r.hits.totalHits);
@@ -146,7 +146,7 @@ public class TestDrillSideways extends F
// drill-sideways + drill-down counts == drill-down of
// just the query:
ddq = new DrillDownQuery(fsp.indexingParams);
- ddq.add(new CategoryPath("Author", "Lisa"));
+ ddq.add(new FacetLabel("Author", "Lisa"));
r = ds.search(null, ddq, 10, fsp);
assertEquals(2, r.hits.totalHits);
@@ -165,7 +165,7 @@ public class TestDrillSideways extends F
// Another simple case: drill-down on on single fields
// but OR of two values
ddq = new DrillDownQuery(fsp.indexingParams, new MatchAllDocsQuery());
- ddq.add(new CategoryPath("Author", "Lisa"), new CategoryPath("Author", "Bob"));
+ ddq.add(new FacetLabel("Author", "Lisa"), new FacetLabel("Author", "Bob"));
r = ds.search(null, ddq, 10, fsp);
assertEquals(3, r.hits.totalHits);
assertEquals(2, r.facetResults.size());
@@ -179,8 +179,8 @@ public class TestDrillSideways extends F
// More interesting case: drill-down on two fields
ddq = new DrillDownQuery(fsp.indexingParams, new MatchAllDocsQuery());
- ddq.add(new CategoryPath("Author", "Lisa"));
- ddq.add(new CategoryPath("Publish Date", "2010"));
+ ddq.add(new FacetLabel("Author", "Lisa"));
+ ddq.add(new FacetLabel("Publish Date", "2010"));
r = ds.search(null, ddq, 10, fsp);
assertEquals(1, r.hits.totalHits);
assertEquals(2, r.facetResults.size());
@@ -196,9 +196,9 @@ public class TestDrillSideways extends F
ddq = new DrillDownQuery(fsp.indexingParams, new MatchAllDocsQuery());
// Drill down on Lisa or Bob:
- ddq.add(new CategoryPath("Author", "Lisa"),
- new CategoryPath("Author", "Bob"));
- ddq.add(new CategoryPath("Publish Date", "2010"));
+ ddq.add(new FacetLabel("Author", "Lisa"),
+ new FacetLabel("Author", "Bob"));
+ ddq.add(new FacetLabel("Publish Date", "2010"));
r = ds.search(null, ddq, 10, fsp);
assertEquals(2, r.hits.totalHits);
assertEquals(2, r.facetResults.size());
@@ -211,10 +211,10 @@ public class TestDrillSideways extends F
// Test drilling down on invalid field:
ddq = new DrillDownQuery(fsp.indexingParams, new MatchAllDocsQuery());
- ddq.add(new CategoryPath("Foobar", "Baz"));
+ ddq.add(new FacetLabel("Foobar", "Baz"));
fsp = new FacetSearchParams(
- new CountFacetRequest(new CategoryPath("Publish Date"), 10),
- new CountFacetRequest(new CategoryPath("Foobar"), 10));
+ new CountFacetRequest(new FacetLabel("Publish Date"), 10),
+ new CountFacetRequest(new FacetLabel("Foobar"), 10));
r = ds.search(null, ddq, 10, fsp);
assertEquals(0, r.hits.totalHits);
assertEquals(2, r.facetResults.size());
@@ -223,11 +223,11 @@ public class TestDrillSideways extends F
// Test drilling down on valid term or'd with invalid term:
ddq = new DrillDownQuery(fsp.indexingParams, new MatchAllDocsQuery());
- ddq.add(new CategoryPath("Author", "Lisa"),
- new CategoryPath("Author", "Tom"));
+ ddq.add(new FacetLabel("Author", "Lisa"),
+ new FacetLabel("Author", "Tom"));
fsp = new FacetSearchParams(
- new CountFacetRequest(new CategoryPath("Publish Date"), 10),
- new CountFacetRequest(new CategoryPath("Author"), 10));
+ new CountFacetRequest(new FacetLabel("Publish Date"), 10),
+ new CountFacetRequest(new FacetLabel("Author"), 10));
r = ds.search(null, ddq, 10, fsp);
assertEquals(2, r.hits.totalHits);
assertEquals(2, r.facetResults.size());
@@ -242,10 +242,10 @@ public class TestDrillSideways extends F
// LUCENE-4915: test drilling down on a dimension but
// NOT facet counting it:
ddq = new DrillDownQuery(fsp.indexingParams, new MatchAllDocsQuery());
- ddq.add(new CategoryPath("Author", "Lisa"),
- new CategoryPath("Author", "Tom"));
+ ddq.add(new FacetLabel("Author", "Lisa"),
+ new FacetLabel("Author", "Tom"));
fsp = new FacetSearchParams(
- new CountFacetRequest(new CategoryPath("Publish Date"), 10));
+ new CountFacetRequest(new FacetLabel("Publish Date"), 10));
r = ds.search(null, ddq, 10, fsp);
assertEquals(2, r.hits.totalHits);
assertEquals(1, r.facetResults.size());
@@ -255,10 +255,10 @@ public class TestDrillSideways extends F
// Test main query gets null scorer:
fsp = new FacetSearchParams(
- new CountFacetRequest(new CategoryPath("Publish Date"), 10),
- new CountFacetRequest(new CategoryPath("Author"), 10));
+ new CountFacetRequest(new FacetLabel("Publish Date"), 10),
+ new CountFacetRequest(new FacetLabel("Author"), 10));
ddq = new DrillDownQuery(fsp.indexingParams, new TermQuery(new Term("foobar", "baz")));
- ddq.add(new CategoryPath("Author", "Lisa"));
+ ddq.add(new FacetLabel("Author", "Lisa"));
r = ds.search(null, ddq, 10, fsp);
assertEquals(0, r.hits.totalHits);
@@ -304,11 +304,11 @@ public class TestDrillSideways extends F
// Count both "Publish Date" and "Author" dimensions, in
// drill-down:
FacetSearchParams fsp = new FacetSearchParams(
- new CountFacetRequest(new CategoryPath("Publish Date"), 10),
- new CountFacetRequest(new CategoryPath("Author"), 10));
+ new CountFacetRequest(new FacetLabel("Publish Date"), 10),
+ new CountFacetRequest(new FacetLabel("Author"), 10));
DrillDownQuery ddq = new DrillDownQuery(fsp.indexingParams, new MatchAllDocsQuery());
- ddq.add(new CategoryPath("Author", "Lisa"));
+ ddq.add(new FacetLabel("Author", "Lisa"));
DrillSidewaysResult r = new DrillSideways(searcher, taxoReader).search(null, ddq, 10, fsp);
assertEquals(1, r.hits.totalHits);
@@ -403,11 +403,11 @@ public class TestDrillSideways extends F
// Two requests against the same dim:
FacetSearchParams fsp = new FacetSearchParams(
- new CountFacetRequest(new CategoryPath("dim"), 10),
- new CountFacetRequest(new CategoryPath("dim", "a"), 10));
+ new CountFacetRequest(new FacetLabel("dim"), 10),
+ new CountFacetRequest(new FacetLabel("dim", "a"), 10));
DrillDownQuery ddq = new DrillDownQuery(fsp.indexingParams, new MatchAllDocsQuery());
- ddq.add(new CategoryPath("dim", "a"));
+ ddq.add(new FacetLabel("dim", "a"));
DrillSidewaysResult r = new DrillSideways(searcher, taxoReader).search(null, ddq, 10, fsp);
assertEquals(3, r.hits.totalHits);
@@ -532,7 +532,7 @@ public class TestDrillSideways extends F
Document doc = new Document();
doc.add(newStringField("id", rawDoc.id, Field.Store.YES));
doc.add(newStringField("content", rawDoc.contentToken, Field.Store.NO));
- List<CategoryPath> paths = new ArrayList<CategoryPath>();
+ List<FacetLabel> paths = new ArrayList<FacetLabel>();
if (VERBOSE) {
System.out.println(" doc id=" + rawDoc.id + " token=" + rawDoc.contentToken);
@@ -540,7 +540,7 @@ public class TestDrillSideways extends F
for(int dim=0;dim<numDims;dim++) {
int dimValue = rawDoc.dims[dim];
if (dimValue != -1) {
- CategoryPath cp = new CategoryPath("dim" + dim, dimValues[dim][dimValue]);
+ FacetLabel cp = new FacetLabel("dim" + dim, dimValues[dim][dimValue]);
paths.add(cp);
doc.add(new StringField("dim" + dim, dimValues[dim][dimValue], Field.Store.YES));
if (VERBOSE) {
@@ -549,7 +549,7 @@ public class TestDrillSideways extends F
}
int dimValue2 = rawDoc.dims2[dim];
if (dimValue2 != -1) {
- CategoryPath cp = new CategoryPath("dim" + dim, dimValues[dim][dimValue2]);
+ FacetLabel cp = new FacetLabel("dim" + dim, dimValues[dim][dimValue2]);
paths.add(cp);
doc.add(new StringField("dim" + dim, dimValues[dim][dimValue2], Field.Store.YES));
if (VERBOSE) {
@@ -632,7 +632,7 @@ public class TestDrillSideways extends F
if (VERBOSE) {
System.out.println(" do facet request on dim=" + i);
}
- requests.add(new CountFacetRequest(new CategoryPath("dim" + i), dimValues[numDims-1].length));
+ requests.add(new CountFacetRequest(new FacetLabel("dim" + i), dimValues[numDims-1].length));
} else {
if (VERBOSE) {
System.out.println(" skip facet request on dim=" + i);
@@ -696,10 +696,10 @@ public class TestDrillSideways extends F
for(int dim=0;dim<numDims;dim++) {
if (drillDowns[dim] != null) {
- CategoryPath[] paths = new CategoryPath[drillDowns[dim].length];
+ FacetLabel[] paths = new FacetLabel[drillDowns[dim].length];
int upto = 0;
for(String value : drillDowns[dim]) {
- paths[upto++] = new CategoryPath("dim" + dim, value);
+ paths[upto++] = new FacetLabel("dim" + dim, value);
}
ddq.add(paths);
}
@@ -1152,11 +1152,11 @@ public class TestDrillSideways extends F
taxoWriter.close();
// Count "Author"
- FacetSearchParams fsp = new FacetSearchParams(new CountFacetRequest(new CategoryPath("Author"), 10));
+ FacetSearchParams fsp = new FacetSearchParams(new CountFacetRequest(new FacetLabel("Author"), 10));
DrillSideways ds = new DrillSideways(searcher, taxoReader);
DrillDownQuery ddq = new DrillDownQuery(fsp.indexingParams, new MatchAllDocsQuery());
- ddq.add(new CategoryPath("Author", "Lisa"));
+ ddq.add(new FacetLabel("Author", "Lisa"));
DrillSidewaysResult r = ds.search(null, ddq, 10, fsp); // this used to fail on IllegalArgEx
assertEquals(0, r.hits.totalHits);
Modified: lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/search/TestFacetsCollector.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/search/TestFacetsCollector.java?rev=1542065&r1=1542064&r2=1542065&view=diff
==============================================================================
--- lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/search/TestFacetsCollector.java (original)
+++ lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/search/TestFacetsCollector.java Thu Nov 14 20:38:42 2013
@@ -29,7 +29,7 @@ import org.apache.lucene.facet.sampling.
import org.apache.lucene.facet.search.FacetRequest.ResultMode;
import org.apache.lucene.facet.sortedset.SortedSetDocValuesAccumulator;
import org.apache.lucene.facet.sortedset.SortedSetDocValuesReaderState;
-import org.apache.lucene.facet.taxonomy.CategoryPath;
+import org.apache.lucene.facet.taxonomy.FacetLabel;
import org.apache.lucene.facet.taxonomy.TaxonomyReader;
import org.apache.lucene.facet.taxonomy.TaxonomyWriter;
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyReader;
@@ -79,7 +79,7 @@ public class TestFacetsCollector extends
if (random().nextBoolean()) { // don't match all documents
doc.add(new StringField("f", "v", Store.NO));
}
- facetFields.addFields(doc, Collections.singletonList(new CategoryPath("a")));
+ facetFields.addFields(doc, Collections.singletonList(new FacetLabel("a")));
iw.addDocument(doc);
}
@@ -89,7 +89,7 @@ public class TestFacetsCollector extends
DirectoryReader r = DirectoryReader.open(indexDir);
DirectoryTaxonomyReader taxo = new DirectoryTaxonomyReader(taxoDir);
- FacetSearchParams fsp = new FacetSearchParams(new SumScoreFacetRequest(new CategoryPath("a"), 10));
+ FacetSearchParams fsp = new FacetSearchParams(new SumScoreFacetRequest(new FacetLabel("a"), 10));
FacetsCollector fc = FacetsCollector.create(fsp, r, taxo);
TopScoreDocCollector topDocs = TopScoreDocCollector.create(10, false);
ConstantScoreQuery csq = new ConstantScoreQuery(new MatchAllDocsQuery());
@@ -113,15 +113,15 @@ public class TestFacetsCollector extends
TaxonomyWriter taxonomyWriter = new DirectoryTaxonomyWriter(taxoDir);
IndexWriter iw = new IndexWriter(indexDir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())));
- FacetIndexingParams fip = new PerDimensionIndexingParams(Collections.singletonMap(new CategoryPath("b"), new CategoryListParams("$b")));
+ FacetIndexingParams fip = new PerDimensionIndexingParams(Collections.singletonMap(new FacetLabel("b"), new CategoryListParams("$b")));
FacetFields facetFields = new FacetFields(taxonomyWriter, fip);
for(int i = atLeast(30); i > 0; --i) {
Document doc = new Document();
doc.add(new StringField("f", "v", Store.NO));
- List<CategoryPath> cats = new ArrayList<CategoryPath>();
- cats.add(new CategoryPath("a"));
- cats.add(new CategoryPath("b"));
+ List<FacetLabel> cats = new ArrayList<FacetLabel>();
+ cats.add(new FacetLabel("a"));
+ cats.add(new FacetLabel("b"));
facetFields.addFields(doc, cats);
iw.addDocument(doc);
}
@@ -133,8 +133,8 @@ public class TestFacetsCollector extends
DirectoryTaxonomyReader taxo = new DirectoryTaxonomyReader(taxoDir);
FacetSearchParams sParams = new FacetSearchParams(fip,
- new CountFacetRequest(new CategoryPath("a"), 10),
- new CountFacetRequest(new CategoryPath("b"), 10));
+ new CountFacetRequest(new FacetLabel("a"), 10),
+ new CountFacetRequest(new FacetLabel("b"), 10));
FacetsCollector fc = FacetsCollector.create(sParams, r, taxo);
newSearcher(r).search(new MatchAllDocsQuery(), fc);
@@ -152,15 +152,15 @@ public class TestFacetsCollector extends
TaxonomyWriter taxonomyWriter = new DirectoryTaxonomyWriter(taxoDir);
IndexWriter iw = new IndexWriter(indexDir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())));
- FacetIndexingParams fip = new PerDimensionIndexingParams(Collections.singletonMap(new CategoryPath("b"), new CategoryListParams("$b")));
+ FacetIndexingParams fip = new PerDimensionIndexingParams(Collections.singletonMap(new FacetLabel("b"), new CategoryListParams("$b")));
FacetFields facetFields = new FacetFields(taxonomyWriter, fip);
for(int i = atLeast(30); i > 0; --i) {
Document doc = new Document();
doc.add(new StringField("f", "v", Store.NO));
- List<CategoryPath> cats = new ArrayList<CategoryPath>();
- cats.add(new CategoryPath("a"));
- cats.add(new CategoryPath("b"));
+ List<FacetLabel> cats = new ArrayList<FacetLabel>();
+ cats.add(new FacetLabel("a"));
+ cats.add(new FacetLabel("b"));
facetFields.addFields(doc, cats);
iw.addDocument(doc);
}
@@ -172,8 +172,8 @@ public class TestFacetsCollector extends
DirectoryTaxonomyReader taxo = new DirectoryTaxonomyReader(taxoDir);
FacetSearchParams sParams = new FacetSearchParams(fip,
- new CountFacetRequest(new CategoryPath("a"), 10),
- new SumScoreFacetRequest(new CategoryPath("b"), 10));
+ new CountFacetRequest(new FacetLabel("a"), 10),
+ new SumScoreFacetRequest(new FacetLabel("b"), 10));
FacetsCollector fc = FacetsCollector.create(sParams, r, taxo);
TopScoreDocCollector topDocs = TopScoreDocCollector.create(10, false);
@@ -202,7 +202,7 @@ public class TestFacetsCollector extends
FacetFields facetFields = new FacetFields(taxonomyWriter);
for(int i = atLeast(30); i > 0; --i) {
Document doc = new Document();
- facetFields.addFields(doc, Arrays.asList(new CategoryPath("a"), new CategoryPath("b")));
+ facetFields.addFields(doc, Arrays.asList(new FacetLabel("a"), new FacetLabel("b")));
iw.addDocument(doc);
}
@@ -212,7 +212,7 @@ public class TestFacetsCollector extends
DirectoryReader r = DirectoryReader.open(indexDir);
DirectoryTaxonomyReader taxo = new DirectoryTaxonomyReader(taxoDir);
- FacetSearchParams fsp = new FacetSearchParams(new CountFacetRequest(CategoryPath.EMPTY, 10));
+ FacetSearchParams fsp = new FacetSearchParams(new CountFacetRequest(FacetLabel.EMPTY, 10));
final TaxonomyFacetsAccumulator fa = random().nextBoolean() ? new TaxonomyFacetsAccumulator(fsp, r, taxo) : new OldFacetsAccumulator(fsp, r, taxo);
FacetsCollector fc = FacetsCollector.create(fa);
@@ -237,7 +237,7 @@ public class TestFacetsCollector extends
FacetFields facetFields = new FacetFields(taxonomyWriter);
Document doc = new Document();
- facetFields.addFields(doc, Arrays.asList(new CategoryPath("a/1", '/'), new CategoryPath("b/1", '/')));
+ facetFields.addFields(doc, Arrays.asList(new FacetLabel("a/1", '/'), new FacetLabel("b/1", '/')));
iw.addDocument(doc);
taxonomyWriter.close();
iw.close();
@@ -246,8 +246,8 @@ public class TestFacetsCollector extends
DirectoryTaxonomyReader taxo = new DirectoryTaxonomyReader(taxoDir);
FacetSearchParams fsp = new FacetSearchParams(
- new CountFacetRequest(new CategoryPath("a"), 10),
- new CountFacetRequest(new CategoryPath("b"), 10));
+ new CountFacetRequest(new FacetLabel("a"), 10),
+ new CountFacetRequest(new FacetLabel("b"), 10));
final TaxonomyFacetsAccumulator fa = random().nextBoolean() ? new TaxonomyFacetsAccumulator(fsp, r, taxo) : new OldFacetsAccumulator(fsp, r, taxo);
final FacetsCollector fc = FacetsCollector.create(fa);
newSearcher(r).search(new MatchAllDocsQuery(), fc);
@@ -269,7 +269,7 @@ public class TestFacetsCollector extends
FacetFields facetFields = new FacetFields(taxonomyWriter);
Document doc = new Document();
- facetFields.addFields(doc, Arrays.asList(new CategoryPath("a/1", '/'), new CategoryPath("b/1", '/')));
+ facetFields.addFields(doc, Arrays.asList(new FacetLabel("a/1", '/'), new FacetLabel("b/1", '/')));
iw.addDocument(doc);
taxonomyWriter.close();
iw.close();
@@ -278,8 +278,8 @@ public class TestFacetsCollector extends
DirectoryTaxonomyReader taxo = new DirectoryTaxonomyReader(taxoDir);
FacetSearchParams fsp = new FacetSearchParams(
- new CountFacetRequest(new CategoryPath("a"), 10),
- new CountFacetRequest(new CategoryPath("b"), 10));
+ new CountFacetRequest(new FacetLabel("a"), 10),
+ new CountFacetRequest(new FacetLabel("b"), 10));
final TaxonomyFacetsAccumulator fa = random().nextBoolean() ? new TaxonomyFacetsAccumulator(fsp, r, taxo) : new OldFacetsAccumulator(fsp, r, taxo);
final FacetsCollector fc = FacetsCollector.create(fa);
// this should populate the cached results, but doing search should clear the cache
@@ -311,7 +311,7 @@ public class TestFacetsCollector extends
FacetFields facetFields = new FacetFields(taxonomyWriter);
Document doc = new Document();
- facetFields.addFields(doc, Arrays.asList(new CategoryPath("a/1", '/')));
+ facetFields.addFields(doc, Arrays.asList(new FacetLabel("a/1", '/')));
iw.addDocument(doc);
taxonomyWriter.close();
iw.close();
@@ -320,14 +320,14 @@ public class TestFacetsCollector extends
DirectoryTaxonomyReader taxo = new DirectoryTaxonomyReader(taxoDir);
// assert IntFacetResultHandler
- FacetSearchParams fsp = new FacetSearchParams(new CountFacetRequest(new CategoryPath("a"), 10));
+ FacetSearchParams fsp = new FacetSearchParams(new CountFacetRequest(new FacetLabel("a"), 10));
TaxonomyFacetsAccumulator fa = random().nextBoolean() ? new TaxonomyFacetsAccumulator(fsp, r, taxo) : new OldFacetsAccumulator(fsp, r, taxo);
FacetsCollector fc = FacetsCollector.create(fa);
newSearcher(r).search(new MatchAllDocsQuery(), fc);
assertTrue("invalid ordinal for child node: 0", 0 != fc.getFacetResults().get(0).getFacetResultNode().subResults.get(0).ordinal);
// assert IntFacetResultHandler
- fsp = new FacetSearchParams(new SumScoreFacetRequest(new CategoryPath("a"), 10));
+ fsp = new FacetSearchParams(new SumScoreFacetRequest(new FacetLabel("a"), 10));
if (random().nextBoolean()) {
fa = new TaxonomyFacetsAccumulator(fsp, r, taxo);
} else {
@@ -352,7 +352,7 @@ public class TestFacetsCollector extends
FacetFields facetFields = new FacetFields(taxonomyWriter);
for (int i = 0; i < 10; i++) {
Document doc = new Document();
- facetFields.addFields(doc, Arrays.asList(new CategoryPath("a", Integer.toString(i))));
+ facetFields.addFields(doc, Arrays.asList(new FacetLabel("a", Integer.toString(i))));
iw.addDocument(doc);
}
@@ -362,7 +362,7 @@ public class TestFacetsCollector extends
DirectoryReader r = DirectoryReader.open(indexDir);
DirectoryTaxonomyReader taxo = new DirectoryTaxonomyReader(taxoDir);
- CountFacetRequest cfr = new CountFacetRequest(new CategoryPath("a"), 2);
+ CountFacetRequest cfr = new CountFacetRequest(new FacetLabel("a"), 2);
cfr.setResultMode(random().nextBoolean() ? ResultMode.GLOBAL_FLAT : ResultMode.PER_NODE_IN_TREE);
FacetSearchParams fsp = new FacetSearchParams(cfr);
final TaxonomyFacetsAccumulator fa = random().nextBoolean() ? new TaxonomyFacetsAccumulator(fsp, r, taxo) : new OldFacetsAccumulator(fsp, r, taxo);
@@ -384,7 +384,7 @@ public class TestFacetsCollector extends
DirectoryTaxonomyWriter taxoWriter = new DirectoryTaxonomyWriter(taxoDir);
FacetFields facetFields = new FacetFields(taxoWriter);
Document doc = new Document();
- facetFields.addFields(doc, Arrays.asList(new CategoryPath("A/1", '/')));
+ facetFields.addFields(doc, Arrays.asList(new FacetLabel("A/1", '/')));
indexWriter.addDocument(doc);
IOUtils.close(indexWriter, taxoWriter);
@@ -392,7 +392,7 @@ public class TestFacetsCollector extends
TaxonomyReader taxoReader = new DirectoryTaxonomyReader(taxoDir);
IndexSearcher searcher = new IndexSearcher(indexReader);
// ask to count a non-existing category to test labeling
- FacetSearchParams fsp = new FacetSearchParams(new CountFacetRequest(new CategoryPath("B"), 5));
+ FacetSearchParams fsp = new FacetSearchParams(new CountFacetRequest(new FacetLabel("B"), 5));
final SamplingParams sampleParams = new SamplingParams();
sampleParams.setMaxSampleSize(100);
@@ -434,7 +434,7 @@ public class TestFacetsCollector extends
searcher.search(new MatchAllDocsQuery(), fc);
List<FacetResult> facetResults = fc.getFacetResults();
assertNotNull(facetResults);
- assertEquals("incorrect label returned for RangeAccumulator", new CategoryPath("f"), facetResults.get(0).getFacetResultNode().label);
+ assertEquals("incorrect label returned for RangeAccumulator", new FacetLabel("f"), facetResults.get(0).getFacetResultNode().label);
IOUtils.close(indexReader, taxoReader);
Modified: lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/search/TestMultipleCategoryLists.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/search/TestMultipleCategoryLists.java?rev=1542065&r1=1542064&r2=1542065&view=diff
==============================================================================
--- lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/search/TestMultipleCategoryLists.java (original)
+++ lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/search/TestMultipleCategoryLists.java Thu Nov 14 20:38:42 2013
@@ -20,7 +20,7 @@ import org.apache.lucene.facet.params.Fa
import org.apache.lucene.facet.params.FacetSearchParams;
import org.apache.lucene.facet.params.PerDimensionIndexingParams;
import org.apache.lucene.facet.search.FacetRequest.ResultMode;
-import org.apache.lucene.facet.taxonomy.CategoryPath;
+import org.apache.lucene.facet.taxonomy.FacetLabel;
import org.apache.lucene.facet.taxonomy.TaxonomyReader;
import org.apache.lucene.facet.taxonomy.TaxonomyWriter;
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyReader;
@@ -58,16 +58,16 @@ import org.junit.Test;
public class TestMultipleCategoryLists extends FacetTestCase {
- private static final CategoryPath[] CATEGORIES = new CategoryPath[] {
- new CategoryPath("Author", "Mark Twain"),
- new CategoryPath("Author", "Stephen King"),
- new CategoryPath("Author", "Kurt Vonnegut"),
- new CategoryPath("Band", "Rock & Pop", "The Beatles"),
- new CategoryPath("Band", "Punk", "The Ramones"),
- new CategoryPath("Band", "Rock & Pop", "U2"),
- new CategoryPath("Band", "Rock & Pop", "REM"),
- new CategoryPath("Band", "Rock & Pop", "Dave Matthews Band"),
- new CategoryPath("Composer", "Bach"),
+ private static final FacetLabel[] CATEGORIES = new FacetLabel[] {
+ new FacetLabel("Author", "Mark Twain"),
+ new FacetLabel("Author", "Stephen King"),
+ new FacetLabel("Author", "Kurt Vonnegut"),
+ new FacetLabel("Band", "Rock & Pop", "The Beatles"),
+ new FacetLabel("Band", "Punk", "The Ramones"),
+ new FacetLabel("Band", "Rock & Pop", "U2"),
+ new FacetLabel("Band", "Rock & Pop", "REM"),
+ new FacetLabel("Band", "Rock & Pop", "Dave Matthews Band"),
+ new FacetLabel("Composer", "Bach"),
};
@Test
@@ -81,7 +81,7 @@ public class TestMultipleCategoryLists e
// create and open a taxonomy writer
TaxonomyWriter tw = new DirectoryTaxonomyWriter(taxoDir, OpenMode.CREATE);
- PerDimensionIndexingParams iParams = new PerDimensionIndexingParams(Collections.<CategoryPath, CategoryListParams>emptyMap());
+ PerDimensionIndexingParams iParams = new PerDimensionIndexingParams(Collections.<FacetLabel, CategoryListParams>emptyMap());
seedIndex(iw, tw, iParams);
@@ -117,7 +117,7 @@ public class TestMultipleCategoryLists e
TaxonomyWriter tw = new DirectoryTaxonomyWriter(taxoDir, OpenMode.CREATE);
PerDimensionIndexingParams iParams = new PerDimensionIndexingParams(
- Collections.singletonMap(new CategoryPath("Author"), new CategoryListParams("$author")));
+ Collections.singletonMap(new FacetLabel("Author"), new CategoryListParams("$author")));
seedIndex(iw, tw, iParams);
IndexReader ir = iw.getReader();
@@ -152,9 +152,9 @@ public class TestMultipleCategoryLists e
// create and open a taxonomy writer
TaxonomyWriter tw = new DirectoryTaxonomyWriter(taxoDir, OpenMode.CREATE);
- Map<CategoryPath,CategoryListParams> paramsMap = new HashMap<CategoryPath,CategoryListParams>();
- paramsMap.put(new CategoryPath("Band"), new CategoryListParams("$music"));
- paramsMap.put(new CategoryPath("Composer"), new CategoryListParams("$music"));
+ Map<FacetLabel,CategoryListParams> paramsMap = new HashMap<FacetLabel,CategoryListParams>();
+ paramsMap.put(new FacetLabel("Band"), new CategoryListParams("$music"));
+ paramsMap.put(new FacetLabel("Composer"), new CategoryListParams("$music"));
PerDimensionIndexingParams iParams = new PerDimensionIndexingParams(paramsMap);
seedIndex(iw, tw, iParams);
@@ -201,9 +201,9 @@ public class TestMultipleCategoryLists e
// create and open a taxonomy writer
TaxonomyWriter tw = new DirectoryTaxonomyWriter(taxoDir, OpenMode.CREATE);
- Map<CategoryPath,CategoryListParams> paramsMap = new HashMap<CategoryPath,CategoryListParams>();
- paramsMap.put(new CategoryPath("Band"), new CategoryListParams("$bands"));
- paramsMap.put(new CategoryPath("Composer"), new CategoryListParams("$composers"));
+ Map<FacetLabel,CategoryListParams> paramsMap = new HashMap<FacetLabel,CategoryListParams>();
+ paramsMap.put(new FacetLabel("Band"), new CategoryListParams("$bands"));
+ paramsMap.put(new FacetLabel("Composer"), new CategoryListParams("$composers"));
PerDimensionIndexingParams iParams = new PerDimensionIndexingParams(paramsMap);
seedIndex(iw, tw, iParams);
@@ -239,10 +239,10 @@ public class TestMultipleCategoryLists e
// create and open a taxonomy writer
TaxonomyWriter tw = new DirectoryTaxonomyWriter(taxoDir, OpenMode.CREATE);
- Map<CategoryPath,CategoryListParams> paramsMap = new HashMap<CategoryPath,CategoryListParams>();
- paramsMap.put(new CategoryPath("Band"), new CategoryListParams("$music"));
- paramsMap.put(new CategoryPath("Composer"), new CategoryListParams("$music"));
- paramsMap.put(new CategoryPath("Author"), new CategoryListParams("$literature"));
+ Map<FacetLabel,CategoryListParams> paramsMap = new HashMap<FacetLabel,CategoryListParams>();
+ paramsMap.put(new FacetLabel("Band"), new CategoryListParams("$music"));
+ paramsMap.put(new FacetLabel("Composer"), new CategoryListParams("$music"));
+ paramsMap.put(new FacetLabel("Author"), new CategoryListParams("$literature"));
PerDimensionIndexingParams iParams = new PerDimensionIndexingParams(paramsMap);
seedIndex(iw, tw, iParams);
@@ -318,14 +318,14 @@ public class TestMultipleCategoryLists e
TopScoreDocCollector topDocsCollector = TopScoreDocCollector.create(10, true);
List<FacetRequest> facetRequests = new ArrayList<FacetRequest>();
- facetRequests.add(new CountFacetRequest(new CategoryPath("Band"), 10));
- CountFacetRequest bandDepth = new CountFacetRequest(new CategoryPath("Band"), 10);
+ facetRequests.add(new CountFacetRequest(new FacetLabel("Band"), 10));
+ CountFacetRequest bandDepth = new CountFacetRequest(new FacetLabel("Band"), 10);
bandDepth.setDepth(2);
// makes it easier to check the results in the test.
bandDepth.setResultMode(ResultMode.GLOBAL_FLAT);
facetRequests.add(bandDepth);
- facetRequests.add(new CountFacetRequest(new CategoryPath("Author"), 10));
- facetRequests.add(new CountFacetRequest(new CategoryPath("Band", "Rock & Pop"), 10));
+ facetRequests.add(new CountFacetRequest(new FacetLabel("Author"), 10));
+ facetRequests.add(new CountFacetRequest(new FacetLabel("Band", "Rock & Pop"), 10));
// Faceted search parameters indicate which facets are we interested in
FacetSearchParams facetSearchParams = new FacetSearchParams(iParams, facetRequests);
@@ -338,7 +338,7 @@ public class TestMultipleCategoryLists e
private void seedIndex(RandomIndexWriter iw, TaxonomyWriter tw, FacetIndexingParams iParams) throws IOException {
FacetFields facetFields = new FacetFields(tw, iParams);
- for (CategoryPath cp : CATEGORIES) {
+ for (FacetLabel cp : CATEGORIES) {
Document doc = new Document();
facetFields.addFields(doc, Collections.singletonList(cp));
doc.add(new TextField("content", "alpha", Field.Store.YES));