You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2013/11/17 21:31:07 UTC

svn commit: r1542804 - in /lucene/dev/branches/lucene5339: ./ lucene/facet/src/java/org/apache/lucene/facet/associations/ lucene/facet/src/java/org/apache/lucene/facet/simple/ lucene/facet/src/test/org/apache/lucene/facet/simple/

Author: mikemccand
Date: Sun Nov 17 20:31:07 2013
New Revision: 1542804

URL: http://svn.apache.org/r1542804
Log:
LUCENE-5339: simplify DrillDownQuery

Modified:
    lucene/dev/branches/lucene5339/TODO
    lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/associations/SumIntAssociationFacetsAggregator.java
    lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/FacetsConfig.java
    lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/SimpleDrillDownQuery.java
    lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/SimpleDrillSideways.java
    lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/simple/TestSimpleDrillSideways.java
    lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/simple/TestSortedSetDocValuesFacets.java
    lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/simple/TestTaxonomyFacets.java

Modified: lucene/dev/branches/lucene5339/TODO
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5339/TODO?rev=1542804&r1=1542803&r2=1542804&view=diff
==============================================================================
--- lucene/dev/branches/lucene5339/TODO (original)
+++ lucene/dev/branches/lucene5339/TODO Sun Nov 17 20:31:07 2013
@@ -2,15 +2,14 @@ nocommit this!
 
 TODO
   - associations
+  - nuke delimChar?  can we escape instead?
   - wrap an IW instead of extending one?
   - re-enable ALL_BUT_DIM somehow?
-  - simplify ddq api
   - SSDVValueSourceFacets?
   - we could put more stuff into the "schema", e.g. this field is
     sorted-set-DV and that one is taxo?
   - standardize on facet or facets (e.g. FacetIndexWriter)
   - fewer args when constructing a range
-  - rename CategoryPath -> FacetLabel
   - how to do avg() agg?
   - test needsScores=true / valuesource associations
   - make FieldTypes optional (if all your dims are flat)?

