lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sh...@apache.org
Subject svn commit: r1417364 - in /lucene/dev/branches/branch_4x: ./ lucene/ lucene/facet/ lucene/facet/src/java/org/apache/lucene/facet/search/ lucene/facet/src/java/org/apache/lucene/facet/search/params/ lucene/facet/src/test/org/apache/lucene/facet/ lucene/...
Date Wed, 05 Dec 2012 11:32:14 GMT
Author: shaie
Date: Wed Dec  5 11:32:13 2012
New Revision: 1417364

URL: http://svn.apache.org/viewvc?rev=1417364&view=rev
Log:
LUCENE-4586: Change default ResultMode of FacetRequest to PER_NODE_IN_TREE

Modified:
    lucene/dev/branches/branch_4x/   (props changed)
    lucene/dev/branches/branch_4x/lucene/   (props changed)
    lucene/dev/branches/branch_4x/lucene/CHANGES.txt   (contents, props changed)
    lucene/dev/branches/branch_4x/lucene/facet/   (props changed)
    lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/TopKInEachNodeHandler.java
    lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/params/FacetRequest.java
    lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/FacetTestBase.java
    lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/BaseTestTopK.java
    lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestMultipleCategoryLists.java
    lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestTopKResultsHandler.java
    lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/sampling/BaseSampleTestTopK.java

Modified: lucene/dev/branches/branch_4x/lucene/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/CHANGES.txt?rev=1417364&r1=1417363&r2=1417364&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/CHANGES.txt (original)
+++ lucene/dev/branches/branch_4x/lucene/CHANGES.txt Wed Dec  5 11:32:13 2012
@@ -186,6 +186,13 @@ Bug Fixes
 * LUCENE-4009: Improve TermsFilter.toString (Tim Costermans via Chris
   Male, Mike McCandless)
 
+Changes in Runtime Behavior
+  
+* LUCENE-4586: Change default ResultMode of FacetRequest to PER_NODE_IN_TREE.
+  This only affects requests with depth>1. If you execute such requests and
+  rely on the facet results being returned flat (i.e. no hierarchy), you should
+  set the ResultMode to GLOBAL_FLAT. (Shai Erera, Gilad Barkai) 
+
 Optimizations
 
 * LUCENE-2221: oal.util.BitUtil was modified to use Long.bitCount and

Modified: lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/TopKInEachNodeHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/TopKInEachNodeHandler.java?rev=1417364&r1=1417363&r2=1417364&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/TopKInEachNodeHandler.java
(original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/TopKInEachNodeHandler.java
Wed Dec  5 11:32:13 2012
@@ -592,7 +592,7 @@ public class TopKInEachNodeHandler exten
     
     @Override
     protected boolean leftGoesNow (int ord1, double val1, int ord2, double val2) {
-      return (val1 < val2);
+      return (val1 == val2) ? (ord1 < ord2) : (val1 < val2);
     }
   }
 
@@ -602,7 +602,7 @@ public class TopKInEachNodeHandler exten
     
     @Override
     protected boolean leftGoesNow (int ord1, double val1, int ord2, double val2) {
-      return (val1 > val2);
+      return (val1 == val2) ? (ord1 > ord2) : (val1 > val2);
     }
   }
 
@@ -656,6 +656,7 @@ public class TopKInEachNodeHandler exten
       this.totalNumOfFacetsConsidered = 0;
     }
 
+    @Override
     public FacetRequest getFacetRequest() {
       return this.facetRequest;
     }

Modified: lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/params/FacetRequest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/params/FacetRequest.java?rev=1417364&r1=1417363&r2=1417364&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/params/FacetRequest.java
(original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/params/FacetRequest.java
Wed Dec  5 11:32:13 2012
@@ -64,7 +64,7 @@ public abstract class FacetRequest imple
    * Default result mode
    * @see #getResultMode()
    */
-  public static final ResultMode DEFAULT_RESULT_MODE = ResultMode.GLOBAL_FLAT;
+  public static final ResultMode DEFAULT_RESULT_MODE = ResultMode.PER_NODE_IN_TREE;
 
   private final CategoryPath categoryPath;
   private final int numResults;

Modified: lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/FacetTestBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/FacetTestBase.java?rev=1417364&r1=1417363&r2=1417364&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/FacetTestBase.java
(original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/FacetTestBase.java
Wed Dec  5 11:32:13 2012
@@ -328,7 +328,7 @@ public abstract class FacetTestBase exte
     if (!expectedResults.equals(actualResults)) {
       System.err.println("Results are not the same!");
       System.err.println("Expected:\n" + expectedResults);
-      System.err.println("Actual" + actualResults);
+      System.err.println("Actual:\n" + actualResults);
       throw new NotSameResultError();
     }
   }

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=1417364&r1=1417363&r2=1417364&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
Wed Dec  5 11:32:13 2012
@@ -61,6 +61,10 @@ public abstract class BaseTestTopK exten
       return;
     }
     currDoc = doc;
