Package org.apache.lucene.search

Examples of org.apache.lucene.search.ParallelMultiSearcher


   * @return a Searcher instance
   * @see org.springmodules.lucene.search.SearcherFactory#getSearcher()
   */
  public Searcher getSearcher() throws IOException {
    Searcher[] searchers = createSearchers();
    return new ParallelMultiSearcher(searchers);
  }
View Full Code Here


   * @return a Searcher instance
   * @see org.springmodules.lucene.search.SearcherFactory#getSearcher()
   */
  public LuceneSearcher getSearcher() throws IOException {
    Searcher[] searchers = createSearchers();
    ParallelMultiSearcher parallelMultiSearcher = new ParallelMultiSearcher(searchers);
    return new SimpleLuceneSearcher(parallelMultiSearcher);
  }
View Full Code Here

                        .size()];
                for (int i = 0; i < searchers.length; i++) {
                    searchers[i]= new IndexSearcher((Directory)(directories
                        .get(i)));
                }
                luceneSearcher = new ParallelMultiSearcher(searchers);
            } else {
                luceneSearcher = new IndexSearcher((Directory) (directories
                        .get(0)));
            }
    }
View Full Code Here

            }
          }
          if (searchers.size()>0) {
            Searcher[] searcherarraytype = new Searcher[searchers.size()];
          Searcher[] allsearchers = (searchers.toArray(searcherarraytype));
          Searcher searcher = new ParallelMultiSearcher(allsearchers);
          RemoteSearchable remoteSearchable = new RemoteSearchable(searcher);
          Naming.rebind("mailarchiva",remoteSearchable);
          }
        } catch (Exception e) {
          logger.error("failed to bind remote access searchables",e);
View Full Code Here

      Searcher[] searcherarraytype = new Searcher[searchers.size()];
      Searcher[] allsearchers = (Searcher[])(searchers.toArray(searcherarraytype));

      Searcher searcher;
       try {
           searcher = new ParallelMultiSearcher(allsearchers);
      } catch (IOException io) {
          throw new MessageSearchException("failed to open/create one or more index searchers",logger);
      }
      return searcher;
    }
View Full Code Here

    //Parse Query
    Query parsedQuery;
    SearchResponse response = new SearchResponse();
   
    //Construct the multiSearcher
    ParallelMultiSearcher multiSearcher = null;
    RealTimeDiskFilter    myFilter      = null;
    try{

      //This section needs to be thread safe
      synchronized(this){
           
        //Commit any prev writes
        if(hasWrite.getAndSet(false)){
          ramWriter.commit();
         
          //Reopen index reader
          IndexReader newReader = ramReader.reopen();
          if(ramReader != newReader){ 
            //ramReader.close();
            ramSearcher.close();
            ramReader   = newReader;     
            ramSearcher = new IndexSearcher(ramReader);
          }       
        }
       
       
        List<Searchable> searchersList = new ArrayList<Searchable>();
       
        if(ramSearcher.maxDoc() > 0)
          searchersList.add(ramSearcher);
       
        if(prevRamSearcher != null && prevRamSearcher.maxDoc() > 0)
          searchersList.add(prevRamSearcher);
       
        if(diskSearcher.maxDoc() > 0)
          searchersList.add(diskSearcher);
       
        //empty index
        if(searchersList.size() == 0)
          return response;
       
        Searchable[] searchers = new Searchable[]{};
        multiSearcher = new ParallelMultiSearcher(searchersList.toArray(searchers));
       
        myFilter      = diskFilter;
     
     
      }
     
      PerFieldAnalyzerWrapper qAnalyzer = new PerFieldAnalyzerWrapper(analyzer);
      QueryParser    queryParser = new QueryParser(DOCUMENT_KEY,qAnalyzer);
     
      //add any keyword fields
      if(query.isSetKeyword_fields()){     
        for(String field : query.keyword_fields)
          qAnalyzer.addAnalyzer(field, kwAnalyzer);
      }
     
      //parse query
      //TODO: Cache?
      try{
        parsedQuery = queryParser.parse(query.getQuery());
      }catch(org.apache.lucene.queryParser.ParseException e){
        throw new ThrudexExceptionImpl(e.toString());
      }
     
 
     
      //Set Sort
      Sort    sortBy = new Sort();
     
      if(query.isSetSortby() && !query.sortby.trim().equals(""))
        sortBy.setSort(query.getSortby() + "_sort", query.desc);
   
     
      //Search   
      TopDocs result = null;
      try{
        result = multiSearcher.search(parsedQuery,myFilter,query.offset + query.limit,sortBy);
      }catch(Exception e){
        logger.debug("Sortby failed, trying non sorted search");
        result = multiSearcher.search(parsedQuery,myFilter,query.offset + query.limit);
      }
     
      response.setTotal(result.totalHits);
     
      FieldSelector fieldSelector;
      if(query.isPayload()){
        fieldSelector = new MapFieldSelector(new String[]{DOCUMENT_KEY,PAYLOAD_KEY});
      }else{
        fieldSelector = new MapFieldSelector(new String[]{DOCUMENT_KEY});
      }
     
     
      for(int i=query.offset; i<result.totalHits && i<(query.offset + query.limit); i++){
       
        Element el = new Element();
        el.setIndex(query.index);
                   
        Document d = multiSearcher.doc(result.scoreDocs[i].doc,fieldSelector);
        el.setKey(d.get(DOCUMENT_KEY));
       
        if(query.isSetPayload() && query.payload)
          el.setPayload(d.get(PAYLOAD_KEY));
     
View Full Code Here

TOP

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

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.