You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by sh...@apache.org on 2012/12/13 13:45:58 UTC
svn commit: r1421262 [2/2] - in /lucene/dev/branches/branch_4x: ./ lucene/
lucene/facet/
lucene/facet/src/examples/org/apache/lucene/facet/example/adaptive/
lucene/facet/src/examples/org/apache/lucene/facet/example/association/
lucene/facet/src/example...
Modified: lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/enhancements/CategoryEnhancementDummy2.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/enhancements/CategoryEnhancementDummy2.java?rev=1421262&r1=1421261&r2=1421262&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/enhancements/CategoryEnhancementDummy2.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/enhancements/CategoryEnhancementDummy2.java Thu Dec 13 12:45:53 2012
@@ -65,8 +65,8 @@ public class CategoryEnhancementDummy2 i
}
@Override
- public Class<? extends CategoryProperty> getRetainableProperty() {
- return DummyProperty.class;
+ public CategoryProperty getRetainableProperty() {
+ return DummyProperty.INSTANCE;
}
@Override
Modified: lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/enhancements/CategoryEnhancementDummy3.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/enhancements/CategoryEnhancementDummy3.java?rev=1421262&r1=1421261&r2=1421262&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/enhancements/CategoryEnhancementDummy3.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/enhancements/CategoryEnhancementDummy3.java Thu Dec 13 12:45:53 2012
@@ -64,7 +64,7 @@ public class CategoryEnhancementDummy3 i
}
@Override
- public Class<? extends CategoryProperty> getRetainableProperty() {
+ public CategoryProperty getRetainableProperty() {
return null;
}
Modified: lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/enhancements/TwoEnhancementsTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/enhancements/TwoEnhancementsTest.java?rev=1421262&r1=1421261&r2=1421262&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/enhancements/TwoEnhancementsTest.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/enhancements/TwoEnhancementsTest.java Thu Dec 13 12:45:53 2012
@@ -7,21 +7,17 @@ import java.util.List;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.analysis.MockTokenizer;
import org.apache.lucene.document.Document;
-import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.index.RandomIndexWriter;
-import org.apache.lucene.index.Term;
-import org.apache.lucene.store.Directory;
-import org.junit.Test;
-
-import org.apache.lucene.util.LuceneTestCase;
-import org.apache.lucene.facet.enhancements.EnhancementsDocumentBuilder;
-import org.apache.lucene.facet.enhancements.EnhancementsPayloadIterator;
-import org.apache.lucene.facet.enhancements.params.DefaultEnhancementsIndexingParams;
import org.apache.lucene.facet.enhancements.params.EnhancementsIndexingParams;
import org.apache.lucene.facet.search.DrillDown;
import org.apache.lucene.facet.taxonomy.CategoryPath;
import org.apache.lucene.facet.taxonomy.TaxonomyWriter;
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter;
+import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.RandomIndexWriter;
+import org.apache.lucene.index.Term;
+import org.apache.lucene.store.Directory;
+import org.apache.lucene.util.LuceneTestCase;
+import org.junit.Test;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -47,10 +43,8 @@ public class TwoEnhancementsTest extends
Directory indexDir = newDirectory();
Directory taxoDir = newDirectory();
- EnhancementsIndexingParams indexingParams =
- new DefaultEnhancementsIndexingParams(
- new CategoryEnhancementDummy1(),
- new CategoryEnhancementDummy3());
+ EnhancementsIndexingParams indexingParams = new EnhancementsIndexingParams(
+ new CategoryEnhancementDummy1(), new CategoryEnhancementDummy3());
// add document with a category containing data for both enhancements
List<CategoryPath> categoryPaths = new ArrayList<CategoryPath>();
@@ -93,10 +87,8 @@ public class TwoEnhancementsTest extends
Directory indexDir = newDirectory();
Directory taxoDir = newDirectory();
- EnhancementsIndexingParams indexingParams =
- new DefaultEnhancementsIndexingParams(
- new CategoryEnhancementDummy2(),
- new CategoryEnhancementDummy3());
+ EnhancementsIndexingParams indexingParams = new EnhancementsIndexingParams(
+ new CategoryEnhancementDummy2(), new CategoryEnhancementDummy3());
List<CategoryPath> categoryPaths = new ArrayList<CategoryPath>();
categoryPaths.add(new CategoryPath("a", "b"));
Modified: lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/enhancements/association/CustomAssociationPropertyTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/enhancements/association/CustomAssociationPropertyTest.java?rev=1421262&r1=1421261&r2=1421262&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/enhancements/association/CustomAssociationPropertyTest.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/enhancements/association/CustomAssociationPropertyTest.java Thu Dec 13 12:45:53 2012
@@ -3,14 +3,7 @@ package org.apache.lucene.facet.enhancem
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.analysis.MockTokenizer;
import org.apache.lucene.document.Document;
-import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.index.RandomIndexWriter;
-import org.apache.lucene.store.Directory;
-import org.junit.Test;
-
-import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.facet.enhancements.EnhancementsDocumentBuilder;
-import org.apache.lucene.facet.enhancements.params.DefaultEnhancementsIndexingParams;
import org.apache.lucene.facet.enhancements.params.EnhancementsIndexingParams;
import org.apache.lucene.facet.index.CategoryContainer;
import org.apache.lucene.facet.index.attributes.CategoryAttributeImpl;
@@ -18,6 +11,11 @@ import org.apache.lucene.facet.index.att
import org.apache.lucene.facet.taxonomy.CategoryPath;
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyReader;
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter;
+import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.RandomIndexWriter;
+import org.apache.lucene.store.Directory;
+import org.apache.lucene.util.LuceneTestCase;
+import org.junit.Test;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -51,8 +49,7 @@ public class CustomAssociationPropertyTe
}
final int NUM_CATEGORIES = 10;
- EnhancementsIndexingParams iParams = new DefaultEnhancementsIndexingParams(
- new AssociationEnhancement());
+ EnhancementsIndexingParams iParams = new EnhancementsIndexingParams(new AssociationEnhancement());
Directory iDir = newDirectory();
Directory tDir = newDirectory();
Modified: lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/index/CategoryContainerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/index/CategoryContainerTest.java?rev=1421262&r1=1421261&r2=1421262&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/index/CategoryContainerTest.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/index/CategoryContainerTest.java Thu Dec 13 12:45:53 2012
@@ -62,7 +62,7 @@ public class CategoryContainerTest exten
@Test
public void testExistingNewCategoryWithProperty() throws FacetException {
categoryContainer.addCategory(new CategoryPath("five", "six"),
- new DummyProperty());
+ DummyProperty.INSTANCE);
Iterator<CategoryAttribute> iterator = categoryContainer.iterator();
// count the number of tokens, and check there is one DummyAttribute
@@ -83,12 +83,12 @@ public class CategoryContainerTest exten
AssociationProperty associationProperty = new AssociationIntProperty(
49);
categoryContainer.addCategory(new CategoryPath("five", "six"),
- new DummyProperty(), associationProperty);
+ DummyProperty.INSTANCE, associationProperty);
categoryContainer.addCategory(new CategoryPath("seven", "eight"),
- new DummyProperty());
+ DummyProperty.INSTANCE);
associationProperty = new AssociationIntProperty(123);
categoryContainer.addCategory(new CategoryPath("nine"),
- associationProperty, new DummyProperty());
+ associationProperty, DummyProperty.INSTANCE);
Iterator<CategoryAttribute> iterator = categoryContainer.iterator();
// count the number of tokens, and check there is one DummyAttribute
@@ -114,7 +114,7 @@ public class CategoryContainerTest exten
@Test
public void testAddNewCategoryWithProperty() throws FacetException {
categoryContainer.addCategory(new CategoryPath("seven", "eight"),
- new DummyProperty());
+ DummyProperty.INSTANCE);
Iterator<CategoryAttribute> iterator = categoryContainer.iterator();
// count the number of tokens, and check there is one DummyAttribute
@@ -150,7 +150,7 @@ public class CategoryContainerTest exten
public void testAddCategoryAttributeWithProperty() throws FacetException {
CategoryAttribute newCA = new CategoryAttributeImpl(new CategoryPath(
"seven", "eight"));
- newCA.addProperty(new DummyProperty());
+ newCA.addProperty(DummyProperty.INSTANCE);
categoryContainer.addCategory(newCA);
Iterator<CategoryAttribute> iterator = categoryContainer.iterator();
@@ -215,12 +215,12 @@ public class CategoryContainerTest exten
AssociationProperty associationProperty = new AssociationIntProperty(
49);
categoryContainer.addCategory(new CategoryPath("five", "six"),
- new DummyProperty(), associationProperty);
+ DummyProperty.INSTANCE, associationProperty);
categoryContainer.addCategory(new CategoryPath("seven", "eight"),
- new DummyProperty());
+ DummyProperty.INSTANCE);
associationProperty = new AssociationIntProperty(123);
categoryContainer.addCategory(new CategoryPath("nine"),
- associationProperty, new DummyProperty());
+ associationProperty, DummyProperty.INSTANCE);
ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
ObjectOutputStream out = new ObjectOutputStream(baos);
Modified: lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/index/DummyProperty.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/index/DummyProperty.java?rev=1421262&r1=1421261&r2=1421262&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/index/DummyProperty.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/index/DummyProperty.java Thu Dec 13 12:45:53 2012
@@ -24,6 +24,10 @@ import org.apache.lucene.facet.index.att
*/
public class DummyProperty implements CategoryProperty {
+ public static final DummyProperty INSTANCE = new DummyProperty();
+
+ private DummyProperty() {}
+
@Override
public boolean equals(Object o) {
if (o instanceof DummyProperty) {
Modified: lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/index/FacetsPayloadProcessorProviderTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/index/FacetsPayloadProcessorProviderTest.java?rev=1421262&r1=1421261&r2=1421262&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/index/FacetsPayloadProcessorProviderTest.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/index/FacetsPayloadProcessorProviderTest.java Thu Dec 13 12:45:53 2012
@@ -70,8 +70,7 @@ public class FacetsPayloadProcessorProvi
DirectoryReader reader1 = DirectoryReader.open(dir);
DirectoryTaxonomyReader taxReader = new DirectoryTaxonomyReader(taxDir);
IndexSearcher searcher = newSearcher(reader1);
- FacetSearchParams fsp = new FacetSearchParams();
- fsp.addFacetRequest(new CountFacetRequest(new CategoryPath("tag"), NUM_DOCS));
+ FacetSearchParams fsp = new FacetSearchParams(new CountFacetRequest(new CategoryPath("tag"), NUM_DOCS));
FacetsCollector collector = new FacetsCollector(fsp, reader1, taxReader);
searcher.search(new MatchAllDocsQuery(), collector);
FacetResult result = collector.getFacetResults().get(0);
Modified: lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/index/attributes/CategoryAttributeImplTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/index/attributes/CategoryAttributeImplTest.java?rev=1421262&r1=1421261&r2=1421262&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/index/attributes/CategoryAttributeImplTest.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/index/attributes/CategoryAttributeImplTest.java Thu Dec 13 12:45:53 2012
@@ -57,15 +57,15 @@ public class CategoryAttributeImplTest e
.getProperty(DummyProperty.class));
assertNull("Attribute classes should be null", ca.getPropertyClasses());
- ca.addProperty(new DummyProperty());
+ ca.addProperty(DummyProperty.INSTANCE);
assertEquals("DummyProperty should be in properties",
- new DummyProperty(), ca.getProperty(DummyProperty.class));
+ DummyProperty.INSTANCE, ca.getProperty(DummyProperty.class));
assertEquals("Attribute classes should contain 1 element", 1, ca
.getPropertyClasses().size());
boolean failed = false;
try {
- ca.addProperty(new DummyProperty());
+ ca.addProperty(DummyProperty.INSTANCE);
} catch (UnsupportedOperationException e) {
failed = true;
}
@@ -77,24 +77,24 @@ public class CategoryAttributeImplTest e
ca.clearProperties();
assertNull("Attribute classes should be null", ca.getPropertyClasses());
- ca.addProperty(new DummyProperty());
+ ca.addProperty(DummyProperty.INSTANCE);
assertEquals("DummyProperty should be in properties",
- new DummyProperty(), ca.getProperty(DummyProperty.class));
+ DummyProperty.INSTANCE, ca.getProperty(DummyProperty.class));
ca.remove(DummyProperty.class);
assertEquals("DummyProperty should not be in properties", null, ca
.getProperty(DummyProperty.class));
assertNull("Attribute classes should be null", ca.getPropertyClasses());
- ca.addProperty(new DummyProperty());
+ ca.addProperty(DummyProperty.INSTANCE);
List<Class<? extends CategoryProperty>> propertyClasses = new ArrayList<Class<? extends CategoryProperty>>();
assertEquals("No property expected when no classes given", null, ca
.getProperty(propertyClasses));
propertyClasses.add(DummyProperty.class);
assertEquals("DummyProperty should be in properties",
- new DummyProperty(), ca.getProperty(propertyClasses));
+ DummyProperty.INSTANCE, ca.getProperty(propertyClasses));
propertyClasses.add(OrdinalProperty.class);
assertEquals("DummyProperty should be in properties",
- new DummyProperty(), ca.getProperty(propertyClasses));
+ DummyProperty.INSTANCE, ca.getProperty(propertyClasses));
propertyClasses.clear();
propertyClasses.add(OrdinalProperty.class);
assertEquals("No ordinal property expected", null, ca
@@ -107,7 +107,7 @@ public class CategoryAttributeImplTest e
CategoryPath cp = new CategoryPath("a", "b");
ca1.setCategoryPath(cp);
- ca1.addProperty(new DummyProperty());
+ ca1.addProperty(DummyProperty.INSTANCE);
CategoryAttribute ca2 = ca1.clone();
assertEquals("Error in cloning", ca1, ca2);
Modified: lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/index/params/PerDimensionIndexingParamsTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/index/params/PerDimensionIndexingParamsTest.java?rev=1421262&r1=1421261&r2=1421262&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/index/params/PerDimensionIndexingParamsTest.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/index/params/PerDimensionIndexingParamsTest.java Thu Dec 13 12:45:53 2012
@@ -1,15 +1,13 @@
package org.apache.lucene.facet.index.params;
-import org.apache.lucene.index.Term;
-import org.junit.Test;
+import java.util.Collections;
-import org.apache.lucene.util.LuceneTestCase;
-import org.apache.lucene.facet.index.params.CategoryListParams;
-import org.apache.lucene.facet.index.params.FacetIndexingParams;
-import org.apache.lucene.facet.index.params.PerDimensionIndexingParams;
import org.apache.lucene.facet.search.DrillDown;
import org.apache.lucene.facet.taxonomy.CategoryPath;
import org.apache.lucene.facet.util.PartitionsUtils;
+import org.apache.lucene.index.Term;
+import org.apache.lucene.util.LuceneTestCase;
+import org.junit.Test;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -32,9 +30,8 @@ public class PerDimensionIndexingParamsT
@Test
public void testTopLevelSettings() {
- FacetIndexingParams ifip = new PerDimensionIndexingParams();
- assertNotNull("Missing default category list", ifip
- .getAllCategoryListParams());
+ FacetIndexingParams ifip = new PerDimensionIndexingParams(Collections.<CategoryPath, CategoryListParams>emptyMap());
+ assertNotNull("Missing default category list", ifip.getAllCategoryListParams());
assertEquals(
"Expected default category list term is $facets:$fulltree$",
new Term("$facets", "$fulltree$"), ifip.getCategoryListParams(
@@ -67,15 +64,12 @@ public class PerDimensionIndexingParamsT
@Test
public void testCategoryListParamsAddition() {
- PerDimensionIndexingParams tlfip = new PerDimensionIndexingParams();
- CategoryListParams clp = new CategoryListParams(
- new Term("clp", "value"));
- tlfip.addCategoryListParams(new CategoryPath("a"), clp);
- assertEquals("Expected category list term is " + clp.getTerm(), clp
- .getTerm(), tlfip.getCategoryListParams(new CategoryPath("a"))
- .getTerm());
- assertNotSame("Unexpected default category list " + clp.getTerm(), clp,
- tlfip.getCategoryListParams(null));
+ CategoryListParams clp = new CategoryListParams(new Term("clp", "value"));
+ PerDimensionIndexingParams tlfip = new PerDimensionIndexingParams(
+ Collections.<CategoryPath,CategoryListParams> singletonMap(new CategoryPath("a"), clp));
+ assertEquals("Expected category list term is " + clp.getTerm(),
+ clp.getTerm(), tlfip.getCategoryListParams(new CategoryPath("a")).getTerm());
+ assertNotSame("Unexpected default category list " + clp.getTerm(), clp, tlfip.getCategoryListParams(null));
}
}
\ No newline at end of file
Modified: lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/index/streaming/CategoryParentsStreamTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/index/streaming/CategoryParentsStreamTest.java?rev=1421262&r1=1421261&r2=1421262&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/index/streaming/CategoryParentsStreamTest.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/index/streaming/CategoryParentsStreamTest.java Thu Dec 13 12:45:53 2012
@@ -3,20 +3,17 @@ package org.apache.lucene.facet.index.st
import java.io.IOException;
import org.apache.lucene.analysis.TokenStream;
-import org.apache.lucene.store.Directory;
-import org.junit.Test;
-
-import org.apache.lucene.facet.FacetException;
import org.apache.lucene.facet.index.CategoryContainerTestBase;
import org.apache.lucene.facet.index.DummyProperty;
import org.apache.lucene.facet.index.categorypolicy.NonTopLevelOrdinalPolicy;
import org.apache.lucene.facet.index.categorypolicy.NonTopLevelPathPolicy;
import org.apache.lucene.facet.index.categorypolicy.OrdinalPolicy;
import org.apache.lucene.facet.index.categorypolicy.PathPolicy;
-import org.apache.lucene.facet.index.params.DefaultFacetIndexingParams;
import org.apache.lucene.facet.index.params.FacetIndexingParams;
import org.apache.lucene.facet.taxonomy.TaxonomyWriter;
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter;
+import org.apache.lucene.store.Directory;
+import org.junit.Test;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -49,7 +46,7 @@ public class CategoryParentsStreamTest e
directory);
CategoryParentsStream stream = new CategoryParentsStream(
new CategoryAttributesStream(categoryContainer),
- taxonomyWriter, new DefaultFacetIndexingParams());
+ taxonomyWriter, FacetIndexingParams.ALL_PARENTS);
// count the number of tokens
int nTokens;
@@ -72,13 +69,13 @@ public class CategoryParentsStreamTest e
Directory directory = newDirectory();
final TaxonomyWriter taxonomyWriter = new DirectoryTaxonomyWriter(
directory);
- FacetIndexingParams indexingParams = new DefaultFacetIndexingParams() {
+ FacetIndexingParams indexingParams = new FacetIndexingParams() {
@Override
- protected OrdinalPolicy fixedOrdinalPolicy() {
+ public OrdinalPolicy getOrdinalPolicy() {
return new NonTopLevelOrdinalPolicy();
}
@Override
- protected PathPolicy fixedPathPolicy() {
+ public PathPolicy getPathPolicy() {
return new NonTopLevelPathPolicy();
}
};
@@ -110,15 +107,14 @@ public class CategoryParentsStreamTest e
Directory directory = newDirectory();
TaxonomyWriter taxonomyWriter = new DirectoryTaxonomyWriter(directory);
- new CategoryParentsStream(new CategoryAttributesStream(categoryContainer),
- taxonomyWriter, new DefaultFacetIndexingParams());
+ assertNotNull(new CategoryParentsStream(new CategoryAttributesStream(categoryContainer),
+ taxonomyWriter, FacetIndexingParams.ALL_PARENTS));
// add DummyAttribute, but do not retain, only one expected
- categoryContainer.addCategory(initialCatgeories[0], new DummyProperty());
+ categoryContainer.addCategory(initialCatgeories[0], DummyProperty.INSTANCE);
CategoryParentsStream stream = new CategoryParentsStream(new CategoryAttributesStream(
- categoryContainer), taxonomyWriter,
- new DefaultFacetIndexingParams());
+ categoryContainer), taxonomyWriter, FacetIndexingParams.ALL_PARENTS);
int nAttributes = 0;
while (stream.incrementToken()) {
@@ -139,24 +135,21 @@ public class CategoryParentsStreamTest e
@Test
public void testRetainableAttributes() throws IOException {
Directory directory = newDirectory();
- TaxonomyWriter taxonomyWriter = new DirectoryTaxonomyWriter(
- directory);
+ TaxonomyWriter taxonomyWriter = new DirectoryTaxonomyWriter(directory);
- FacetIndexingParams indexingParams = new DefaultFacetIndexingParams();
- new CategoryParentsStream(new CategoryAttributesStream(
- categoryContainer), taxonomyWriter, indexingParams);
+ FacetIndexingParams indexingParams = FacetIndexingParams.ALL_PARENTS;
+ assertNotNull(new CategoryParentsStream(new CategoryAttributesStream(
+ categoryContainer), taxonomyWriter, indexingParams));
// add DummyAttribute and retain it, three expected
categoryContainer.clear();
- categoryContainer
- .addCategory(initialCatgeories[0], new DummyProperty());
+ categoryContainer.addCategory(initialCatgeories[0], DummyProperty.INSTANCE);
CategoryParentsStream stream = new CategoryParentsStream(
new CategoryAttributesStream(categoryContainer),
- taxonomyWriter, new DefaultFacetIndexingParams());
+ taxonomyWriter, FacetIndexingParams.ALL_PARENTS);
stream.addRetainableProperty(DummyProperty.class);
- MyCategoryListTokenizer tokenizer = new MyCategoryListTokenizer(stream,
- indexingParams);
+ MyCategoryListTokenizer tokenizer = new MyCategoryListTokenizer(stream, indexingParams);
int nAttributes = 0;
try {
Modified: lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/index/streaming/CategoryTokenizerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/index/streaming/CategoryTokenizerTest.java?rev=1421262&r1=1421261&r2=1421262&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/index/streaming/CategoryTokenizerTest.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/index/streaming/CategoryTokenizerTest.java Thu Dec 13 12:45:53 2012
@@ -7,17 +7,14 @@ import java.util.List;
import java.util.Set;
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
-import org.apache.lucene.store.Directory;
-import org.junit.Test;
-
import org.apache.lucene.facet.index.CategoryContainerTestBase;
import org.apache.lucene.facet.index.attributes.CategoryAttributesIterable;
-import org.apache.lucene.facet.index.params.DefaultFacetIndexingParams;
-import org.apache.lucene.facet.index.streaming.CategoryAttributesStream;
-import org.apache.lucene.facet.index.streaming.CategoryTokenizer;
+import org.apache.lucene.facet.index.params.FacetIndexingParams;
import org.apache.lucene.facet.taxonomy.CategoryPath;
import org.apache.lucene.facet.taxonomy.TaxonomyWriter;
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter;
+import org.apache.lucene.store.Directory;
+import org.junit.Test;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -47,7 +44,7 @@ public class CategoryTokenizerTest exten
Directory directory = newDirectory();
TaxonomyWriter taxonomyWriter = new DirectoryTaxonomyWriter(
directory);
- DefaultFacetIndexingParams indexingParams = new DefaultFacetIndexingParams();
+ FacetIndexingParams indexingParams = FacetIndexingParams.ALL_PARENTS;
CategoryTokenizer tokenizer = new CategoryTokenizer(
new CategoryAttributesStream(categoryContainer),
indexingParams);
@@ -89,7 +86,7 @@ public class CategoryTokenizerTest exten
longCategory.add(new CategoryPath("one", "two", "three", "four",
"five", "six", "seven"));
- DefaultFacetIndexingParams indexingParams = new DefaultFacetIndexingParams();
+ FacetIndexingParams indexingParams = FacetIndexingParams.ALL_PARENTS;
CategoryTokenizer tokenizer = new CategoryTokenizer(
new CategoryAttributesStream(new CategoryAttributesIterable(
longCategory)), indexingParams);
Modified: lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/BaseTestTopK.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/BaseTestTopK.java?rev=1421262&r1=1421261&r2=1421262&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/BaseTestTopK.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/BaseTestTopK.java Thu Dec 13 12:45:53 2012
@@ -1,6 +1,7 @@
package org.apache.lucene.facet.search;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -12,6 +13,7 @@ import org.apache.lucene.analysis.Analyz
import org.apache.lucene.facet.FacetTestBase;
import org.apache.lucene.facet.index.params.FacetIndexingParams;
import org.apache.lucene.facet.search.params.CountFacetRequest;
+import org.apache.lucene.facet.search.params.FacetRequest;
import org.apache.lucene.facet.search.params.FacetSearchParams;
import org.apache.lucene.facet.taxonomy.CategoryPath;
import org.apache.lucene.facet.taxonomy.TaxonomyWriter;
@@ -97,12 +99,12 @@ public abstract class BaseTestTopK exten
}
protected FacetSearchParams searchParamsWithRequests(int numResults, int partitionSize) {
- FacetSearchParams res = getFacetedSearchParams(partitionSize);
- res.addFacetRequest(new CountFacetRequest(new CategoryPath("a"), numResults));
- res.addFacetRequest(new CountFacetRequest(new CategoryPath("a", "1"), numResults));
- res.addFacetRequest(new CountFacetRequest(new CategoryPath("a", "1", "10"), numResults));
- res.addFacetRequest(new CountFacetRequest(new CategoryPath("a", "2", "26", "267"), numResults));
- return res;
+ 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));
+ return getFacetSearchParams(facetRequests, getFacetIndexingParams(partitionSize));
}
@Override
Modified: lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/DrillDownTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/DrillDownTest.java?rev=1421262&r1=1421261&r2=1421262&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/DrillDownTest.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/DrillDownTest.java Thu Dec 13 12:45:53 2012
@@ -2,6 +2,8 @@ package org.apache.lucene.facet.search;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.analysis.MockTokenizer;
@@ -10,8 +12,8 @@ import org.apache.lucene.document.Field;
import org.apache.lucene.document.TextField;
import org.apache.lucene.facet.index.CategoryDocumentBuilder;
import org.apache.lucene.facet.index.params.CategoryListParams;
+import org.apache.lucene.facet.index.params.FacetIndexingParams;
import org.apache.lucene.facet.index.params.PerDimensionIndexingParams;
-import org.apache.lucene.facet.search.params.FacetSearchParams;
import org.apache.lucene.facet.taxonomy.CategoryPath;
import org.apache.lucene.facet.taxonomy.TaxonomyWriter;
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyReader;
@@ -49,22 +51,18 @@ import org.junit.Test;
public class DrillDownTest extends LuceneTestCase {
- private FacetSearchParams defaultParams = new FacetSearchParams();
- private FacetSearchParams nonDefaultParams;
+ private FacetIndexingParams defaultParams = FacetIndexingParams.ALL_PARENTS;
+ private PerDimensionIndexingParams nonDefaultParams;
private static IndexReader reader;
private static DirectoryTaxonomyReader taxo;
private static Directory dir;
private static Directory taxoDir;
public DrillDownTest() {
- PerDimensionIndexingParams iParams = new PerDimensionIndexingParams();
- CategoryListParams aClParams = new CategoryListParams(new Term("testing_facets_a", "a"));
- CategoryListParams bClParams = new CategoryListParams(new Term("testing_facets_b", "b"));
-
- iParams.addCategoryListParams(new CategoryPath("a"), aClParams);
- iParams.addCategoryListParams(new CategoryPath("b"), bClParams);
-
- nonDefaultParams = new FacetSearchParams(iParams);
+ Map<CategoryPath,CategoryListParams> paramsMap = new HashMap<CategoryPath,CategoryListParams>();
+ paramsMap.put(new CategoryPath("a"), new CategoryListParams(new Term("testing_facets_a", "a")));
+ paramsMap.put(new CategoryPath("b"), new CategoryListParams(new Term("testing_facets_b", "b")));
+ nonDefaultParams = new PerDimensionIndexingParams(paramsMap);
}
@BeforeClass
Modified: lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestCategoryListCache.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestCategoryListCache.java?rev=1421262&r1=1421261&r2=1421262&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestCategoryListCache.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestCategoryListCache.java Thu Dec 13 12:45:53 2012
@@ -1,6 +1,7 @@
package org.apache.lucene.facet.search;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -16,6 +17,7 @@ import org.apache.lucene.facet.index.par
import org.apache.lucene.facet.search.cache.CategoryListCache;
import org.apache.lucene.facet.search.cache.CategoryListData;
import org.apache.lucene.facet.search.params.CountFacetRequest;
+import org.apache.lucene.facet.search.params.FacetRequest;
import org.apache.lucene.facet.search.params.FacetSearchParams;
import org.apache.lucene.facet.search.results.FacetResult;
import org.apache.lucene.facet.taxonomy.CategoryPath;
@@ -74,22 +76,29 @@ public class TestCategoryListCache exten
private void doTest(boolean withCache, boolean plantWrongData) throws Exception {
Map<CategoryPath,Integer> truth = facetCountsTruth();
- CategoryPath cp = (CategoryPath) truth.keySet().toArray()[0]; // any category path will do for this test
- CountFacetRequest frq = new CountFacetRequest(cp, 10);
- FacetSearchParams sParams = getFacetedSearchParams();
- sParams.addFacetRequest(frq);
+ CategoryPath cp = (CategoryPath) truth.keySet().toArray()[0]; // any category path will do for this test
+ FacetIndexingParams iParams = FacetIndexingParams.ALL_PARENTS;
+ final CategoryListCache clCache;
if (withCache) {
//let's use a cached cl data
- FacetIndexingParams iparams = sParams.getFacetIndexingParams();
CategoryListParams clp = new CategoryListParams(); // default term ok as only single list
- CategoryListCache clCache = new CategoryListCache();
- clCache.loadAndRegister(clp, indexReader, taxoReader, iparams);
+ clCache = new CategoryListCache();
+ clCache.loadAndRegister(clp, indexReader, taxoReader, iParams);
if (plantWrongData) {
// let's mess up the cached data and then expect a wrong result...
messCachedData(clCache, clp);
}
- sParams.setClCache(clCache);
+ } else {
+ clCache = null;
}
+ List<FacetRequest> req = new ArrayList<FacetRequest>();
+ req.add(new CountFacetRequest(cp, 10));
+ final FacetSearchParams sParams = new FacetSearchParams(req, iParams) {
+ @Override
+ public CategoryListCache getCategoryListCache() {
+ return clCache;
+ }
+ };
FacetsCollector fc = new FacetsCollector(sParams, indexReader, taxoReader);
searcher.search(new MatchAllDocsQuery(), fc);
List<FacetResult> res = fc.getFacetResults();
Modified: lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestDemoFacets.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestDemoFacets.java?rev=1421262&r1=1421261&r2=1421262&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestDemoFacets.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestDemoFacets.java Thu Dec 13 12:45:53 2012
@@ -84,12 +84,10 @@ public class TestDemoFacets extends Luce
TaxonomyReader taxoReader = new DirectoryTaxonomyReader(taxoWriter);
taxoWriter.close();
- // Holds all configuration for a facet request:
- FacetSearchParams fsp = new FacetSearchParams();
-
// Count both "Publish Date" and "Author" dimensions:
- fsp.addFacetRequest(new CountFacetRequest(new CategoryPath("Publish Date"), 10));
- fsp.addFacetRequest(new CountFacetRequest(new CategoryPath("Author"), 10));
+ FacetSearchParams fsp = new FacetSearchParams(
+ new CountFacetRequest(new CategoryPath("Publish Date"), 10),
+ new CountFacetRequest(new CategoryPath("Author"), 10));
// Aggregatses the facet counts:
FacetsCollector c = new FacetsCollector(fsp, searcher.getIndexReader(), taxoReader);
@@ -110,9 +108,8 @@ public class TestDemoFacets extends Luce
// Now user drills down on Publish Date/2010:
- fsp = new FacetSearchParams();
+ fsp = new FacetSearchParams(new CountFacetRequest(new CategoryPath("Author"), 10));
Query q2 = DrillDown.query(fsp, new MatchAllDocsQuery(), new CategoryPath("Publish Date/2010", '/'));
- fsp.addFacetRequest(new CountFacetRequest(new CategoryPath("Author"), 10));
c = new FacetsCollector(fsp, searcher.getIndexReader(), taxoReader);
searcher.search(q2, c);
results = c.getFacetResults();
Modified: lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestFacetsAccumulatorWithComplement.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestFacetsAccumulatorWithComplement.java?rev=1421262&r1=1421261&r2=1421262&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestFacetsAccumulatorWithComplement.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestFacetsAccumulatorWithComplement.java Thu Dec 13 12:45:53 2012
@@ -123,18 +123,15 @@ public class TestFacetsAccumulatorWithCo
}
- @Override
- protected FacetSearchParams getFacetedSearchParams() {
- FacetSearchParams res = super.getFacetedSearchParams();
- res.addFacetRequest(new CountFacetRequest(new CategoryPath("root","a"), 10));
- return res;
+ private FacetSearchParams getFacetSearchParams() {
+ return new FacetSearchParams(new CountFacetRequest(new CategoryPath("root","a"), 10));
}
/** compute facets with certain facet requests and docs */
private List<FacetResult> findFacets(ScoredDocIDs sDocids, boolean withComplement) throws IOException {
FacetsAccumulator fAccumulator =
- new StandardFacetsAccumulator(getFacetedSearchParams(), indexReader, taxoReader);
+ new StandardFacetsAccumulator(getFacetSearchParams(), indexReader, taxoReader);
fAccumulator.setComplementThreshold(
withComplement ?
Modified: lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestFacetsCollector.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestFacetsCollector.java?rev=1421262&r1=1421261&r2=1421262&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestFacetsCollector.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestFacetsCollector.java Thu Dec 13 12:45:53 2012
@@ -67,8 +67,7 @@ public class TestFacetsCollector extends
taxonomyWriter.close();
iw.close();
- FacetSearchParams sParams = new FacetSearchParams();
- sParams.addFacetRequest(new ScoreFacetRequest(new CategoryPath("a"), 10));
+ FacetSearchParams sParams = new FacetSearchParams(new ScoreFacetRequest(new CategoryPath("a"), 10));
DirectoryReader r = DirectoryReader.open(indexDir);
DirectoryTaxonomyReader taxo = new DirectoryTaxonomyReader(taxoDir);
Modified: lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestMultipleCategoryLists.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestMultipleCategoryLists.java?rev=1421262&r1=1421261&r2=1421262&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestMultipleCategoryLists.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestMultipleCategoryLists.java Thu Dec 13 12:45:53 2012
@@ -1,8 +1,12 @@
package org.apache.lucene.facet.search;
import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.analysis.MockTokenizer;
@@ -11,6 +15,7 @@ import org.apache.lucene.facet.index.par
import org.apache.lucene.facet.index.params.FacetIndexingParams;
import org.apache.lucene.facet.index.params.PerDimensionIndexingParams;
import org.apache.lucene.facet.search.params.CountFacetRequest;
+import org.apache.lucene.facet.search.params.FacetRequest;
import org.apache.lucene.facet.search.params.FacetSearchParams;
import org.apache.lucene.facet.search.params.FacetRequest.ResultMode;
import org.apache.lucene.facet.search.results.FacetResult;
@@ -70,7 +75,7 @@ public class TestMultipleCategoryLists e
/**
* Configure with no custom counting lists
*/
- PerDimensionIndexingParams iParams = new PerDimensionIndexingParams();
+ PerDimensionIndexingParams iParams = new PerDimensionIndexingParams(Collections.<CategoryPath, CategoryListParams>emptyMap());
seedIndex(iw, tw, iParams);
@@ -109,9 +114,9 @@ public class TestMultipleCategoryLists e
TaxonomyWriter tw = new DirectoryTaxonomyWriter(dirs[0][1],
OpenMode.CREATE);
- PerDimensionIndexingParams iParams = new PerDimensionIndexingParams();
- iParams.addCategoryListParams(new CategoryPath("Author"),
- new CategoryListParams(new Term("$author", "Authors")));
+ PerDimensionIndexingParams iParams = new PerDimensionIndexingParams(
+ Collections.singletonMap(new CategoryPath("Author"),
+ new CategoryListParams(new Term("$author", "Authors"))));
seedIndex(iw, tw, iParams);
IndexReader ir = iw.getReader();
@@ -148,11 +153,10 @@ public class TestMultipleCategoryLists e
TaxonomyWriter tw = new DirectoryTaxonomyWriter(dirs[0][1],
OpenMode.CREATE);
- PerDimensionIndexingParams iParams = new PerDimensionIndexingParams();
- iParams.addCategoryListParams(new CategoryPath("Band"),
- new CategoryListParams(new Term("$music", "Bands")));
- iParams.addCategoryListParams(new CategoryPath("Composer"),
- new CategoryListParams(new Term("$music", "Composers")));
+ Map<CategoryPath,CategoryListParams> paramsMap = new HashMap<CategoryPath,CategoryListParams>();
+ paramsMap.put(new CategoryPath("Band"), new CategoryListParams(new Term("$music", "Bands")));
+ paramsMap.put(new CategoryPath("Composer"), new CategoryListParams(new Term("$music", "Composers")));
+ PerDimensionIndexingParams iParams = new PerDimensionIndexingParams(paramsMap);
seedIndex(iw, tw, iParams);
IndexReader ir = iw.getReader();
@@ -195,11 +199,10 @@ public class TestMultipleCategoryLists e
// create and open a taxonomy writer
TaxonomyWriter tw = new DirectoryTaxonomyWriter(dirs[0][1], OpenMode.CREATE);
- PerDimensionIndexingParams iParams = new PerDimensionIndexingParams();
- iParams.addCategoryListParams(new CategoryPath("Band"),
- new CategoryListParams(new Term("$bands", "Bands")));
- iParams.addCategoryListParams(new CategoryPath("Composer"),
- new CategoryListParams(new Term("$composers", "Composers")));
+ Map<CategoryPath,CategoryListParams> paramsMap = new HashMap<CategoryPath,CategoryListParams>();
+ paramsMap.put(new CategoryPath("Band"), new CategoryListParams(new Term("$bands", "Bands")));
+ paramsMap.put(new CategoryPath("Composer"), new CategoryListParams(new Term("$composers", "Composers")));
+ PerDimensionIndexingParams iParams = new PerDimensionIndexingParams(paramsMap);
seedIndex(iw, tw, iParams);
IndexReader ir = iw.getReader();
@@ -236,13 +239,11 @@ public class TestMultipleCategoryLists e
TaxonomyWriter tw = new DirectoryTaxonomyWriter(dirs[0][1],
OpenMode.CREATE);
- PerDimensionIndexingParams iParams = new PerDimensionIndexingParams();
- iParams.addCategoryListParams(new CategoryPath("Band"),
- new CategoryListParams(new Term("$music", "music")));
- iParams.addCategoryListParams(new CategoryPath("Composer"),
- new CategoryListParams(new Term("$music", "music")));
- iParams.addCategoryListParams(new CategoryPath("Author"),
- new CategoryListParams(new Term("$literature", "Authors")));
+ Map<CategoryPath,CategoryListParams> paramsMap = new HashMap<CategoryPath,CategoryListParams>();
+ paramsMap.put(new CategoryPath("Band"), new CategoryListParams(new Term("$music", "music")));
+ paramsMap.put(new CategoryPath("Composer"), new CategoryListParams(new Term("$music", "music")));
+ paramsMap.put(new CategoryPath("Author"), new CategoryListParams(new Term("$literature", "Authors")));
+ PerDimensionIndexingParams iParams = new PerDimensionIndexingParams(paramsMap);
seedIndex(iw, tw, iParams);
@@ -329,20 +330,21 @@ public class TestMultipleCategoryLists e
IndexSearcher searcher) throws IOException {
// step 1: collect matching documents into a collector
Query q = new MatchAllDocsQuery();
- TopScoreDocCollector topDocsCollector = TopScoreDocCollector.create(10,
- true);
+ TopScoreDocCollector topDocsCollector = TopScoreDocCollector.create(10, true);
- // Faceted search parameters indicate which facets are we interested in
- FacetSearchParams facetSearchParams = new FacetSearchParams(iParams);
-
- facetSearchParams.addFacetRequest(new CountFacetRequest(new CategoryPath("Band"), 10));
+ List<FacetRequest> facetRequests = new ArrayList<FacetRequest>();
+ facetRequests.add(new CountFacetRequest(new CategoryPath("Band"), 10));
CountFacetRequest bandDepth = new CountFacetRequest(new CategoryPath("Band"), 10);
bandDepth.setDepth(2);
// makes it easier to check the results in the test.
bandDepth.setResultMode(ResultMode.GLOBAL_FLAT);
- facetSearchParams.addFacetRequest(bandDepth);
- facetSearchParams.addFacetRequest(new CountFacetRequest(new CategoryPath("Author"), 10));
- facetSearchParams.addFacetRequest(new CountFacetRequest(new CategoryPath("Band", "Rock & Pop"), 10));
+ facetRequests.add(bandDepth);
+ facetRequests.add(new CountFacetRequest(new CategoryPath("Author"), 10));
+ facetRequests.add(new CountFacetRequest(new CategoryPath("Band", "Rock & Pop"), 10));
+
+ // Faceted search parameters indicate which facets are we interested in
+ FacetSearchParams facetSearchParams = new FacetSearchParams(facetRequests, iParams);
+
// perform documents search and facets accumulation
FacetsCollector facetsCollector = new FacetsCollector(facetSearchParams, ir, tr);
Modified: lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestScoredDocIdCollector.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestScoredDocIdCollector.java?rev=1421262&r1=1421261&r2=1421262&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestScoredDocIdCollector.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestScoredDocIdCollector.java Thu Dec 13 12:45:53 2012
@@ -80,7 +80,7 @@ public class TestScoredDocIdCollector ex
}
// verify by facet values
- List<FacetResult> countRes = findFacets(scoredDocIDs, getFacetedSearchParams());
+ List<FacetResult> countRes = findFacets(scoredDocIDs, getFacetSearchParams());
List<FacetResult> scoreRes = findFacets(scoredDocIDs, sumScoreSearchParams());
assertEquals("Wrong number of facet count results!", 1, countRes.size());
@@ -160,16 +160,11 @@ public class TestScoredDocIdCollector ex
/* use a scoring aggregator */
private FacetSearchParams sumScoreSearchParams() {
// this will use default faceted indexing params, not altering anything about indexing
- FacetSearchParams res = super.getFacetedSearchParams();
- res.addFacetRequest(new ScoreFacetRequest(new CategoryPath("root", "a"), 10));
- return res;
+ return new FacetSearchParams(new ScoreFacetRequest(new CategoryPath("root", "a"), 10));
}
- @Override
- protected FacetSearchParams getFacetedSearchParams() {
- FacetSearchParams res = super.getFacetedSearchParams();
- res.addFacetRequest(new CountFacetRequest(new CategoryPath("root","a"), 10));
- return res;
+ private FacetSearchParams getFacetSearchParams() {
+ return new FacetSearchParams(new CountFacetRequest(new CategoryPath("root","a"), 10));
}
}
\ No newline at end of file
Modified: lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestTopKInEachNodeResultHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestTopKInEachNodeResultHandler.java?rev=1421262&r1=1421261&r2=1421262&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestTopKInEachNodeResultHandler.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestTopKInEachNodeResultHandler.java Thu Dec 13 12:45:53 2012
@@ -8,22 +8,12 @@ import org.apache.lucene.analysis.MockAn
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.TextField;
-import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.index.IndexWriterConfig.OpenMode;
-import org.apache.lucene.index.RandomIndexWriter;
-import org.apache.lucene.index.Term;
-import org.apache.lucene.search.IndexSearcher;
-import org.apache.lucene.search.Query;
-import org.apache.lucene.search.TermQuery;
-import org.apache.lucene.store.Directory;
-import org.junit.Test;
-
-import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.facet.index.CategoryDocumentBuilder;
-import org.apache.lucene.facet.index.params.DefaultFacetIndexingParams;
+import org.apache.lucene.facet.index.params.FacetIndexingParams;
import org.apache.lucene.facet.search.params.CountFacetRequest;
-import org.apache.lucene.facet.search.params.FacetSearchParams;
+import org.apache.lucene.facet.search.params.FacetRequest;
import org.apache.lucene.facet.search.params.FacetRequest.ResultMode;
+import org.apache.lucene.facet.search.params.FacetSearchParams;
import org.apache.lucene.facet.search.results.FacetResult;
import org.apache.lucene.facet.search.results.FacetResultNode;
import org.apache.lucene.facet.taxonomy.CategoryPath;
@@ -31,6 +21,16 @@ import org.apache.lucene.facet.taxonomy.
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyReader;
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter;
import org.apache.lucene.facet.util.PartitionsUtils;
+import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.IndexWriterConfig.OpenMode;
+import org.apache.lucene.index.RandomIndexWriter;
+import org.apache.lucene.index.Term;
+import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.search.Query;
+import org.apache.lucene.search.TermQuery;
+import org.apache.lucene.store.Directory;
+import org.apache.lucene.util.LuceneTestCase;
+import org.junit.Test;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -69,9 +69,9 @@ public class TestTopKInEachNodeResultHan
}
final int pSize = partitionSize;
- DefaultFacetIndexingParams iParams = new DefaultFacetIndexingParams() {
+ FacetIndexingParams iParams = new FacetIndexingParams() {
@Override
- protected int fixedPartitionSize() {
+ public int getPartitionSize() {
return pSize;
}
};
@@ -153,17 +153,18 @@ public class TestTopKInEachNodeResultHan
cfrb20.setDepth(0);
cfrb20.setResultMode(ResultMode.PER_NODE_IN_TREE);
- FacetSearchParams facetSearchParams = new FacetSearchParams(iParams);
- facetSearchParams.addFacetRequest(cfra23);
- facetSearchParams.addFacetRequest(cfra22);
- facetSearchParams.addFacetRequest(cfra21);
- facetSearchParams.addFacetRequest(cfrb23);
- facetSearchParams.addFacetRequest(cfrb22);
- facetSearchParams.addFacetRequest(cfrb21);
- facetSearchParams.addFacetRequest(doctor);
- facetSearchParams.addFacetRequest(cfrb20);
+ List<FacetRequest> facetRequests = new ArrayList<FacetRequest>();
+ facetRequests.add(cfra23);
+ facetRequests.add(cfra22);
+ facetRequests.add(cfra21);
+ facetRequests.add(cfrb23);
+ facetRequests.add(cfrb22);
+ facetRequests.add(cfrb21);
+ facetRequests.add(doctor);
+ facetRequests.add(cfrb20);
+ FacetSearchParams facetSearchParams = new FacetSearchParams(facetRequests, iParams);
- FacetArrays facetArrays = new FacetArrays(PartitionsUtils.partitionSize(facetSearchParams,tr));
+ FacetArrays facetArrays = new FacetArrays(PartitionsUtils.partitionSize(facetSearchParams.getFacetIndexingParams(), tr));
FacetsAccumulator fctExtrctr = new StandardFacetsAccumulator(facetSearchParams, is.getIndexReader(), tr, facetArrays);
fctExtrctr.setComplementThreshold(FacetsAccumulator.DISABLE_COMPLEMENT);
long start = System.currentTimeMillis();
@@ -318,8 +319,8 @@ public class TestTopKInEachNodeResultHan
}
- private void prvt_add(DefaultFacetIndexingParams iParams, RandomIndexWriter iw,
- TaxonomyWriter tw, String... strings) throws IOException {
+ private void prvt_add(FacetIndexingParams iParams, RandomIndexWriter iw,
+ TaxonomyWriter tw, String... strings) throws IOException {
ArrayList<CategoryPath> cps = new ArrayList<CategoryPath>();
CategoryPath cp = new CategoryPath(strings);
cps.add(cp);
Modified: lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestTopKResultsHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestTopKResultsHandler.java?rev=1421262&r1=1421261&r2=1421262&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestTopKResultsHandler.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestTopKResultsHandler.java Thu Dec 13 12:45:53 2012
@@ -1,19 +1,20 @@
package org.apache.lucene.facet.search;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.search.MatchAllDocsQuery;
-import org.junit.Test;
-
import org.apache.lucene.facet.search.params.CountFacetRequest;
-import org.apache.lucene.facet.search.params.FacetSearchParams;
+import org.apache.lucene.facet.search.params.FacetRequest;
import org.apache.lucene.facet.search.params.FacetRequest.ResultMode;
+import org.apache.lucene.facet.search.params.FacetSearchParams;
import org.apache.lucene.facet.search.results.FacetResult;
import org.apache.lucene.facet.search.results.FacetResultNode;
import org.apache.lucene.facet.taxonomy.CategoryPath;
import org.apache.lucene.facet.taxonomy.TaxonomyReader;
+import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.search.MatchAllDocsQuery;
+import org.junit.Test;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -74,18 +75,19 @@ public class TestTopKResultsHandler exte
for (int partitionSize : partitionSizes) {
initIndex(partitionSize);
- // do different facet counts and compare to control
- FacetSearchParams sParams = getFacetedSearchParams(partitionSize);
-
- sParams.addFacetRequest(new CountFacetRequest(new CategoryPath("a"), 100));
+ List<FacetRequest> facetRequests = new ArrayList<FacetRequest>();
+ facetRequests.add(new CountFacetRequest(new CategoryPath("a"), 100));
CountFacetRequest cfra = new CountFacetRequest(new CategoryPath("a"), 100);
cfra.setDepth(3);
// makes it easier to check the results in the test.
cfra.setResultMode(ResultMode.GLOBAL_FLAT);
- sParams.addFacetRequest(cfra);
- sParams.addFacetRequest(new CountFacetRequest(new CategoryPath("a", "b"), 100));
- sParams.addFacetRequest(new CountFacetRequest(new CategoryPath("a", "b", "1"), 100));
- sParams.addFacetRequest(new CountFacetRequest(new CategoryPath("a", "c"), 100));
+ facetRequests.add(cfra);
+ facetRequests.add(new CountFacetRequest(new CategoryPath("a", "b"), 100));
+ facetRequests.add(new CountFacetRequest(new CategoryPath("a", "b", "1"), 100));
+ facetRequests.add(new CountFacetRequest(new CategoryPath("a", "c"), 100));
+
+ // do different facet counts and compare to control
+ FacetSearchParams sParams = getFacetSearchParams(facetRequests, getFacetIndexingParams(partitionSize));
FacetsCollector fc = new FacetsCollector(sParams, indexReader, taxoReader) {
@Override
@@ -157,8 +159,8 @@ public class TestTopKResultsHandler exte
// do different facet counts and compare to control
CategoryPath path = new CategoryPath("a", "b");
- FacetSearchParams sParams = getFacetedSearchParams(partitionSize);
- sParams.addFacetRequest(new CountFacetRequest(path, Integer.MAX_VALUE));
+ FacetSearchParams sParams = getFacetSearchParams(
+ getFacetIndexingParams(partitionSize), new CountFacetRequest(path, Integer.MAX_VALUE));
FacetsCollector fc = new FacetsCollector(sParams, indexReader, taxoReader) {
@Override
@@ -183,8 +185,8 @@ public class TestTopKResultsHandler exte
assertEquals(path + " should only have 4 desendants", 4, res.getNumValidDescendants());
// As a control base results, ask for top-1000 results
- FacetSearchParams sParams2 = getFacetedSearchParams(partitionSize);
- sParams2.addFacetRequest(new CountFacetRequest(path, Integer.MAX_VALUE));
+ FacetSearchParams sParams2 = getFacetSearchParams(
+ getFacetIndexingParams(partitionSize), new CountFacetRequest(path, Integer.MAX_VALUE));
FacetsCollector fc2 = new FacetsCollector(sParams2, indexReader, taxoReader) {
@Override
@@ -220,8 +222,9 @@ public class TestTopKResultsHandler exte
initIndex(partitionSize);
CategoryPath path = new CategoryPath("Miau Hattulla");
- FacetSearchParams sParams = getFacetedSearchParams(partitionSize);
- sParams.addFacetRequest(new CountFacetRequest(path, 10));
+ FacetSearchParams sParams = getFacetSearchParams(
+ getFacetIndexingParams(partitionSize),
+ new CountFacetRequest(path, 10));
FacetsCollector fc = new FacetsCollector(sParams, indexReader, taxoReader);
Modified: lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestTotalFacetCounts.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestTotalFacetCounts.java?rev=1421262&r1=1421261&r2=1421262&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestTotalFacetCounts.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestTotalFacetCounts.java Thu Dec 13 12:45:53 2012
@@ -4,17 +4,16 @@ import java.io.File;
import java.io.IOException;
import java.util.Arrays;
+import org.apache.lucene.facet.FacetTestUtils;
+import org.apache.lucene.facet.FacetTestUtils.IndexTaxonomyReaderPair;
+import org.apache.lucene.facet.FacetTestUtils.IndexTaxonomyWriterPair;
+import org.apache.lucene.facet.index.params.FacetIndexingParams;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.IOUtils;
+import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util._TestUtil;
import org.junit.Test;
-import org.apache.lucene.util.LuceneTestCase;
-import org.apache.lucene.facet.FacetTestUtils;
-import org.apache.lucene.facet.FacetTestUtils.IndexTaxonomyReaderPair;
-import org.apache.lucene.facet.FacetTestUtils.IndexTaxonomyWriterPair;
-import org.apache.lucene.facet.index.params.DefaultFacetIndexingParams;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -56,9 +55,9 @@ public class TestTotalFacetCounts extend
// Create our index/taxonomy writers
IndexTaxonomyWriterPair[] writers = FacetTestUtils
.createIndexTaxonomyWriterPair(dirs);
- DefaultFacetIndexingParams iParams = new DefaultFacetIndexingParams() {
+ FacetIndexingParams iParams = new FacetIndexingParams() {
@Override
- protected int fixedPartitionSize() {
+ public int getPartitionSize() {
return partitionSize;
}
};
Modified: lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestTotalFacetCountsCache.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestTotalFacetCountsCache.java?rev=1421262&r1=1421261&r2=1421262&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestTotalFacetCountsCache.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestTotalFacetCountsCache.java Thu Dec 13 12:45:53 2012
@@ -8,16 +8,6 @@ import java.util.List;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.analysis.MockTokenizer;
import org.apache.lucene.document.Document;
-import org.apache.lucene.index.DirectoryReader;
-import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.index.IndexWriter;
-import org.apache.lucene.index.IndexWriterConfig;
-import org.apache.lucene.store.Directory;
-import org.apache.lucene.store.MockDirectoryWrapper;
-import org.junit.Before;
-import org.junit.Test;
-
-import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.facet.FacetTestUtils;
import org.apache.lucene.facet.FacetTestUtils.IndexTaxonomyReaderPair;
import org.apache.lucene.facet.FacetTestUtils.IndexTaxonomyWriterPair;
@@ -26,7 +16,6 @@ import org.apache.lucene.facet.example.T
import org.apache.lucene.facet.example.multiCL.MultiCLIndexer;
import org.apache.lucene.facet.example.multiCL.MultiCLSearcher;
import org.apache.lucene.facet.index.CategoryDocumentBuilder;
-import org.apache.lucene.facet.index.params.DefaultFacetIndexingParams;
import org.apache.lucene.facet.index.params.FacetIndexingParams;
import org.apache.lucene.facet.search.TotalFacetCounts.CreationType;
import org.apache.lucene.facet.search.results.FacetResult;
@@ -36,9 +25,18 @@ import org.apache.lucene.facet.taxonomy.
import org.apache.lucene.facet.taxonomy.TaxonomyWriter;
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyReader;
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter;
+import org.apache.lucene.index.DirectoryReader;
+import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.index.IndexWriterConfig;
+import org.apache.lucene.store.Directory;
+import org.apache.lucene.store.MockDirectoryWrapper;
import org.apache.lucene.util.IOUtils;
+import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.SlowRAMDirectory;
import org.apache.lucene.util._TestUtil;
+import org.junit.Before;
+import org.junit.Test;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -196,7 +194,7 @@ public class TestTotalFacetCountsCache e
// it references a different TFC cache. This will still result
// in valid results, but will only search one of the category lists
// instead of all of them.
- multis[numThreads - 1] = new Multi(slowIndexReader, slowTaxoReader, new DefaultFacetIndexingParams());
+ multis[numThreads - 1] = new Multi(slowIndexReader, slowTaxoReader, FacetIndexingParams.ALL_PARENTS);
// Gentleman, start your engines
for (Multi m : multis) {
@@ -252,7 +250,7 @@ public class TestTotalFacetCountsCache e
// Create our index/taxonomy writers
IndexTaxonomyWriterPair[] writers = FacetTestUtils.createIndexTaxonomyWriterPair(dirs);
- DefaultFacetIndexingParams iParams = new DefaultFacetIndexingParams();
+ FacetIndexingParams iParams = FacetIndexingParams.ALL_PARENTS;
// Add a facet to the index
addFacets(iParams, writers[0].indexWriter, writers[0].taxWriter, "a", "b");
@@ -347,11 +345,10 @@ public class TestTotalFacetCountsCache e
// Create temporary RAMDirectories
Directory[][] dirs = FacetTestUtils.createIndexTaxonomyDirs(1);
// Create our index/taxonomy writers
- IndexTaxonomyWriterPair[] writers = FacetTestUtils
- .createIndexTaxonomyWriterPair(dirs);
- DefaultFacetIndexingParams iParams = new DefaultFacetIndexingParams() {
+ IndexTaxonomyWriterPair[] writers = FacetTestUtils.createIndexTaxonomyWriterPair(dirs);
+ FacetIndexingParams iParams = new FacetIndexingParams() {
@Override
- protected int fixedPartitionSize() {
+ public int getPartitionSize() {
return 2;
}
};
@@ -403,7 +400,7 @@ public class TestTotalFacetCountsCache e
IndexWriter w = new IndexWriter(indexDir, new IndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer(random(), MockTokenizer.WHITESPACE, false)));
DirectoryTaxonomyWriter tw = new DirectoryTaxonomyWriter(taxoDir);
- DefaultFacetIndexingParams iParams = new DefaultFacetIndexingParams();
+ FacetIndexingParams iParams = FacetIndexingParams.ALL_PARENTS;
// Add documents and facets
for (int i = 0; i < 1000; i++) {
addFacets(iParams, w, tw, "facet", Integer.toString(i));
@@ -454,7 +451,7 @@ public class TestTotalFacetCountsCache e
Directory[][] dirs = FacetTestUtils.createIndexTaxonomyDirs(2);
// Create our index/taxonomy writers
IndexTaxonomyWriterPair[] writers = FacetTestUtils.createIndexTaxonomyWriterPair(dirs);
- DefaultFacetIndexingParams iParams = new DefaultFacetIndexingParams();
+ FacetIndexingParams iParams = FacetIndexingParams.ALL_PARENTS;
// Add a facet to the index
addFacets(iParams, writers[0].indexWriter, writers[0].taxWriter, "a", "b");
Modified: lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/association/AssociationsFacetRequestTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/association/AssociationsFacetRequestTest.java?rev=1421262&r1=1421261&r2=1421262&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/association/AssociationsFacetRequestTest.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/association/AssociationsFacetRequestTest.java Thu Dec 13 12:45:53 2012
@@ -2,17 +2,6 @@ package org.apache.lucene.facet.search.a
import java.util.List;
-import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.index.RandomIndexWriter;
-import org.apache.lucene.search.IndexSearcher;
-import org.apache.lucene.search.MatchAllDocsQuery;
-import org.apache.lucene.search.Query;
-import org.apache.lucene.store.Directory;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.analysis.MockTokenizer;
import org.apache.lucene.document.Document;
@@ -20,7 +9,7 @@ import org.apache.lucene.facet.enhanceme
import org.apache.lucene.facet.enhancements.association.AssociationEnhancement;
import org.apache.lucene.facet.enhancements.association.AssociationFloatProperty;
import org.apache.lucene.facet.enhancements.association.AssociationIntProperty;
-import org.apache.lucene.facet.enhancements.params.DefaultEnhancementsIndexingParams;
+import org.apache.lucene.facet.enhancements.params.EnhancementsIndexingParams;
import org.apache.lucene.facet.index.CategoryContainer;
import org.apache.lucene.facet.search.FacetsCollector;
import org.apache.lucene.facet.search.params.FacetSearchParams;
@@ -31,6 +20,16 @@ import org.apache.lucene.facet.taxonomy.
import org.apache.lucene.facet.taxonomy.TaxonomyWriter;
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyReader;
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter;
+import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.RandomIndexWriter;
+import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.search.MatchAllDocsQuery;
+import org.apache.lucene.search.Query;
+import org.apache.lucene.store.Directory;
+import org.apache.lucene.util.LuceneTestCase;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -72,8 +71,7 @@ public class AssociationsFacetRequestTes
TaxonomyWriter taxoWriter = new DirectoryTaxonomyWriter(taxoDir);
EnhancementsDocumentBuilder builder = new EnhancementsDocumentBuilder(
- taxoWriter, new DefaultEnhancementsIndexingParams(
- new AssociationEnhancement()));
+ taxoWriter, new EnhancementsIndexingParams(new AssociationEnhancement()));
// index documents, 50% have only 'b' and all have 'a'
for (int i = 0; i < 100; i++) {
@@ -109,9 +107,9 @@ public class AssociationsFacetRequestTes
DirectoryTaxonomyReader taxo = new DirectoryTaxonomyReader(taxoDir);
// facet requests for two facets
- FacetSearchParams fsp = new FacetSearchParams();
- fsp.addFacetRequest(new AssociationIntSumFacetRequest(aint, 10));
- fsp.addFacetRequest(new AssociationIntSumFacetRequest(bint, 10));
+ FacetSearchParams fsp = new FacetSearchParams(
+ new AssociationIntSumFacetRequest(aint, 10),
+ new AssociationIntSumFacetRequest(bint, 10));
Query q = new MatchAllDocsQuery();
@@ -134,9 +132,9 @@ public class AssociationsFacetRequestTes
DirectoryTaxonomyReader taxo = new DirectoryTaxonomyReader(taxoDir);
// facet requests for two facets
- FacetSearchParams fsp = new FacetSearchParams();
- fsp.addFacetRequest(new AssociationFloatSumFacetRequest(afloat, 10));
- fsp.addFacetRequest(new AssociationFloatSumFacetRequest(bfloat, 10));
+ FacetSearchParams fsp = new FacetSearchParams(
+ new AssociationFloatSumFacetRequest(afloat, 10),
+ new AssociationFloatSumFacetRequest(bfloat, 10));
Query q = new MatchAllDocsQuery();
@@ -162,11 +160,11 @@ public class AssociationsFacetRequestTes
DirectoryTaxonomyReader taxo = new DirectoryTaxonomyReader(taxoDir);
// facet requests for two facets
- FacetSearchParams fsp = new FacetSearchParams();
- fsp.addFacetRequest(new AssociationIntSumFacetRequest(aint, 10));
- fsp.addFacetRequest(new AssociationIntSumFacetRequest(bint, 10));
- fsp.addFacetRequest(new AssociationFloatSumFacetRequest(afloat, 10));
- fsp.addFacetRequest(new AssociationFloatSumFacetRequest(bfloat, 10));
+ FacetSearchParams fsp = new FacetSearchParams(
+ new AssociationIntSumFacetRequest(aint, 10),
+ new AssociationIntSumFacetRequest(bint, 10),
+ new AssociationFloatSumFacetRequest(afloat, 10),
+ new AssociationFloatSumFacetRequest(bfloat, 10));
Query q = new MatchAllDocsQuery();
Modified: lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/params/FacetSearchParamsTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/params/FacetSearchParamsTest.java?rev=1421262&r1=1421261&r2=1421262&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/params/FacetSearchParamsTest.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/params/FacetSearchParamsTest.java Thu Dec 13 12:45:53 2012
@@ -1,16 +1,15 @@
package org.apache.lucene.facet.search.params;
-import org.apache.lucene.store.Directory;
-import org.junit.Test;
-
-import org.apache.lucene.util.LuceneTestCase;
-import org.apache.lucene.facet.index.params.DefaultFacetIndexingParams;
+import org.apache.lucene.facet.index.params.FacetIndexingParams;
import org.apache.lucene.facet.taxonomy.CategoryPath;
import org.apache.lucene.facet.taxonomy.TaxonomyReader;
import org.apache.lucene.facet.taxonomy.TaxonomyWriter;
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyReader;
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter;
import org.apache.lucene.facet.util.PartitionsUtils;
+import org.apache.lucene.store.Directory;
+import org.apache.lucene.util.LuceneTestCase;
+import org.junit.Test;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -32,47 +31,32 @@ import org.apache.lucene.facet.util.Part
public class FacetSearchParamsTest extends LuceneTestCase {
@Test
- public void testDefaultSettings() throws Exception {
- FacetSearchParams fsp = new FacetSearchParams();
- assertEquals("unexpected default facet indexing params class", DefaultFacetIndexingParams.class.getName(), fsp.getFacetIndexingParams().getClass().getName());
- assertEquals("no facet requests should be added by default", 0, fsp.getFacetRequests().size());
- Directory dir = newDirectory();
- new DirectoryTaxonomyWriter(dir).close();
- TaxonomyReader tr = new DirectoryTaxonomyReader(dir);
- assertEquals("unexpected partition offset for 0 categories", 1, PartitionsUtils.partitionOffset(fsp, 1, tr));
- assertEquals("unexpected partition size for 0 categories", 1, PartitionsUtils.partitionSize(fsp,tr));
- tr.close();
- dir.close();
- }
-
- @Test
public void testAddFacetRequest() throws Exception {
- FacetSearchParams fsp = new FacetSearchParams();
- fsp.addFacetRequest(new CountFacetRequest(new CategoryPath("a", "b"), 1));
+ FacetSearchParams fsp = new FacetSearchParams(new CountFacetRequest(new CategoryPath("a", "b"), 1));
assertEquals("expected 1 facet request", 1, fsp.getFacetRequests().size());
}
@Test
public void testPartitionSizeWithCategories() throws Exception {
- FacetSearchParams fsp = new FacetSearchParams();
Directory dir = newDirectory();
TaxonomyWriter tw = new DirectoryTaxonomyWriter(dir);
tw.addCategory(new CategoryPath("a"));
tw.commit();
tw.close();
TaxonomyReader tr = new DirectoryTaxonomyReader(dir);
- assertEquals("unexpected partition offset for 1 categories", 2, PartitionsUtils.partitionOffset(fsp, 1, tr));
- assertEquals("unexpected partition size for 1 categories", 2, PartitionsUtils.partitionSize(fsp,tr));
+ assertEquals("unexpected partition offset for 1 categories", 2,
+ PartitionsUtils.partitionOffset(FacetIndexingParams.ALL_PARENTS, 1, tr));
+ assertEquals("unexpected partition size for 1 categories", 2,
+ PartitionsUtils.partitionSize(FacetIndexingParams.ALL_PARENTS,tr));
tr.close();
dir.close();
}
@Test
public void testSearchParamsWithNullRequest() throws Exception {
- FacetSearchParams fsp = new FacetSearchParams();
try {
- fsp.addFacetRequest(null);
- fail("FacetSearchParams should throw IllegalArgumentException when trying to add a null FacetRequest");
+ assertNull(new FacetSearchParams());
+ fail("FacetSearchParams should throw IllegalArgumentException when not adding requests");
} catch (IllegalArgumentException e) {
}
}
Modified: lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/params/MultiIteratorsPerCLParamsTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/params/MultiIteratorsPerCLParamsTest.java?rev=1421262&r1=1421261&r2=1421262&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/params/MultiIteratorsPerCLParamsTest.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/params/MultiIteratorsPerCLParamsTest.java Thu Dec 13 12:45:53 2012
@@ -1,22 +1,15 @@
package org.apache.lucene.facet.search.params;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.analysis.MockTokenizer;
import org.apache.lucene.document.Document;
-import org.apache.lucene.index.DirectoryReader;
-import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.index.RandomIndexWriter;
-import org.apache.lucene.store.Directory;
-import org.junit.Test;
-
-import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.facet.index.CategoryDocumentBuilder;
import org.apache.lucene.facet.index.params.CategoryListParams;
-import org.apache.lucene.facet.index.params.DefaultFacetIndexingParams;
import org.apache.lucene.facet.index.params.FacetIndexingParams;
import org.apache.lucene.facet.search.CategoryListIterator;
import org.apache.lucene.facet.search.FacetArrays;
@@ -35,6 +28,12 @@ import org.apache.lucene.facet.taxonomy.
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyReader;
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter;
import org.apache.lucene.facet.util.ScoredDocIdsUtils;
+import org.apache.lucene.index.DirectoryReader;
+import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.RandomIndexWriter;
+import org.apache.lucene.store.Directory;
+import org.apache.lucene.util.LuceneTestCase;
+import org.junit.Test;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -87,7 +86,7 @@ public class MultiIteratorsPerCLParamsTe
// Create a CLP which generates different CLIs according to the
// FacetRequest's dimension
CategoryListParams clp = new CategoryListParams();
- FacetIndexingParams iParams = new DefaultFacetIndexingParams(clp);
+ FacetIndexingParams iParams = new FacetIndexingParams(clp);
Directory indexDir = newDirectory();
Directory taxoDir = newDirectory();
populateIndex(iParams, indexDir, taxoDir);
@@ -135,16 +134,19 @@ public class MultiIteratorsPerCLParamsTe
}
private void validateFacetedSearch(FacetIndexingParams iParams,
- TaxonomyReader taxo, IndexReader reader, CategoryListCache clCache, ScoredDocIDs allDocs,
- String[] dimension, int[] expectedValue,
- int[] expectedNumDescendants)
- throws IOException {
- FacetSearchParams sParams = new FacetSearchParams(iParams);
- sParams.setClCache(clCache);
+ TaxonomyReader taxo, IndexReader reader, final CategoryListCache clCache,
+ ScoredDocIDs allDocs, String[] dimension, int[] expectedValue,
+ int[] expectedNumDescendants) throws IOException {
+ List<FacetRequest> facetRequests = new ArrayList<FacetRequest>();
for (String dim : dimension) {
- sParams.addFacetRequest(new PerDimCountFacetRequest(
- new CategoryPath(dim), 10));
+ facetRequests.add(new PerDimCountFacetRequest(new CategoryPath(dim), 10));
}
+ FacetSearchParams sParams = new FacetSearchParams(facetRequests, iParams) {
+ @Override
+ public CategoryListCache getCategoryListCache() {
+ return clCache;
+ }
+ };
FacetsAccumulator acc = new StandardFacetsAccumulator(sParams, reader, taxo);
// no use to test this with complement since at that mode all facets are taken
Modified: lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/sampling/OversampleWithDepthTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/sampling/OversampleWithDepthTest.java?rev=1421262&r1=1421261&r2=1421262&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/sampling/OversampleWithDepthTest.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/sampling/OversampleWithDepthTest.java Thu Dec 13 12:45:53 2012
@@ -63,14 +63,12 @@ public class OversampleWithDepthTest ext
DirectoryReader r = DirectoryReader.open(indexDir);
TaxonomyReader tr = new DirectoryTaxonomyReader(taxoDir);
- FacetSearchParams fsp = new FacetSearchParams();
-
CountFacetRequest facetRequest = new CountFacetRequest(new CategoryPath("root"), 10);
-
// Setting the depth to '2', should potentially get all categories
facetRequest.setDepth(2);
facetRequest.setResultMode(ResultMode.PER_NODE_IN_TREE);
- fsp.addFacetRequest(facetRequest);
+
+ FacetSearchParams fsp = new FacetSearchParams(facetRequest);
// Craft sampling params to enforce sampling
final SamplingParams params = new SamplingParams();