Return-Path: X-Original-To: apmail-lucene-commits-archive@www.apache.org Delivered-To: apmail-lucene-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8604A102E2 for ; Tue, 19 Nov 2013 17:13:50 +0000 (UTC) Received: (qmail 10204 invoked by uid 500); 19 Nov 2013 17:13:43 -0000 Mailing-List: contact commits-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@lucene.apache.org Delivered-To: mailing list commits@lucene.apache.org Received: (qmail 10147 invoked by uid 99); 19 Nov 2013 17:13:40 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 19 Nov 2013 17:13:40 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 19 Nov 2013 17:13:36 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id CD93D23888E7; Tue, 19 Nov 2013 17:13:14 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1543506 - in /lucene/dev/branches/lucene5339/lucene/facet/src: java/org/apache/lucene/facet/simple/ test/org/apache/lucene/facet/ test/org/apache/lucene/facet/simple/ Date: Tue, 19 Nov 2013 17:13:14 -0000 To: commits@lucene.apache.org From: mikemccand@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20131119171314.CD93D23888E7@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: mikemccand Date: Tue Nov 19 17:13:14 2013 New Revision: 1543506 URL: http://svn.apache.org/r1543506 Log: LUCENE-5339: migrate some more tests; fix 'ignores IntsRef.offset bug' in TaxoFacetCounts; add FacetTestCase.getFacetCounts Modified: lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/FacetIndexWriter.java lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/TaxonomyFacetCounts.java lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/TaxonomyFacetSumValueSource.java lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/FacetTestCase.java lucene/dev/branches/lucene5339/lucene/facet/src/test/org/apache/lucene/facet/simple/TestTaxonomyFacetCounts.java Modified: lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/FacetIndexWriter.java URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/FacetIndexWriter.java?rev=1543506&r1=1543505&r2=1543506&view=diff ============================================================================== --- lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/FacetIndexWriter.java (original) +++ lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/FacetIndexWriter.java Tue Nov 19 17:13:14 2013 @@ -248,6 +248,7 @@ public class FacetIndexWriter extends In } } + // nocommit open this up /** We can open this up if/when we really need * pluggability on the encoding. */ private final BytesRef dedupAndEncode(IntsRef ordinals) { Modified: lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/TaxonomyFacetCounts.java URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/TaxonomyFacetCounts.java?rev=1543506&r1=1543505&r2=1543506&view=diff ============================================================================== --- lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/TaxonomyFacetCounts.java (original) +++ lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/TaxonomyFacetCounts.java Tue Nov 19 17:13:14 2013 @@ -60,7 +60,7 @@ public class TaxonomyFacetCounts extends while (doc < length && (doc = bits.nextSetBit(doc)) != -1) { ords.get(doc, scratch); for(int i=0;i results = facets.getAllDims(10); @@ -275,7 +266,6 @@ public class TestTaxonomyFacetCounts ext // nocommit in the sparse case test that we are really // sorting by the correct dim count - /* public void testReallyNoNormsForDrillDown() throws Exception { Directory dir = newDirectory(); Directory taxoDir = newDirectory(); @@ -289,13 +279,12 @@ public class TestTaxonomyFacetCounts ext return sim; } }); - RandomIndexWriter writer = new RandomIndexWriter(random(), dir, iwc); TaxonomyWriter taxoWriter = new DirectoryTaxonomyWriter(taxoDir, IndexWriterConfig.OpenMode.CREATE); - FacetFields facetFields = new FacetFields(taxoWriter); + IndexWriter writer = new FacetIndexWriter(dir, iwc, taxoWriter, new FacetsConfig()); Document doc = new Document(); doc.add(newTextField("field", "text", Field.Store.NO)); - facetFields.addFields(doc, Collections.singletonList(new CategoryPath("a/path", '/'))); + doc.add(new FacetField("a", "path")); writer.addDocument(doc); writer.close(); taxoWriter.close(); @@ -303,54 +292,42 @@ public class TestTaxonomyFacetCounts ext taxoDir.close(); } - public void testAllParents() throws Exception { + public void testMultiValuedHierarchy() throws Exception { Directory dir = newDirectory(); Directory taxoDir = newDirectory(); - RandomIndexWriter writer = new RandomIndexWriter(random(), dir); DirectoryTaxonomyWriter taxoWriter = new DirectoryTaxonomyWriter(taxoDir, IndexWriterConfig.OpenMode.CREATE); - - CategoryListParams clp = new CategoryListParams("$facets") { - @Override - public OrdinalPolicy getOrdinalPolicy(String fieldName) { - return OrdinalPolicy.ALL_PARENTS; - } - }; - FacetIndexingParams fip = new FacetIndexingParams(clp); - - FacetFields facetFields = new FacetFields(taxoWriter, fip); + IndexWriterConfig iwc = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())); + FacetsConfig config = new FacetsConfig(); + config.setHierarchical("a"); + config.setMultiValued("a"); + IndexWriter writer = new FacetIndexWriter(dir, iwc, taxoWriter, config); Document doc = new Document(); doc.add(newTextField("field", "text", Field.Store.NO)); - facetFields.addFields(doc, Collections.singletonList(new CategoryPath("a/path", '/'))); + doc.add(new FacetField("a", "path", "x")); + doc.add(new FacetField("a", "path", "y")); writer.addDocument(doc); // NRT open - IndexSearcher searcher = newSearcher(writer.getReader()); + IndexSearcher searcher = newSearcher(DirectoryReader.open(writer, true)); writer.close(); // NRT open TaxonomyReader taxoReader = new DirectoryTaxonomyReader(taxoWriter); taxoWriter.close(); - FacetSearchParams fsp = new FacetSearchParams(fip, - new CountFacetRequest(new CategoryPath("a", '/'), 10)); - // Aggregate the facet counts: - FacetsCollector c = FacetsCollector.create(fsp, searcher.getIndexReader(), taxoReader); + SimpleFacetsCollector c = new SimpleFacetsCollector(); // MatchAllDocsQuery is for "browsing" (counts facets // for all non-deleted docs in the index); normally // you'd use a "normal" query, and use MultiCollector to // wrap collecting the "normal" hits and also facets: searcher.search(new MatchAllDocsQuery(), c); - List results = c.getFacetResults(); - assertEquals(1, results.size()); - assertEquals(1, (int) results.get(0).getFacetResultNode().value); - - // LUCENE-4913: - for(FacetResultNode childNode : results.get(0).getFacetResultNode().subResults) { - assertTrue(childNode.ordinal != 0); - } + Facets facets = getFacetCounts(taxoReader, config, c); + SimpleFacetResult result = facets.getTopChildren(10, "a"); + assertEquals(1, result.labelValues.length); + assertEquals(1, result.labelValues[0].value.intValue()); searcher.getIndexReader().close(); taxoReader.close(); @@ -358,6 +335,7 @@ public class TestTaxonomyFacetCounts ext taxoDir.close(); } + /* public void testLabelWithDelimiter() throws Exception { Directory dir = newDirectory(); Directory taxoDir = newDirectory();