Package org.apache.lucene.search

Examples of org.apache.lucene.search.MatchAllDocsQuery


          }
        }
      }

      FacetsCollector fc = FacetsCollector.create(new RangeAccumulator(new RangeFacetRequest<FloatRange>("field", ranges)));
      s.search(new MatchAllDocsQuery(), fc);
      List<FacetResult> results = fc.getFacetResults();
      assertEquals(1, results.size());
      List<FacetResultNode> nodes = results.get(0).getFacetResultNode().subResults;
      assertEquals(numRange, nodes.size());
      for(int rangeID=0;rangeID<numRange;rangeID++) {
View Full Code Here


          }
        }
      }

      FacetsCollector fc = FacetsCollector.create(new RangeAccumulator(new RangeFacetRequest<DoubleRange>("field", ranges)));
      s.search(new MatchAllDocsQuery(), fc);
      List<FacetResult> results = fc.getFacetResults();
      assertEquals(1, results.size());
      List<FacetResultNode> nodes = results.get(0).getFacetResultNode().subResults;
      assertEquals(numRange, nodes.size());
      for(int rangeID=0;rangeID<numRange;rangeID++) {
View Full Code Here

        new LongRange("over 1000", 1000L, false, Long.MAX_VALUE, false)));
   
    FacetsCollector fc = FacetsCollector.create(a);

    IndexSearcher s = newSearcher(r);
    s.search(new MatchAllDocsQuery(), fc);
    List<FacetResult> result = fc.getFacetResults();
    assertEquals(1, result.size());
    assertEquals("field (0)\n  less than 10 (8)\n  less than or equal to 10 (8)\n  over 90 (8)\n  90 or above (8)\n  over 1000 (0)\n", FacetTestUtils.toSimpleString(result.get(0)));
   
    r.close();
View Full Code Here

  private List<FacetResult> findFacets(boolean withComplement) throws IOException {
    FacetSearchParams fsp = new FacetSearchParams(fip, new CountFacetRequest(new CategoryPath("root","a"), 10));
    OldFacetsAccumulator sfa = new OldFacetsAccumulator(fsp, indexReader, taxoReader);
    sfa.setComplementThreshold(withComplement ? OldFacetsAccumulator.FORCE_COMPLEMENT : OldFacetsAccumulator.DISABLE_COMPLEMENT);
    FacetsCollector fc = FacetsCollector.create(sfa);
    searcher.search(new MatchAllDocsQuery(), fc);
   
    List<FacetResult> res = fc.getFacetResults();
   
    // Results are ready, printing them...
    int i = 0;
View Full Code Here

    // facet requests for two facets
    FacetSearchParams fsp = new FacetSearchParams(
        new SumIntAssociationFacetRequest(aint, 10),
        new SumIntAssociationFacetRequest(bint, 10));
   
    Query q = new MatchAllDocsQuery();
   
    FacetsCollector fc = FacetsCollector.create(fsp, reader, taxo);
   
    IndexSearcher searcher = newSearcher(reader);
    searcher.search(q, fc);
View Full Code Here

    // facet requests for two facets
    FacetSearchParams fsp = new FacetSearchParams(
        new SumFloatAssociationFacetRequest(afloat, 10),
        new SumFloatAssociationFacetRequest(bfloat, 10));
   
    Query q = new MatchAllDocsQuery();
   
    FacetsCollector fc = FacetsCollector.create(fsp, reader, taxo);
   
    IndexSearcher searcher = newSearcher(reader);
    searcher.search(q, fc);
View Full Code Here

        new SumIntAssociationFacetRequest(aint, 10),
        new SumIntAssociationFacetRequest(bint, 10),
        new SumFloatAssociationFacetRequest(afloat, 10),
        new SumFloatAssociationFacetRequest(bfloat, 10));
   
    Query q = new MatchAllDocsQuery();
   
    FacetsCollector fc = FacetsCollector.create(fsp, reader, taxo);
   
    IndexSearcher searcher = newSearcher(reader);
    searcher.search(q, fc);
