Examples of Hits


Examples of org.apache.lucene.search.Hits

      IndexSearcher searcher = buildSearcher( searchFactoryImplementor );
      if ( searcher == null ) {
        resultSize = 0;
      }
      else {
        Hits hits;
        try {
          hits = getHits( searcher );
          resultSize = hits.length();
        }
        catch (IOException e) {
          throw new HibernateException( "Unable to query Lucene index", e );
        }
        finally {
View Full Code Here

Examples of org.apache.lucene.search.Hits

    }

    public Hits getOverview( NewsGroup group ) throws IOException, ParseException {
        IndexSearcher searcher = new IndexSearcher( articleOverviewDirectory );
        Query query = QueryParser.parse( group.getName(), "newsgroup", new StandardAnalyzer());
        Hits hits = searcher.search( query );
        return hits;
    }
View Full Code Here

Examples of org.apache.lucene.search.Hits

                    nntpResponse.sendResponse( 200, "Hello you can post." );
                }
            } else if( nntpRequest.getCommand().equalsIgnoreCase("xover") ) {
                nntpResponse.sendResponse( 224, "Header follows" );
                NewsGroup group = forum.getNewsgroup( nntpRequest.getCurrentNewsgroup() );
                Hits hits = forum.getOverview( group );
                for( int i = 0; i < hits.length(); i++ ) {
                    Document doc = hits.doc( i );
                    NntpOutputStream stream = nntpResponse.getOutputStream();
                    stream.print( doc.getField("article." + group.getName() + ".article-number").stringValue() );
                    stream.print( "\t" );
                    stream.print( doc.getField("article.subject").stringValue() );
                    stream.print( "\t" );
View Full Code Here

Examples of org.apache.lucene.search.Hits

        } // next
      } else {
        aRetArr = null;
      }
    } else {
      Hits oHitSet = oSearch.search(oQry);
      int iHitCount = oHitSet.length();
      if (iHitCount>0) {
        aRetArr = new BugRecord[iHitCount];
        for (int h=0; h<iHitCount; h++) {
          oDoc = oHitSet.doc(h);
          aRetArr[h] = new BugRecord(oHitSet.score(h),
                   Integer.parseInt(oDoc.get("number")),
                       oDoc.get("guid"), oDoc.get("container"), oDoc.get("title"),
                       oDoc.get("author"), oDoc.get("created"), oDoc.get("type"),
                       oDoc.get("status"), oDoc.get("priority"),
                       oDoc.get("severity"), oDoc.get("abstract"));
View Full Code Here

Examples of org.apache.lucene.search.Hits

        } // next
      } else {
        aRetArr = null;
      }
    } else {
      Hits oHitSet = oSearch.search(oQrx);
      int iHitCount = oHitSet.length();
      if (iHitCount>0) {
        aRetArr = new NewsMessageRecord[iHitCount];
        for (int h=0; h<iHitCount; h++) {
          oDoc = oHitSet.doc(h);
          try {
            aRetArr[h] = new NewsMessageRecord(oHitSet.score(h), oDoc.get("workarea"),
                         oDoc.get("guid"), oDoc.get("container"), oDoc.get("title"),
                         oDoc.get("author"), DateTools.stringToDate(oDoc.get("created")), oDoc.get("abstract"));
          } catch (java.text.ParseException neverthrown) {
            throw new ParseException("NewsMessageSearcher.search() Error parsing date "+oDoc.get("created")+" of document "+oDoc.get("guid"));
          }
View Full Code Here

Examples of org.apache.lucene.search.Hits

    try {
      File directory = searchIndexManager.getIndexDirectory();
      searcher = new IndexSearcher(IndexReader.open(directory));
      Analyzer analyzer = DocumentCreator.createDocumentAnalyzer();
      QueryParser parser = new QueryParser(DocumentCreator.FIELD_TEXT,analyzer);
      Hits hits = searcher.search(parser.parse(query));
      List<BookmarkDoc> bmDocs = new ArrayList<BookmarkDoc>();
      if (offset >= 0 && offset < hits.length()) {
        if (count > 0) {         
          for (int i = offset; i < hits.length() && bmDocs.size() < count; i++) {
            BookmarkDoc doc = createBookmarkDoc(hits.doc(i));
            if (doc != null) {
              bmDocs.add(doc);
            }
          }
        }
      }
      result = new DaoResult<BookmarkDoc>(bmDocs,hits.length());
    } finally {
      if (searcher != null) {
        searcher.close();
      }
    }
View Full Code Here

Examples of org.apache.lucene.search.Hits

      Query inputQuery = parser.parse(query);
      BooleanQuery boolQuery = new BooleanQuery();
      boolQuery.add(matchUserQuery, BooleanClause.Occur.MUST);
      boolQuery.add(inputQuery,BooleanClause.Occur.MUST);
     
      Hits hits = searcher.search(boolQuery);
      List<BookmarkDoc> bmDocs = new ArrayList<BookmarkDoc>();
      if (offset >= 0 && offset < hits.length()) {
        if (count > 0) {         
          for (int i = offset; i < hits.length() && bmDocs.size() < count; i++) {
            BookmarkDoc doc = createBookmarkDoc(hits.doc(i));
            if (doc != null) {
              bmDocs.add(doc);
            }
          }
        }
      }
      result = new DaoResult<BookmarkDoc>(bmDocs,hits.length());
    } finally {
      if (searcher != null) {
        searcher.close();
      }
    }
View Full Code Here

Examples of org.apache.lucene.search.Hits

      IndexReader indexReader = null;
      IndexSearcher indexSearch = null;
      try{
        indexReader = searchSuggestIndexer.openSuggestIndexReader();
        indexSearch = new IndexSearcher(indexReader);
        Hits hits = indexSearch.search(prefixQuery);
        int maxNumCandidate = maxSuggestionSize;
        if(idxReader != null && field != null){
          maxNumCandidate = maxSuggestionSize * 10;
        }
        PriorityQueue<SuggestWord> suggestQueue = new PriorityQueue<SuggestWord>(maxNumCandidate);
        for(int i = 0; i < hits.length() && i < maxNumCandidate; i++){
          String sugWord = hits.doc(i).get("t");
          // check if the 'sugWord' matches at least one doc in the
          // source index database (idxReader)
          if(idxReader != null && field != null){
            int freq = idxReader.docFreq(new Term(field,sugWord));
            if(freq > 0){
View Full Code Here

Examples of org.apache.lucene.search.Hits

  {
   System.out.println("Started testQuery");
   SearchQuery sq = new SearchQuery();
   String query = "money";
   System.out.println("Query: " + query);
   Hits hits = sq.getHits(query); sq.dumpHits(hits, false);
   String[] results = sq.getResults();
   for (int i = 0; i < results.length; i++)
    System.out.println(i + ": " + results[i]);
  
   System.out.println("Ended testQuery");
View Full Code Here

Examples of org.apache.lucene.search.Hits

  * @return Hits A hits object
  */
public Hits getHits(String question)
{
  //*-- translate the question into a search engine query
  Hits hits = null;
  try { query = buildQuery(question);
        logger.info("Question: " + question + " is parsed to " + query);
        hits = is.search(query);
       }
  catch (IOException ie) { logger.error("IO Error in fetching hits for query " + question); hits = 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.