Package org.apache.lucene.facet.search

Examples of org.apache.lucene.facet.search.ScoredDocIdCollector$ScoringDocIdCollector


      }

      assertEquals("Wrong number of (live) documents", allDocs.size(), numIteratedDocs);

      // Get all 'alpha' documents
      ScoredDocIdCollector collector = ScoredDocIdCollector.create(reader.maxDoc(), false);
      Query q = new TermQuery(new Term(DocumentFactory.field, DocumentFactory.alphaTxt));
      IndexSearcher searcher = newSearcher(reader);
      searcher.search(q, collector);
      searcher.close();

      ScoredDocIDs scoredDocIds = collector.getScoredDocIDs();
      OpenBitSet resultSet = new OpenBitSetDISI(scoredDocIds.getDocIDs().iterator(), reader.maxDoc());
     
      // Getting the complement set of the query result
      ScoredDocIDs complementSet = ScoredDocIdsUtils.getComplementSet(scoredDocIds, reader);
View Full Code Here


    Query q = new TermQuery(new Term(CONTENT_FIELD, "white"));
    if (VERBOSE) {
      System.out.println("Query: " + q);
    }
    float constScore = 17.0f;
    ScoredDocIdCollector dCollector = ScoredDocIdCollector.create(indexReader
        .maxDoc(), false); // scoring is disabled
    dCollector.setDefaultScore(constScore);
    searcher.search(q, dCollector);

    // verify by doc scores at the level of doc-id-iterator
    ScoredDocIDs scoredDocIDs = dCollector.getScoredDocIDs();
    assertEquals("Wrong number of matching documents!", 2, scoredDocIDs.size());
    ScoredDocIDsIterator docItr = scoredDocIDs.iterator();
    while (docItr.next()) {
      assertEquals("Wrong score for doc " + docItr.getDocID(), constScore,
          docItr.getScore(), Double.MIN_VALUE);
View Full Code Here

  public void testOutOfOrderCollectionScoringDisabled() throws Exception {
    // This used to fail, because ScoredDocIdCollector.acceptDocsOutOfOrder
    // returned true, even when scoring was enabled.
    final int[] docs = new int[] { 1, 0, 2 }; // out of order on purpose

    ScoredDocIdCollector sdic = ScoredDocIdCollector.create(docs.length, false);
    assertTrue(
        "when scoring disabled, out-of-order collection should be supported",
        sdic.acceptsDocsOutOfOrder());
    for (int i = 0; i < docs.length; i++) {
      sdic.collect(docs[i]);
    }

    assertEquals("expected 3 documents but got " + sdic.getScoredDocIDs().size(), 3, sdic.getScoredDocIDs().size());
    ScoredDocIDsIterator iter = sdic.getScoredDocIDs().iterator();
    Arrays.sort(docs);
    for (int i = 0; iter.next(); i++) {
      assertEquals("expected doc " + docs[i], docs[i], iter.getDocID());
    }
  }
View Full Code Here

      LuceneTaxonomyReader tr = new LuceneTaxonomyReader(tDir);

      // Get all of the documents and run the query, then do different
      // facet counts and compare to control
      Query q = new TermQuery(new Term("content", "alpha"));
      ScoredDocIdCollector scoredDoc = ScoredDocIdCollector.create(is.maxDoc(), true);

      // Collector collector = new MultiCollector(scoredDoc);
      is.search(q, scoredDoc);

      CountFacetRequest cfra23 = new CountFacetRequest(
          new CategoryPath("a"), 2);
      cfra23.setDepth(3);
      cfra23.setResultMode(ResultMode.PER_NODE_IN_TREE);

      CountFacetRequest cfra22 = new CountFacetRequest(
          new CategoryPath("a"), 2);
      cfra22.setDepth(2);
      cfra22.setResultMode(ResultMode.PER_NODE_IN_TREE);

      CountFacetRequest cfra21 = new CountFacetRequest(
          new CategoryPath("a"), 2);
      cfra21.setDepth(1);
      cfra21.setResultMode(ResultMode.PER_NODE_IN_TREE);

      CountFacetRequest cfrb22 = new CountFacetRequest(
          new CategoryPath("a", "b"), 2);
      cfrb22.setDepth(2);
      cfrb22.setResultMode(ResultMode.PER_NODE_IN_TREE);

      CountFacetRequest cfrb23 = new CountFacetRequest(
          new CategoryPath("a", "b"), 2);
      cfrb23.setDepth(3);
      cfrb23.setResultMode(ResultMode.PER_NODE_IN_TREE);

      CountFacetRequest cfrb21 = new CountFacetRequest(
          new CategoryPath("a", "b"), 2);
      cfrb21.setDepth(1);
      cfrb21.setResultMode(ResultMode.PER_NODE_IN_TREE);

      CountFacetRequest doctor = new CountFacetRequest(
          new CategoryPath("Doctor"), 2);
      doctor.setDepth(1);
      doctor.setResultMode(ResultMode.PER_NODE_IN_TREE);

      CountFacetRequest cfrb20 = new CountFacetRequest(
          new CategoryPath("a", "b"), 2);
      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);
     
      IntArrayAllocator iaa = new IntArrayAllocator(PartitionsUtils.partitionSize(facetSearchParams,tr), 1);
      FloatArrayAllocator faa = new FloatArrayAllocator(PartitionsUtils.partitionSize(facetSearchParams,tr), 1);
      FacetsAccumulator fctExtrctr = new StandardFacetsAccumulator(facetSearchParams, is.getIndexReader(), tr, iaa, faa);
      fctExtrctr.setComplementThreshold(FacetsAccumulator.DISABLE_COMPLEMENT);
      long start = System.currentTimeMillis();

      List<FacetResult> facetResults = fctExtrctr.accumulate(scoredDoc.getScoredDocIDs());

      long end = System.currentTimeMillis();
      if (VERBOSE) {
        System.out.println("Time: " + (end - start));
      }