+    // the code below tries to achieve non-uniform distribution of
+    // categories. Perhaps we can use random.nextGaussian() instead,
+    // something like nextGaussian() * stdev + maxCategory/2. Or
+    // try to generate a Zipf distribution.
     nextInt = random().nextInt(categoriesPow2);
     nextInt = (int)Math.sqrt(nextInt);
   }

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=1417364&r1=1417363&r2=1417364&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
Wed Dec  5 11:32:13 2012
@@ -12,6 +12,7 @@ import org.apache.lucene.facet.index.par
 import org.apache.lucene.facet.index.params.PerDimensionIndexingParams;
 import org.apache.lucene.facet.search.params.CountFacetRequest;
 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;
 import org.apache.lucene.facet.search.results.FacetResultNode;
 import org.apache.lucene.facet.taxonomy.CategoryPath;
@@ -122,8 +123,7 @@ public class TestMultipleCategoryLists e
     // prepare searcher to search against
     IndexSearcher searcher = newSearcher(ir);
 
-    FacetsCollector facetsCollector = performSearch(iParams, tr, ir,
-        searcher);
+    FacetsCollector facetsCollector = performSearch(iParams, tr, ir, searcher);
 
     // Obtain facets results and hand-test them
     assertCorrectResults(facetsCollector);
@@ -335,16 +335,14 @@ public class TestMultipleCategoryLists e
     // Faceted search parameters indicate which facets are we interested in
     FacetSearchParams facetSearchParams = new FacetSearchParams(iParams);
 
-    facetSearchParams.addFacetRequest(new CountFacetRequest(
-        new CategoryPath("Band"), 10));
-    CountFacetRequest bandDepth = new CountFacetRequest(new CategoryPath(
-    "Band"), 10);
+    facetSearchParams.addFacetRequest(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));
+    facetSearchParams.addFacetRequest(new CountFacetRequest(new CategoryPath("Author"), 10));
+    facetSearchParams.addFacetRequest(new CountFacetRequest(new CategoryPath("Band", "Rock
& Pop"), 10));
 
     // 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/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=1417364&r1=1417363&r2=1417364&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
Wed Dec  5 11:32:13 2012
@@ -9,6 +9,7 @@ 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.ResultMode;
 import org.apache.lucene.facet.search.results.FacetResult;
 import org.apache.lucene.facet.search.results.FacetResultNode;
 import org.apache.lucene.facet.taxonomy.CategoryPath;
@@ -65,7 +66,7 @@ public class TestTopKResultsHandler exte
   }
   
   /**
-   * Strait forward test: Adding specific documents with specific facets and
+   * Straightforward test: Adding specific documents with specific facets and
    * counting them in the most basic form.
    */
   @Test
@@ -79,6 +80,8 @@ public class TestTopKResultsHandler exte
       sParams.addFacetRequest(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));

Modified: lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/sampling/BaseSampleTestTopK.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/sampling/BaseSampleTestTopK.java?rev=1417364&r1=1417363&r2=1417364&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/sampling/BaseSampleTestTopK.java
(original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/sampling/BaseSampleTestTopK.java
Wed Dec  5 11:32:13 2012
@@ -14,6 +14,8 @@ import org.apache.lucene.facet.search.Fa
 import org.apache.lucene.facet.search.FacetsCollector;
 import org.apache.lucene.facet.search.ScoredDocIDs;
 import org.apache.lucene.facet.search.ScoredDocIdCollector;
+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.taxonomy.TaxonomyReader;
@@ -43,6 +45,20 @@ public abstract class BaseSampleTestTopK
   /** since there is a chance that this test would fail even if the code is correct, retry
the sampling */
   protected static final int RETRIES = 10;
   
+  @Override
+  protected FacetSearchParams searchParamsWithRequests(int numResults, int partitionSize)
{
+    FacetSearchParams res = super.searchParamsWithRequests(numResults, partitionSize);
+    for (FacetRequest req : res.getFacetRequests()) {
+      // randomize the way we aggregate results
+      if (random().nextBoolean()) {
+        req.setResultMode(ResultMode.GLOBAL_FLAT);
+      } else {
+        req.setResultMode(ResultMode.PER_NODE_IN_TREE);
+      }
+    }
+    return res;
+  }
+  
   protected abstract FacetsAccumulator getSamplingAccumulator(Sampler sampler,
       TaxonomyReader taxoReader, IndexReader indexReader,
       FacetSearchParams searchParams);



Mime
View raw message