Package org.apache.lucene.search

Examples of org.apache.lucene.search.TopFieldDocs


       
    SortField sf = new SortField(sortProperty, SortField.STRING, reverse);

    Query query = new MatchAllDocsQuery();
   
    TopFieldDocs topDocs = searcher.search(query, (Filter) null, 1000000, new Sort(sf));
    logger.info("offset:" + offset);
    logger.info("limit:" + limit);
    logger.info("topDocs.totalHits:" + topDocs.totalHits);
   
    int start = offset;
View Full Code Here


   
    SortField sf = new SortField(sortProperty, SortField.STRING, reverse);
    logger.info("searchText:" + searchText);
    Query query = new QueryParser(Version.LUCENE_34, "contents", analyzer).parse(searchText+"*");
   
    TopFieldDocs topDocs = searcher.search(query, (Filter) null, 1000000, new Sort(sf));
    logger.info("offset:" + offset);
    logger.info("limit:" + limit);
    logger.info("topDocs.totalHits:" + topDocs.totalHits);
   
    int start = offset;
View Full Code Here

      query = mfqp.parse(entityName + " " + searchText + "*");
    }
   
    logger.info("query" + query);
   
    TopFieldDocs topDocs = searcher.search(query, (Filter) null, 1000000, new Sort(sf));
    logger.info("offset:" + offset);
    logger.info("limit:" + limit);
    logger.info("topDocs.totalHits:" + topDocs.totalHits);
   
    int start = offset;
View Full Code Here

      if(query.isSetSortby() && !query.sortby.trim().equals(""))
        sortBy.setSort(query.getSortby() + "_sort", query.desc);
   
     
      //Search   
      TopFieldDocs result = mySearcher.search(parsedQuery,null,query.offset + query.limit,sortBy);
     
      SearchResponse response = new SearchResponse();
      response.setTotal(result.totalHits);
     
      FieldSelector fieldSelector;
View Full Code Here

        final IndexFieldData indexFieldData = getForField("value");
        final String missingValue = values[1];
        IndexSearcher searcher = new IndexSearcher(DirectoryReader.open(writer, true));
        XFieldComparatorSource comparator = indexFieldData.comparatorSource(missingValue, MultiValueMode.MIN, null);
        TopFieldDocs topDocs = searcher.search(new MatchAllDocsQuery(), randomBoolean() ? numDocs : randomIntBetween(10, numDocs), new Sort(new SortField("value", comparator, reverse)));
        assertEquals(numDocs, topDocs.totalHits);
        BytesRef previousValue = reverse ? UnicodeUtil.BIG_TERM : new BytesRef();
        for (int i = 0; i < topDocs.scoreDocs.length; ++i) {
            final String docValue = searcher.doc(topDocs.scoreDocs[i].doc).get("value");
            final BytesRef value = new BytesRef(docValue == null ? missingValue : docValue);
View Full Code Here

            }
        }
        final IndexFieldData indexFieldData = getForField("value");
        IndexSearcher searcher = new IndexSearcher(DirectoryReader.open(writer, true));
        XFieldComparatorSource comparator = indexFieldData.comparatorSource(first ? "_first" : "_last", MultiValueMode.MIN, null);
        TopFieldDocs topDocs = searcher.search(new MatchAllDocsQuery(), randomBoolean() ? numDocs : randomIntBetween(10, numDocs), new Sort(new SortField("value", comparator, reverse)));
        assertEquals(numDocs, topDocs.totalHits);
        BytesRef previousValue = first ? null : reverse ? UnicodeUtil.BIG_TERM : new BytesRef();
        for (int i = 0; i < topDocs.scoreDocs.length; ++i) {
            final String docValue = searcher.doc(topDocs.scoreDocs[i].doc).get("value");
            if (first && docValue == null) {
View Full Code Here

        Filter childFilter = new NotFilter(parentFilter);
        Nested nested = createNested(parentFilter, childFilter);
        BytesRefFieldComparatorSource nestedComparatorSource = new BytesRefFieldComparatorSource(fieldData, missingValue, sortMode, nested);
        ToParentBlockJoinQuery query = new ToParentBlockJoinQuery(new FilteredQuery(new MatchAllDocsQuery(), childFilter), new BitDocIdSetCachingWrapperFilter(parentFilter), ScoreMode.None);
        Sort sort = new Sort(new SortField("text", nestedComparatorSource));
        TopFieldDocs topDocs = searcher.search(query, randomIntBetween(1, numParents), sort);
        assertTrue(topDocs.scoreDocs.length > 0);
        BytesRef previous = null;
        for (int i = 0; i < topDocs.scoreDocs.length; ++i) {
            final int docID = topDocs.scoreDocs[i].doc;
            assertTrue("expected " + docID + " to be a parent", parents.get(docID));
View Full Code Here

        MultiSourceReader reader = new MultiSourceReader(rdrs);
        searcher = new IndexSearcher(reader);
      }
      Query rewrittenQuery = searcher.rewrite(query);
      Sort sort = new Sort(new SortField(FIELD_DATE, SortField.STRING, true));
      TopFieldDocs topDocs = searcher.search(rewrittenQuery, 10000, sort);
      int offset = Math.max(0, (page - 1) * pageSize);
      ScoreDoc[] hits = topDocs.scoreDocs;
      int totalHits = topDocs.totalHits;
      if (pageSize <= 0) {
        pageSize = totalHits;
View Full Code Here

TOP

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

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.