View Full Code Here

      initIndex(partitionSize);
     
      // Get all of the documents and run the query, then do different
      // facet counts and compare to control
      Query q = new TermQuery(new Term(CONTENT_FIELD, BETA)); // 90% of the docs
      ScoredDocIdCollector docCollector = ScoredDocIdCollector.create(searcher.maxDoc(), false);
     
      FacetSearchParams expectedSearchParams = searchParamsWithRequests(K, partitionSize);
      FacetsCollector fc = new FacetsCollector(expectedSearchParams, indexReader, taxoReader);
     
      searcher.search(q, MultiCollector.wrap(docCollector, fc));
     
      List<FacetResult> expectedResults = fc.getFacetResults();
     
      // complement with sampling!
      final Sampler sampler = createSampler(docCollector.getScoredDocIDs());
     
      FacetSearchParams samplingSearchParams = searchParamsWithRequests(K, partitionSize);

      assertSampling(expectedResults, q, sampler, samplingSearchParams, false);
      assertSampling(expectedResults, q, sampler, samplingSearchParams, true);
View Full Code Here

   
    // regular collector for scoring matched documents
    TopScoreDocCollector topDocsCollector = TopScoreDocCollector.create(10, true);
   
    // docids collector for guiding facets accumulation (scoring disabled)
    ScoredDocIdCollector docIdsCollecor = ScoredDocIdCollector.create(indexReader.maxDoc(), false);
   
    // Faceted search parameters indicate which facets are we interested in
    FacetSearchParams facetSearchParams = new FacetSearchParams();
    facetSearchParams.addFacetRequest(new CountFacetRequest(new CategoryPath("root","a"), 10));
   
    // search, into both collectors. note: in case only facets accumulation
    // is required, the topDocCollector part can be totally discarded
    searcher.search(q, MultiCollector.wrap(topDocsCollector, docIdsCollecor));
       
    // Obtain facets results and print them
    AdaptiveFacetsAccumulator accumulator = new AdaptiveFacetsAccumulator(facetSearchParams, indexReader, taxo);
    List<FacetResult> res = accumulator.accumulate(docIdsCollecor.getScoredDocIDs());
   
    int i = 0;
    for (FacetResult facetResult : res) {
      ExampleUtils.log("Res "+(i++)+": "+facetResult);
    }
