Package org.apache.lucene.search

Examples of org.apache.lucene.search.Searcher.search()


      if(2>1) return;
     
      MultiReader reader=new MultiReader(readers.toArray(new IndexReader[readers.size()]),false);

      searcher=new IndexSearcher(reader);
      hits = searcher.search(q,10);
      int expected = TestData.testdata.length;
      assertEquals("before update: zoie count mismatch[hit count: " + hits.totalHits +" / expected: "+TestData.testdata.length +"]", count, hits.totalHits);
      q = parser.parse("zoie2");

      searcher.close();
View Full Code Here


      readers=idxSystem.getIndexReaders();
      reader=new MultiReader(readers.toArray(new IndexReader[readers.size()]),false);

      searcher=new IndexSearcher(reader);
      hits = searcher.search(q,10);
      assertEquals("before update: zoie2 count mismatch[hit count: " + hits.totalHits +" / expected: "+ 0 +"]", 0, hits.totalHits);
      searcher.close();
      reader.close();
      idxSystem.returnIndexReaders(readers);
View Full Code Here

      q = parser.parse("zoie");
      readers=idxSystem.getIndexReaders();
      reader=new MultiReader(readers.toArray(new IndexReader[readers.size()]),false);

      searcher=new IndexSearcher(reader);
      hits = searcher.search(q,10);
      expected = 0;
      assertEquals("after update: zoie count mismatch[hit count: " + hits.totalHits +" / expected: "+ 0 +"]", 0,  hits.totalHits);
      searcher.close();
      reader.close();
      idxSystem.returnIndexReaders(readers);
View Full Code Here

      readers=idxSystem.getIndexReaders();
      reader=new MultiReader(readers.toArray(new IndexReader[readers.size()]),false);

      searcher=new IndexSearcher(reader);

      hits = searcher.search(q,10);
      expected = TestData.testdata2.length;
      assertEquals("after update: zoie2 count mismatch[hit count: " + hits.totalHits +" / expected: "+ expected +"]", expected, hits.totalHits);
      searcher.close();
      reader.close();
      idxSystem.returnIndexReaders(readers);
View Full Code Here

      readers=_idxReaderFactory.getIndexReaders();
      multiReader=new MultiReader(readers.toArray(new IndexReader[readers.size()]), false);
      searcher=new IndexSearcher(multiReader);
     
      long start=System.currentTimeMillis();
      TopDocs docs=searcher.search(q, null, 10);
      long end=System.currentTimeMillis();
     
      result.setTime(end-start);
      result.setTotalDocs(multiReader.numDocs());
      result.setTotalHits(docs.totalHits);
View Full Code Here

      q = qparser.parse(queryString);
    }
    readers=_idxReaderFactory.getIndexReaders();
    multiReader=new MultiReader(readers.toArray(new IndexReader[readers.size()]));
    searcher=new IndexSearcher(multiReader);
    TopDocs hits = searcher.search(q,10);
    result.setTotalDocs(multiReader.numDocs());
    result.setTotalHits(hits.totalHits);
    long end = System.nanoTime();
    long latency = (end-start)/NANOS_IN_MILLI;
    result.setTime(latency);
View Full Code Here

                                RangeFilter rangeFilter = new RangeFilter(Index.FIELD_MODDATE, dateFrom, dateTo, true, true);
                                if (logger.isDebugEnabled()) {
                                    logger.debug("doSearch() search with date range '" + rangeFilter + "'");
                                }

                                hits = searcher.search(query, rangeFilter);
                            }
                            else {
                                if (logger.isDebugEnabled()) {
                                    logger.debug("doSearch() search without date range");
                                }
View Full Code Here

                            else {
                                if (logger.isDebugEnabled()) {
                                    logger.debug("doSearch() search without date range");
                                }

                                hits = searcher.search(query);
                            }

                            // check for search with filesize
                            int numHits;
                            if (useSize.isSelected()) {
View Full Code Here

            // Lucene 3 insists on a hard limit and will not provide
            // a total hits value. Take at least 100 which is
            // an optimal limit for Lucene as any more
            // will trigger writing results to disk.
            int maxResults = (limit == 0 ? 100 : limit) + offset;
            TopDocs docs = searcher.search(query, maxResults);
            if (limit == 0) {
                limit = docs.totalHits;
            }
            for (int i = 0, len = docs.scoreDocs.length;
                    i < limit && i + offset < docs.totalHits
View Full Code Here

            return null;
        }
       
        try
        {
            hits = searcher.search(query);
        }
        catch (IOException e)
        {
           logger.error("Error while peforming search.", e);
           return null;
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.