Modified: lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/associations/SumIntAssociationFacetsAggregator.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/associations/SumIntAssociationFacetsAggregator.java?rev=1542804&r1=1542803&r2=1542804&view=diff
==============================================================================
--- lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/associations/SumIntAssociationFacetsAggregator.java (original)
+++ lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/associations/SumIntAssociationFacetsAggregator.java Sun Nov 17 20:31:07 2013
@@ -56,7 +56,7 @@ public class SumIntAssociationFacetsAggr
     while (doc < length && (doc = matchingDocs.bits.nextSetBit(doc)) != -1) {
       dv.get(doc, bytes);
       if (bytes.length > 0) {
-        // aggreate association values for ordinals
+        // aggregate association values for ordinals
         int bytesUpto = bytes.offset + bytes.length;
         int pos = bytes.offset;
         while (pos < bytesUpto) {

Modified: lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/FacetsConfig.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/FacetsConfig.java?rev=1542804&r1=1542803&r2=1542804&view=diff
==============================================================================
--- lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/FacetsConfig.java (original)
+++ lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/FacetsConfig.java Sun Nov 17 20:31:07 2013
@@ -28,8 +28,6 @@ public class FacetsConfig {
 
   // nocommit pull the delim char into there?
   // nocommit pull DimType into here (shai?)
-  // nocommit pull facet field ($facets) into here, instead
-  // of optionally setting it on FacetField
 
   private final Map<String,DimConfig> fieldTypes = new ConcurrentHashMap<String,DimConfig>();
 

Modified: lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/SimpleDrillDownQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/SimpleDrillDownQuery.java?rev=1542804&r1=1542803&r2=1542804&view=diff
==============================================================================
--- lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/SimpleDrillDownQuery.java (original)
+++ lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/SimpleDrillDownQuery.java Sun Nov 17 20:31:07 2013
@@ -51,21 +51,23 @@ import org.apache.lucene.search.TermQuer
  */
 public final class SimpleDrillDownQuery extends Query {
 
-  private static Term term(String field, char delimChar, FacetLabel path) {
-    return new Term(field, path.toString(delimChar));
+  private static Term term(String field, char delimChar, String dim, String[] path) {
+    return new Term(field, FacetLabel.create(dim, path).toString(delimChar));
   }
 
+  private final FacetsConfig config;
   private final BooleanQuery query;
   private final Map<String,Integer> drillDownDims = new LinkedHashMap<String,Integer>();
 
   /** Used by clone() */
-  SimpleDrillDownQuery(BooleanQuery query, Map<String,Integer> drillDownDims) {
+  SimpleDrillDownQuery(FacetsConfig config, BooleanQuery query, Map<String,Integer> drillDownDims) {
     this.query = query.clone();
     this.drillDownDims.putAll(drillDownDims);
+    this.config = config;
   }
 
   /** Used by DrillSideways */
-  SimpleDrillDownQuery(Filter filter, SimpleDrillDownQuery other) {
+  SimpleDrillDownQuery(FacetsConfig config, Filter filter, SimpleDrillDownQuery other) {
     query = new BooleanQuery(true); // disable coord
 
     BooleanClause[] clauses = other.query.getClauses();
@@ -78,10 +80,11 @@ public final class SimpleDrillDownQuery 
     for(int i=1;i<clauses.length;i++) {
       query.add(clauses[i].getQuery(), Occur.MUST);
     }
+    this.config = config;
   }
 
   /** Used by DrillSideways */
-  SimpleDrillDownQuery(Query baseQuery, List<Query> clauses, Map<String,Integer> drillDownDims) {
+  SimpleDrillDownQuery(FacetsConfig config, Query baseQuery, List<Query> clauses, Map<String,Integer> drillDownDims) {
     this.query = new BooleanQuery(true);
     if (baseQuery != null) {
       query.add(baseQuery, Occur.MUST);      
@@ -90,6 +93,7 @@ public final class SimpleDrillDownQuery 
       query.add(clause, Occur.MUST);
     }
     this.drillDownDims.putAll(drillDownDims);
+    this.config = config;
   }
 
   /**
@@ -97,8 +101,8 @@ public final class SimpleDrillDownQuery 
    * to perform a pure browsing query (equivalent to using
    * {@link MatchAllDocsQuery} as base).
    */
-  public SimpleDrillDownQuery() {
-    this(null);
+  public SimpleDrillDownQuery(FacetsConfig config) {
+    this(config, null);
   }
   
   /**
@@ -107,55 +111,57 @@ public final class SimpleDrillDownQuery 
    * {@link #rewrite(IndexReader)} will be a pure browsing query, filtering on
    * the added categories only.
    */
-  public SimpleDrillDownQuery(Query baseQuery) {
+  public SimpleDrillDownQuery(FacetsConfig config, Query baseQuery) {
     query = new BooleanQuery(true); // disable coord
     if (baseQuery != null) {
       query.add(baseQuery, Occur.MUST);
     }
+    this.config = config;
   }
 
-  /**
-   * Adds one dimension of drill downs; if you pass multiple values they are
-   * OR'd, and then the entire dimension is AND'd against the base query.
-   */
+  /** Merges (ORs) a new path into an existing AND'd
+   *  clause. */ 
+  private void merge(String dim, String[] path) {
+    int index = drillDownDims.get(dim);
+    if (query.getClauses().length == drillDownDims.size()+1) {
+      index++;
+    }
+    ConstantScoreQuery q = (ConstantScoreQuery) query.clauses().get(index).getQuery();
+    if ((q.getQuery() instanceof BooleanQuery) == false) {
+      // App called .add(dim, customQuery) and then tried to
+      // merge a facet label in:
+      throw new RuntimeException("cannot merge with custom Query");
+    }
+    String indexedField = config.getDimConfig(dim).indexedFieldName;
+
+    // nocommit pull this from FacetsConfig
+    char delimChar = Constants.DEFAULT_DELIM_CHAR;
+    BooleanQuery bq = (BooleanQuery) q.getQuery();
+    bq.add(new TermQuery(term(indexedField, delimChar, dim, path)), Occur.SHOULD);
+  }
+
+  /** Adds one dimension of drill downs; if you pass the same
+   *  dimension again, it's OR'd with the previous
+   *  constraints on that dimension, and all dimensions are
+   *  AND'd against each other and the base query. */
   // nocommit can we remove FacetLabel here?
-  public void add(FacetLabel... paths) {
-    add(FacetsConfig.DEFAULT_INDEXED_FIELD_NAME, Constants.DEFAULT_DELIM_CHAR, paths);
-  }
+  public void add(String dim, String... path) {
 
-  // nocommit can we remove FacetLabel here?
-  public void add(String field, FacetLabel... paths) {
-    add(field, Constants.DEFAULT_DELIM_CHAR, paths);
-  }
-
-  // nocommit can we remove FacetLabel here?
-  public void add(String field, char delimChar, FacetLabel... paths) {
-    Query q;
-    if (paths[0].length == 0) {
-      throw new IllegalArgumentException("all CategoryPaths must have length > 0");
-    }
-    String dim = paths[0].components[0];
     if (drillDownDims.containsKey(dim)) {
-      throw new IllegalArgumentException("dimension '" + dim + "' was already added");
+      merge(dim, path);
+      return;
     }
-    if (paths.length == 1) {
-      q = new TermQuery(term(field, delimChar, paths[0]));
-    } else {
-      BooleanQuery bq = new BooleanQuery(true); // disable coord
-      for (FacetLabel cp : paths) {
-        if (cp.length == 0) {
-          throw new IllegalArgumentException("all CategoryPaths must have length > 0");
-        }
-        if (!cp.components[0].equals(dim)) {
-          throw new IllegalArgumentException("multiple (OR'd) drill-down paths must be under same dimension; got '" 
-              + dim + "' and '" + cp.components[0] + "'");
-        }
-        bq.add(new TermQuery(term(field, delimChar, cp)), Occur.SHOULD);
-      }
-      q = bq;
+    String indexedField = config.getDimConfig(dim).indexedFieldName;
+
+    // nocommit pull this from FacetsConfig
+    char delimChar = Constants.DEFAULT_DELIM_CHAR;
+    BooleanQuery bq = new BooleanQuery(true); // disable coord
+    if (path.length == 0) {
+      throw new IllegalArgumentException("must have at least one facet label under dim");
     }
+    bq.add(new TermQuery(term(indexedField, delimChar, dim, path)), Occur.SHOULD);
 
-    add(dim, q);
+    add(dim, bq);
   }
 
   /** Expert: add a custom drill-down subQuery.  Use this
@@ -177,7 +183,7 @@ public final class SimpleDrillDownQuery 
 
   @Override
   public SimpleDrillDownQuery clone() {
-    return new SimpleDrillDownQuery(query, drillDownDims);
+    return new SimpleDrillDownQuery(config, query, drillDownDims);
   }
   
   @Override

Modified: lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/SimpleDrillSideways.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/SimpleDrillSideways.java?rev=1542804&r1=1542803&r2=1542804&view=diff
==============================================================================
--- lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/SimpleDrillSideways.java (original)
+++ lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/SimpleDrillSideways.java Sun Nov 17 20:31:07 2013
@@ -76,22 +76,22 @@ public class SimpleDrillSideways {
   protected final IndexSearcher searcher;
   protected final TaxonomyReader taxoReader;
   protected final SortedSetDocValuesReaderState state;
-  protected final FacetsConfig facetsConfig;
+  protected final FacetsConfig config;
 
   /**
    * Create a new {@code DrillSideways} instance, assuming the categories were
    * indexed with {@link FacetFields}.
    */
-  public SimpleDrillSideways(IndexSearcher searcher, FacetsConfig facetsConfig, TaxonomyReader taxoReader) {
-    this(searcher, facetsConfig, taxoReader, null);
+  public SimpleDrillSideways(IndexSearcher searcher, FacetsConfig config, TaxonomyReader taxoReader) {
+    this(searcher, config, taxoReader, null);
   }
     
   /**
    * Create a new {@code DrillSideways} instance, assuming the categories were
    * indexed with {@link SortedSetDocValuesFacetFields}.
    */
-  public SimpleDrillSideways(IndexSearcher searcher, FacetsConfig facetsConfig, SortedSetDocValuesReaderState state) {
-    this(searcher, facetsConfig, null, state);
+  public SimpleDrillSideways(IndexSearcher searcher, FacetsConfig config, SortedSetDocValuesReaderState state) {
+    this(searcher, config, null, state);
   }
 
   /**
@@ -99,9 +99,9 @@ public class SimpleDrillSideways {
    * dimensions are sorted set facets and others are
    * taxononmy facets.
    */
-  public SimpleDrillSideways(IndexSearcher searcher, FacetsConfig facetsConfig, TaxonomyReader taxoReader, SortedSetDocValuesReaderState state) {
+  public SimpleDrillSideways(IndexSearcher searcher, FacetsConfig config, TaxonomyReader taxoReader, SortedSetDocValuesReaderState state) {
     this.searcher = searcher;
-    this.facetsConfig = facetsConfig;
+    this.config = config;
     this.taxoReader = taxoReader;
     this.state = state;
   }
@@ -110,7 +110,7 @@ public class SimpleDrillSideways {
    *  impl. */
   protected Facets buildFacetsResult(SimpleFacetsCollector drillDowns, SimpleFacetsCollector[] drillSideways, String[] drillSidewaysDims) throws IOException {
 
-    Facets drillDownFacets = new FastTaxonomyFacetCounts(taxoReader, facetsConfig, drillDowns);
+    Facets drillDownFacets = new FastTaxonomyFacetCounts(taxoReader, config, drillDowns);
 
     if (drillSideways == null) {
       return drillDownFacets;
@@ -118,7 +118,7 @@ public class SimpleDrillSideways {
       Map<String,Facets> drillSidewaysFacets = new HashMap<String,Facets>();
       for(int i=0;i<drillSideways.length;i++) {
         drillSidewaysFacets.put(drillSidewaysDims[i],
-                                new FastTaxonomyFacetCounts(taxoReader, facetsConfig, drillSideways[i]));
+                                new FastTaxonomyFacetCounts(taxoReader, config, drillSideways[i]));
       }
       return new MultiFacets(drillSidewaysFacets, drillDownFacets);
     }
@@ -313,7 +313,7 @@ public class SimpleDrillSideways {
                                           Filter filter, FieldDoc after, int topN, Sort sort, boolean doDocScores,
                                           boolean doMaxScore) throws IOException {
     if (filter != null) {
-      query = new SimpleDrillDownQuery(filter, query);
+      query = new SimpleDrillDownQuery(config, filter, query);
     }
     if (sort != null) {
       int limit = searcher.getIndexReader().maxDoc();

Modified: lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/simple/TestSimpleDrillSideways.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/simple/TestSimpleDrillSideways.java?rev=1542804&r1=1542803&r2=1542804&view=diff
==============================================================================
--- lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/simple/TestSimpleDrillSideways.java (original)
+++ lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/simple/TestSimpleDrillSideways.java Sun Nov 17 20:31:07 2013
@@ -39,7 +39,6 @@ import org.apache.lucene.facet.params.Fa
 import org.apache.lucene.facet.simple.SimpleDrillSideways.SimpleDrillSidewaysResult;
 import org.apache.lucene.facet.sortedset.SortedSetDocValuesFacetFields;
 import org.apache.lucene.facet.sortedset.SortedSetDocValuesReaderState;
-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;
@@ -132,8 +131,8 @@ public class TestSimpleDrillSideways ext
     // Simple case: drill-down on a single field; in this
     // case the drill-sideways + drill-down counts ==
     // drill-down of just the query: 
-    SimpleDrillDownQuery ddq = new SimpleDrillDownQuery();
-    ddq.add(new FacetLabel("Author", "Lisa"));
+    SimpleDrillDownQuery ddq = new SimpleDrillDownQuery(config);
+    ddq.add("Author", "Lisa");
     SimpleDrillSidewaysResult r = ds.search(null, ddq, 10);
     assertEquals(2, r.hits.totalHits);
     // Publish Date is only drill-down, and Lisa published
@@ -149,8 +148,8 @@ public class TestSimpleDrillSideways ext
     // drill-down on a single field; in this case the
     // drill-sideways + drill-down counts == drill-down of
     // just the query:
-    ddq = new SimpleDrillDownQuery();
-    ddq.add(new FacetLabel("Author", "Lisa"));
+    ddq = new SimpleDrillDownQuery(config);
+    ddq.add("Author", "Lisa");
     r = ds.search(null, ddq, 10);
 
     assertEquals(2, r.hits.totalHits);
@@ -165,8 +164,9 @@ public class TestSimpleDrillSideways ext
 
     // Another simple case: drill-down on on single fields
     // but OR of two values
-    ddq = new SimpleDrillDownQuery();
-    ddq.add(new FacetLabel("Author", "Lisa"), new FacetLabel("Author", "Bob"));
+    ddq = new SimpleDrillDownQuery(config);
+    ddq.add("Author", "Lisa");
+    ddq.add("Author", "Bob");
     r = ds.search(null, ddq, 10);
     assertEquals(3, r.hits.totalHits);
     // Publish Date is only drill-down: Lisa and Bob
@@ -178,9 +178,9 @@ public class TestSimpleDrillSideways ext
     assertEquals("Author (5)\n  Lisa (2)\n  Bob (1)\n  Susan (1)\n  Frank (1)\n", r.facets.getTopChildren(10, "Author").toString());
 
     // More interesting case: drill-down on two fields
-    ddq = new SimpleDrillDownQuery();
-    ddq.add(new FacetLabel("Author", "Lisa"));
-    ddq.add(new FacetLabel("Publish Date", "2010"));
+    ddq = new SimpleDrillDownQuery(config);
+    ddq.add("Author", "Lisa");
+    ddq.add("Publish Date", "2010");
     r = ds.search(null, ddq, 10);
     assertEquals(1, r.hits.totalHits);
     // Publish Date is drill-sideways + drill-down: Lisa
@@ -192,12 +192,12 @@ public class TestSimpleDrillSideways ext
 
     // Even more interesting case: drill down on two fields,
     // but one of them is OR
-    ddq = new SimpleDrillDownQuery();
+    ddq = new SimpleDrillDownQuery(config);
 
     // Drill down on Lisa or Bob:
-    ddq.add(new FacetLabel("Author", "Lisa"),
-            new FacetLabel("Author", "Bob"));
-    ddq.add(new FacetLabel("Publish Date", "2010"));
+    ddq.add("Author", "Lisa");
+    ddq.add("Publish Date", "2010");
+    ddq.add("Author", "Bob");
     r = ds.search(null, ddq, 10);
     assertEquals(2, r.hits.totalHits);
     // Publish Date is both drill-sideways + drill-down:
@@ -208,17 +208,17 @@ public class TestSimpleDrillSideways ext
     assertEquals("Author (2)\n  Bob (1)\n  Lisa (1)\n", r.facets.getTopChildren(10, "Author").toString());
 
     // Test drilling down on invalid field:
-    ddq = new SimpleDrillDownQuery();
-    ddq.add(new FacetLabel("Foobar", "Baz"));
+    ddq = new SimpleDrillDownQuery(config);
+    ddq.add("Foobar", "Baz");
     r = ds.search(null, ddq, 10);
     assertEquals(0, r.hits.totalHits);
     assertNull(r.facets.getTopChildren(10, "Publish Date"));
     assertNull(r.facets.getTopChildren(10, "Foobar"));
 
     // Test drilling down on valid term or'd with invalid term:
-    ddq = new SimpleDrillDownQuery();
-    ddq.add(new FacetLabel("Author", "Lisa"),
-            new FacetLabel("Author", "Tom"));
+    ddq = new SimpleDrillDownQuery(config);
+    ddq.add("Author", "Lisa");
+    ddq.add("Author", "Tom");
     r = ds.search(null, ddq, 10);
     assertEquals(2, r.hits.totalHits);
     // Publish Date is only drill-down, and Lisa published
@@ -231,9 +231,9 @@ public class TestSimpleDrillSideways ext
 
     // LUCENE-4915: test drilling down on a dimension but
     // NOT facet counting it:
-    ddq = new SimpleDrillDownQuery();
-    ddq.add(new FacetLabel("Author", "Lisa"),
-            new FacetLabel("Author", "Tom"));
+    ddq = new SimpleDrillDownQuery(config);
+    ddq.add("Author", "Lisa");
+    ddq.add("Author", "Tom");
     r = ds.search(null, ddq, 10);
     assertEquals(2, r.hits.totalHits);
     // Publish Date is only drill-down, and Lisa published
@@ -241,8 +241,8 @@ public class TestSimpleDrillSideways ext
     assertEquals("Publish Date (2)\n  2010 (1)\n  2012 (1)\n", r.facets.getTopChildren(10, "Publish Date").toString());
 
     // Test main query gets null scorer:
-    ddq = new SimpleDrillDownQuery(new TermQuery(new Term("foobar", "baz")));
-    ddq.add(new FacetLabel("Author", "Lisa"));
+    ddq = new SimpleDrillDownQuery(config, new TermQuery(new Term("foobar", "baz")));
+    ddq.add("Author", "Lisa");
     r = ds.search(null, ddq, 10);
 
     assertEquals(0, r.hits.totalHits);

Modified: lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/simple/TestSortedSetDocValuesFacets.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/simple/TestSortedSetDocValuesFacets.java?rev=1542804&r1=1542803&r2=1542804&view=diff
==============================================================================
--- lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/simple/TestSortedSetDocValuesFacets.java (original)
+++ lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/simple/TestSortedSetDocValuesFacets.java Sun Nov 17 20:31:07 2013
@@ -27,7 +27,6 @@ import org.apache.lucene.facet.FacetTest
 import org.apache.lucene.facet.search.FacetsCollector;
 import org.apache.lucene.facet.simple.SortedSetDocValuesFacetCounts;
 import org.apache.lucene.facet.simple.SortedSetDocValuesReaderState;
-import org.apache.lucene.facet.taxonomy.FacetLabel;
 import org.apache.lucene.index.DirectoryReader;
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.IndexWriter;
@@ -46,7 +45,8 @@ public class TestSortedSetDocValuesFacet
     assumeTrue("Test requires SortedSetDV support", defaultCodecSupportsSortedSet());
     Directory dir = newDirectory();
 
-    IndexWriter writer = new FacetIndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())), null, new FacetsConfig());
+    FacetsConfig config = new FacetsConfig();
+    IndexWriter writer = new FacetIndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())), null, config);
 
     Document doc = new Document();
     doc.add(new SortedSetDocValuesFacetField("a", "foo"));
@@ -79,9 +79,9 @@ public class TestSortedSetDocValuesFacet
     assertEquals("b (1)\n  baz (1)\n", facets.getTopChildren(10, "b").toString());
 
     // DrillDown:
-    SimpleDrillDownQuery q = new SimpleDrillDownQuery();
-    q.add(new FacetLabel("a", "foo"));
-    q.add(new FacetLabel("b", "baz"));
+    SimpleDrillDownQuery q = new SimpleDrillDownQuery(config);
+    q.add("a", "foo");
+    q.add("b", "baz");
     TopDocs hits = searcher.search(q, 1);
     assertEquals(1, hits.totalHits);
 

Modified: lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/simple/TestTaxonomyFacets.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/simple/TestTaxonomyFacets.java?rev=1542804&r1=1542803&r2=1542804&view=diff
==============================================================================
--- lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/simple/TestTaxonomyFacets.java (original)
+++ lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/simple/TestTaxonomyFacets.java Sun Nov 17 20:31:07 2013
@@ -18,7 +18,6 @@ package org.apache.lucene.facet.simple;
  */
 
 import java.io.ByteArrayOutputStream;
-import java.io.IOException;
 import java.io.PrintStream;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -30,7 +29,6 @@ import org.apache.lucene.analysis.MockAn
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
 import org.apache.lucene.facet.FacetTestCase;
-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;
@@ -60,10 +58,10 @@ public class TestTaxonomyFacets extends 
     // main index:
     DirectoryTaxonomyWriter taxoWriter = new DirectoryTaxonomyWriter(taxoDir, IndexWriterConfig.OpenMode.CREATE);
 
-    FacetsConfig fts = new FacetsConfig();
-    fts.setHierarchical("Publish Date");
+    FacetsConfig config = new FacetsConfig();
+    config.setHierarchical("Publish Date");
 
-    IndexWriter writer = new FacetIndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())), taxoWriter, fts);
+    IndexWriter writer = new FacetIndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())), taxoWriter, config);
 
     Document doc = new Document();
     doc.add(new FacetField("Author", "Bob"));
@@ -107,18 +105,18 @@ public class TestTaxonomyFacets extends 
     // wrap collecting the "normal" hits and also facets:
     searcher.search(new MatchAllDocsQuery(), c);
 
-    Facets facets = new FastTaxonomyFacetCounts(taxoReader, fts, c);
+    Facets facets = new FastTaxonomyFacetCounts(taxoReader, config, c);
 
     // Retrieve & verify results:
     assertEquals("Publish Date (5)\n  2010 (2)\n  2012 (2)\n  1999 (1)\n", facets.getTopChildren(10, "Publish Date").toString());
     assertEquals("Author (5)\n  Lisa (2)\n  Bob (1)\n  Susan (1)\n  Frank (1)\n", facets.getTopChildren(10, "Author").toString());
 
     // Now user drills down on Publish Date/2010:
-    SimpleDrillDownQuery q2 = new SimpleDrillDownQuery(new MatchAllDocsQuery());
-    q2.add(new FacetLabel("Publish Date", "2010"));
+    SimpleDrillDownQuery q2 = new SimpleDrillDownQuery(config);
+    q2.add("Publish Date", "2010");
     c = new SimpleFacetsCollector();
     searcher.search(q2, c);
-    facets = new FastTaxonomyFacetCounts(taxoReader, fts, c);
+    facets = new FastTaxonomyFacetCounts(taxoReader, config, c);
     assertEquals("Author (2)\n  Bob (1)\n  Lisa (1)\n", facets.getTopChildren(10, "Author").toString());
 
     assertEquals(1, facets.getSpecificValue("Author", "Lisa"));