View Full Code Here

    DirectoryReader reader1 = DirectoryReader.open(dir);
    DirectoryTaxonomyReader taxReader = new DirectoryTaxonomyReader(taxDir);
    IndexSearcher searcher = newSearcher(reader1);
    FacetSearchParams fsp = new FacetSearchParams(fip, new CountFacetRequest(new CategoryPath("tag"), NUM_DOCS));
    FacetsCollector collector = FacetsCollector.create(fsp, reader1, taxReader);
    searcher.search(new MatchAllDocsQuery(), collector);
    FacetResult result = collector.getFacetResults().get(0);
    FacetResultNode node = result.getFacetResultNode();
    for (FacetResultNode facet: node.subResults) {
      int weight = (int)facet.value;
      int label = Integer.parseInt(facet.label.components[1]);
View Full Code Here

        // verify faceted search
        int id = Integer.parseInt(indexReader.getIndexCommit().getUserData().get(VERSION_ID), 16);
        CategoryPath cp = new CategoryPath("A", Integer.toString(id, 16));
        IndexSearcher searcher = new IndexSearcher(indexReader);
        FacetsCollector fc = FacetsCollector.create(new FacetSearchParams(new CountFacetRequest(cp, 10)), indexReader, taxoReader);
        searcher.search(new MatchAllDocsQuery(), fc);
        assertEquals(1, (int) fc.getFacetResults().get(0).getFacetResultNode().value);
       
        DrillDownQuery drillDown = new DrillDownQuery(FacetIndexingParams.DEFAULT);
        drillDown.add(cp);
        TopDocs docs = searcher.search(drillDown, 10);
View Full Code Here

    IndexSearcher searcher = new IndexSearcher(DirectoryReader.open(w.w, false));
    w.close();
    Filter parentFilter = new QueryWrapperFilter(new TermQuery(new Term("__type", "parent")));
    Filter childFilter = new QueryWrapperFilter(new PrefixQuery(new Term("field2")));
    ToParentBlockJoinQuery query = new ToParentBlockJoinQuery(
        new FilteredQuery(new MatchAllDocsQuery(), childFilter),
        new FixedBitSetCachingWrapperFilter(parentFilter),
        ScoreMode.None
    );

    // Sort by field ascending, order first
    ToParentBlockJoinSortField sortField = new ToParentBlockJoinSortField(
        "field2", SortField.Type.STRING, false, wrap(parentFilter), wrap(childFilter)
    );
    Sort sort = new Sort(sortField);
    TopFieldDocs topDocs = searcher.search(query, 5, sort);
    assertEquals(7, topDocs.totalHits);
    assertEquals(5, topDocs.scoreDocs.length);
    assertEquals(3, topDocs.scoreDocs[0].doc);
    assertEquals("a", ((BytesRef) ((FieldDoc) topDocs.scoreDocs[0]).fields[0]).utf8ToString());
    assertEquals(7, topDocs.scoreDocs[1].doc);
    assertEquals("c", ((BytesRef) ((FieldDoc) topDocs.scoreDocs[1]).fields[0]).utf8ToString());
    assertEquals(11, topDocs.scoreDocs[2].doc);
    assertEquals("e", ((BytesRef) ((FieldDoc) topDocs.scoreDocs[2]).fields[0]).utf8ToString());
    assertEquals(15, topDocs.scoreDocs[3].doc);
    assertEquals("g", ((BytesRef) ((FieldDoc) topDocs.scoreDocs[3]).fields[0]).utf8ToString());
    assertEquals(19, topDocs.scoreDocs[4].doc);
    assertEquals("i", ((BytesRef) ((FieldDoc) topDocs.scoreDocs[4]).fields[0]).utf8ToString());

    // Sort by field ascending, order last
    sortField = new ToParentBlockJoinSortField(
        "field2", SortField.Type.STRING, false, true, wrap(parentFilter), wrap(childFilter)
    );
    sort = new Sort(sortField);
    topDocs = searcher.search(query, 5, sort);
    assertEquals(7, topDocs.totalHits);
    assertEquals(5, topDocs.scoreDocs.length);
    assertEquals(3, topDocs.scoreDocs[0].doc);
    assertEquals("c", ((BytesRef) ((FieldDoc) topDocs.scoreDocs[0]).fields[0]).utf8ToString());
    assertEquals(7, topDocs.scoreDocs[1].doc);
    assertEquals("e", ((BytesRef) ((FieldDoc) topDocs.scoreDocs[1]).fields[0]).utf8ToString());
    assertEquals(11, topDocs.scoreDocs[2].doc);
    assertEquals("g", ((BytesRef) ((FieldDoc) topDocs.scoreDocs[2]).fields[0]).utf8ToString());
    assertEquals(15, topDocs.scoreDocs[3].doc);
    assertEquals("i", ((BytesRef) ((FieldDoc) topDocs.scoreDocs[3]).fields[0]).utf8ToString());
    assertEquals(19, topDocs.scoreDocs[4].doc);
    assertEquals("k", ((BytesRef) ((FieldDoc) topDocs.scoreDocs[4]).fields[0]).utf8ToString());

    // Sort by field descending, order last
    sortField = new ToParentBlockJoinSortField(
        "field2", SortField.Type.STRING, true, wrap(parentFilter), wrap(childFilter)
    );
    sort = new Sort(sortField);
    topDocs = searcher.search(query, 5, sort);
    assertEquals(topDocs.totalHits, 7);
    assertEquals(5, topDocs.scoreDocs.length);
    assertEquals(28, topDocs.scoreDocs[0].doc);
    assertEquals("o", ((BytesRef) ((FieldDoc) topDocs.scoreDocs[0]).fields[0]).utf8ToString());
    assertEquals(23, topDocs.scoreDocs[1].doc);
    assertEquals("m", ((BytesRef) ((FieldDoc) topDocs.scoreDocs[1]).fields[0]).utf8ToString());
    assertEquals(19, topDocs.scoreDocs[2].doc);
    assertEquals("k", ((BytesRef) ((FieldDoc) topDocs.scoreDocs[2]).fields[0]).utf8ToString());
    assertEquals(15, topDocs.scoreDocs[3].doc);
    assertEquals("i", ((BytesRef) ((FieldDoc) topDocs.scoreDocs[3]).fields[0]).utf8ToString());
    assertEquals(11, topDocs.scoreDocs[4].doc);
    assertEquals("g", ((BytesRef) ((FieldDoc) topDocs.scoreDocs[4]).fields[0]).utf8ToString());

    // Sort by field descending, order last, sort filter (filter_1:T)
    childFilter = new QueryWrapperFilter(new TermQuery((new Term("filter_1", "T"))));
    query = new ToParentBlockJoinQuery(
        new FilteredQuery(new MatchAllDocsQuery(), childFilter),
        new FixedBitSetCachingWrapperFilter(parentFilter),
        ScoreMode.None
    );
    sortField = new ToParentBlockJoinSortField(
        "field2", SortField.Type.STRING, true, wrap(parentFilter), wrap(childFilter)
View Full Code Here

TOP

Related Classes of org.apache.lucene.search.MatchAllDocsQuery

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.