Package org.apache.lucene.search

Examples of org.apache.lucene.search.Hits


    SortField[] s_fields = new SortField[2];
    s_fields[0] = SortField.FIELD_SCORE;
    s_fields[1] = new SortField(searching.getKeywordField(), SortField.INT, true);
    Sort sort = new Sort(s_fields);
       
        Hits hits = searcher.search(comboQuery, multiFilter, sort);
    int numResults = hits.length();
    //System.out.println(numResults + " found............................");
    int result_count = Math.min(numResults, MAX_RESULT_COUNT);
    List results = new ArrayList(result_count);
    for(int i=0;i<result_count;i++){
      Document doc = (Document)hits.doc(i);
      //ӳ���ĵ����Ե�Java������
      Object result = params.getSearchObject().newInstance();
      Enumeration fields = doc.fields();
      while(fields.hasMoreElements()){
        Field field = (Field)fields.nextElement();
View Full Code Here


    IndexSearcher searcher = buildSearcher( searchFactoryImplementor );
    if ( searcher == null ) {
      return new IteratorImpl( new ArrayList<EntityInfo>( 0 ), noLoader );
    }
    try {
      Hits hits = getHits( searcher );
      int first = first();
      int max = max( first, hits );
      Session sess = (Session) this.session;

      int size = max - first + 1 < 0 ? 0 : max - first + 1;
View Full Code Here

    SearchFactoryImplementor searchFactory = ContextHelper.getSearchFactoryBySFI( session );

    //find the directories
    IndexSearcher searcher = buildSearcher( searchFactory );
    //FIXME: handle null searcher
    Hits hits;
    try {
      hits = getHits( searcher );
      int first = first();
      int max = max( first, hits );
      DocumentExtractor extractor = new DocumentExtractor( searchFactory, indexProjection );
View Full Code Here

  public List list() throws HibernateException {
    SearchFactoryImplementor searchFactoryImplementor = ContextHelper.getSearchFactoryBySFI( session );
    //find the directories
    IndexSearcher searcher = buildSearcher( searchFactoryImplementor );
    if ( searcher == null ) return new ArrayList( 0 );
    Hits hits;
    try {
      hits = getHits( searcher );
      int first = first();
      int max = max( first, hits );
      Session sess = (Session) this.session;
View Full Code Here

   * @param searcher The index searcher.
   * @return The lucene hits.
   * @throws IOException in case there is an error executing the lucene search.
   */
  private Hits getHits(Searcher searcher) throws IOException {
    Hits hits;
    org.apache.lucene.search.Query query = filterQueryByClasses( luceneQuery );
    buildFilters();
    hits = searcher.search( query, filter, sort );
    setResultSize( hits );
    return hits;
View Full Code Here

      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

    }

    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

                    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

        } // 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

        } // 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

TOP

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

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.