View Full Code Here

  private void doTestComplements() throws Exception {
    Query q = new MatchAllDocsQuery(); //new TermQuery(new Term(TEXT,"white"));
    if (VERBOSE) {
      System.out.println("Query: "+q);
    }
    ScoredDocIdCollector dCollector =
      ScoredDocIdCollector.create(indexReader.maxDoc(),false); // scoring is disabled
    searcher.search(q, dCollector);
   
    // verify by facet values
    List<FacetResult> countResWithComplement = findFacets(dCollector.getScoredDocIDs(), true);
    List<FacetResult> countResNoComplement = findFacets(dCollector.getScoredDocIDs(), false);
   
    assertEquals("Wrong number of facet count results with complement!",1,countResWithComplement.size());
    assertEquals("Wrong number of facet count results no complement!",1,countResNoComplement.size());
   
    FacetResultNode parentResWithComp = countResWithComplement.get(0).getFacetResultNode();
View Full Code Here

   
    // regular collector for scoring matched documents
    TopScoreDocCollector topDocsCollector = TopScoreDocCollector.create(10, true);
   
    // docids collector for guiding facets accumulation (scoring disabled)
    ScoredDocIdCollector docIdsCollecor = ScoredDocIdCollector.create(indexReader.maxDoc(), false);
   
    // Faceted search parameters indicate which facets are we interested in
    FacetSearchParams facetSearchParams = new FacetSearchParams();
    facetSearchParams.addFacetRequest(new CountFacetRequest(new CategoryPath("root","a"), 10));
   
    // search, into both collectors. note: in case only facets accumulation
    // is required, the topDocCollector part can be totally discarded
    searcher.search(q, MultiCollector.wrap(topDocsCollector, docIdsCollecor));
       
    // Obtain facets results and print them
    AdaptiveFacetsAccumulator accumulator = new AdaptiveFacetsAccumulator(facetSearchParams, indexReader, taxo);
    List<FacetResult> res = accumulator.accumulate(docIdsCollecor.getScoredDocIDs());
   
    int i = 0;
    for (FacetResult facetResult : res) {
      ExampleUtils.log("Res "+(i++)+": "+facetResult);
    }
View Full Code Here

   
    // regular collector for scoring matched documents
    TopScoreDocCollector topDocsCollector = TopScoreDocCollector.create(10, true);
   
    // docids collector for guiding facets accumulation (scoring disabled)
    ScoredDocIdCollector docIdsCollecor = ScoredDocIdCollector.create(indexReader.maxDoc(), false);
   
    // Faceted search parameters indicate which facets are we interested in
    FacetSearchParams facetSearchParams = new FacetSearchParams();
    facetSearchParams.addFacetRequest(new CountFacetRequest(new CategoryPath("root","a"), 10));
   
    // search, into both collectors. note: in case only facets accumulation
    // is required, the topDocCollector part can be totally discarded
    searcher.search(q, MultiCollector.wrap(topDocsCollector, docIdsCollecor));
       
    // Obtain facets results and print them
    AdaptiveFacetsAccumulator accumulator = new AdaptiveFacetsAccumulator(facetSearchParams, indexReader, taxo);
    List<FacetResult> res = accumulator.accumulate(docIdsCollecor.getScoredDocIDs());
   
    int i = 0;
    for (FacetResult facetResult : res) {
      ExampleUtils.log("Res "+(i++)+": "+facetResult);
    }
View Full Code Here

      DirectoryTaxonomyReader tr = new DirectoryTaxonomyReader(tDir);

      // Get all of the documents and run the query, then do different
      // facet counts and compare to control
      Query q = new TermQuery(new Term("content", "alpha"));
      ScoredDocIdCollector scoredDoc = ScoredDocIdCollector.create(is.maxDoc(), true);

      // Collector collector = new MultiCollector(scoredDoc);
      is.search(q, scoredDoc);

      CountFacetRequest cfra23 = new CountFacetRequest(
          new CategoryPath("a"), 2);
      cfra23.setDepth(3);
      cfra23.setResultMode(ResultMode.PER_NODE_IN_TREE);

      CountFacetRequest cfra22 = new CountFacetRequest(
          new CategoryPath("a"), 2);
      cfra22.setDepth(2);
      cfra22.setResultMode(ResultMode.PER_NODE_IN_TREE);

      CountFacetRequest cfra21 = new CountFacetRequest(
          new CategoryPath("a"), 2);
      cfra21.setDepth(1);
      cfra21.setResultMode(ResultMode.PER_NODE_IN_TREE);

      CountFacetRequest cfrb22 = new CountFacetRequest(
          new CategoryPath("a", "b"), 2);
      cfrb22.setDepth(2);
      cfrb22.setResultMode(ResultMode.PER_NODE_IN_TREE);

      CountFacetRequest cfrb23 = new CountFacetRequest(
          new CategoryPath("a", "b"), 2);
      cfrb23.setDepth(3);
      cfrb23.setResultMode(ResultMode.PER_NODE_IN_TREE);

      CountFacetRequest cfrb21 = new CountFacetRequest(
          new CategoryPath("a", "b"), 2);
      cfrb21.setDepth(1);
      cfrb21.setResultMode(ResultMode.PER_NODE_IN_TREE);

      CountFacetRequest doctor = new CountFacetRequest(
          new CategoryPath("Doctor"), 2);
      doctor.setDepth(1);
      doctor.setResultMode(ResultMode.PER_NODE_IN_TREE);

      CountFacetRequest cfrb20 = new CountFacetRequest(
          new CategoryPath("a", "b"), 2);
      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);
     
      IntArrayAllocator iaa = new IntArrayAllocator(PartitionsUtils.partitionSize(facetSearchParams,tr), 1);
      FloatArrayAllocator faa = new FloatArrayAllocator(PartitionsUtils.partitionSize(facetSearchParams,tr), 1);
      FacetsAccumulator fctExtrctr = new StandardFacetsAccumulator(facetSearchParams, is.getIndexReader(), tr, iaa, faa);
      fctExtrctr.setComplementThreshold(FacetsAccumulator.DISABLE_COMPLEMENT);
      long start = System.currentTimeMillis();

      List<FacetResult> facetResults = fctExtrctr.accumulate(scoredDoc.getScoredDocIDs());

      long end = System.currentTimeMillis();
      if (VERBOSE) {
        System.out.println("Time: " + (end - start));
      }
View Full Code Here

TOP

Related Classes of org.apache.lucene.facet.search.ScoredDocIdCollector$ScoringDocIdCollector

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.