Package org.apache.lucene.facet.example

Examples of org.apache.lucene.facet.example.ExampleResult


*/
public class TestAdaptiveExample extends LuceneTestCase {
 
  @Test
  public void testAdaptive () throws Exception {
    ExampleResult res = new AdaptiveMain().runSample();
    assertNotNull("Null result!", res);
    assertNotNull("Null facet result!", res.getFacetResults());
    assertEquals("Wrong number of results!",1, res.getFacetResults().size());
    assertEquals("Wrong number of facets!",3, res.getFacetResults().get(0).getNumValidDescendants());
  }
View Full Code Here


*/
public class TestSimpleExample extends LuceneTestCase {

  @Test
  public void testSimple () throws Exception {
    ExampleResult res = new SimpleMain().runSimple();
    assertNotNull("Null result!", res);
    assertNotNull("Null facet result!", res.getFacetResults());
    assertEquals("Wrong number of results!",1, res.getFacetResults().size());
    assertEquals("Wrong number of facets!",3, res.getFacetResults().get(0).getNumValidDescendants());
  }
View Full Code Here

   * In drill down test we are drilling down to a facet that appears in a single document.
   * As result, facets that without drill down got count of 2 will now get a count of 1.
   */
  @Test
  public void testDrillDown () throws Exception {
    ExampleResult res = new SimpleMain().runDrillDown();
    assertNotNull("Null result!", res);
    assertNotNull("Null facet result!", res.getFacetResults());
    assertEquals("Wrong number of results!",1, res.getFacetResults().size());
   
    // drill down facet appears in only 1 doc, and that doc has only 2 facets 
    FacetResult facetResult = res.getFacetResults().get(0);
    assertEquals("Wrong number of facets!",2, facetResult.getNumValidDescendants());
   
    Iterator<? extends FacetResultNode> resIterator = facetResult.getFacetResultNode().getSubResults().iterator();
    assertTrue("Too few results", resIterator.hasNext());
    assertEquals("wrong count for first result out of 2", 1, (int)resIterator.next().getValue());
View Full Code Here

*/
public class TestMultiCLExample extends LuceneTestCase {

  @Test
  public void testMulti() throws Exception {
    ExampleResult res = new MultiCLMain().runSample();
    assertCorrectMultiResults(res);
  }
View Full Code Here

    // close readers
    taxo.close();
    indexReader.close();
   
    ExampleResult res = new ExampleResult();
    res.setFacetResults(facetRes);
    return res;
  }
View Full Code Here

   
    // close readers
    taxo.close();
    indexReader.close();
   
    ExampleResult res = new ExampleResult();
    res.setFacetResults(facetRes);
    return res;
  }
View Full Code Here

        this.taxoReader = taxoReader;
        this.iParams = iParams;
      }

      public ExampleResult getResults() {
        ExampleResult exampleRes = new ExampleResult();
        exampleRes.setFacetResults(results);
        return exampleRes;
      }

      @Override
      public void run() {
        try {
          results = MultiCLSearcher.searchWithFacets(indexReader, taxoReader, iParams);
        } catch (Exception e) {
          throw new RuntimeException(e);
        }
      }
    }

    // Instantiate threads, but do not start them
    Multi[] multis = new Multi[numThreads];
    for (int i = 0; i < numThreads - 1; i++) {
      multis[i] = new Multi(slowIndexReader, slowTaxoReader, MultiCLIndexer.MULTI_IPARAMS);
    }
    // The last thread uses ONLY the DefaultFacetIndexingParams so that
    // 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());

    // Gentleman, start your engines
    for (Multi m : multis) {
      m.start();
    }

    // Wait for threads and get results
    ExampleResult[] multiResults = new ExampleResult[numThreads];
    for (int i = 0; i < numThreads; i++) {
      multis[i].join();
      multiResults[i] = multis[i].getResults();
    }

    // Each of the (numThreads-1) should have the same predictable
    // results, which we test for here.
    for (int i = 0; i < numThreads - 1; i++) {
      ExampleResult eResults = multiResults[i];
      TestMultiCLExample.assertCorrectMultiResults(eResults);
    }

    // The last thread, which only searched over the
    // DefaultFacetIndexingParams,
    // has its own results
    ExampleResult eResults = multiResults[numThreads - 1];
    List<FacetResult> results = eResults.getFacetResults();
    assertEquals(3, results.size());
    String[] expLabels = new String[] { "5", "5/5", "6/2" };
    double[] expValues = new double[] { 0.0, 0.0, 1.0 };
    for (int i = 0; i < 3; i++) {
      FacetResult result = results.get(i);
View Full Code Here

        this.taxoReader = taxoReader;
        this.iParams = iParams;
      }

      public ExampleResult getResults() {
        ExampleResult exampleRes = new ExampleResult();
        exampleRes.setFacetResults(results);
        return exampleRes;
      }
View Full Code Here

    // close readers
    taxo.close();
    indexReader.close();
   
    ExampleResult res = new ExampleResult();
    res.setFacetResults(facetRes);
    return res;
  }
View Full Code Here

   
    // close readers
    taxo.close();
    indexReader.close();
   
    ExampleResult res = new ExampleResult();
    res.setFacetResults(facetRes);
    return res;
  }
View Full Code Here

TOP

Related Classes of org.apache.lucene.facet.example.ExampleResult

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.