Package railo.runtime.search

Examples of railo.runtime.search.AddionalAttrs


            Analyzer analyzer = SearchUtil.getAnalyzer(language);
            Query query=null;
            Op op=null;
            Object highlighter=null;
            railo.runtime.search.lucene2.query.QueryParser queryParser=new railo.runtime.search.lucene2.query.QueryParser();
      AddionalAttrs aa = AddionalAttrs.getAddionlAttrs();
      aa.setHasRowHandling(true);
      int startrow=aa.getStartrow();
      int maxrows=aa.getMaxrows();
     
     
      if(!criteria.equals("*")) {
        // FUTURE take this data from calling parameters
        op=queryParser.parseOp(criteria);
        if(op==null) criteria="*";
        else criteria=op.toString();
        try {
         
          query = new QueryParser("contents",analyzer ).parse(criteria);
          highlighter = Highlight.createHighlighter(query,aa.getContextHighlightBegin(),aa.getContextHighlightEnd());
         
               
        }
              catch (ParseException e) {
          throw new SearchException(e);
        }
      }
     
      Resource[] files = _getIndexDirectories();
     
            if(files==null) return new SearchResulItem[0];
            ArrayList<SearchResulItem> list=new ArrayList<SearchResulItem>();
            String ct,c;
           
            ArrayList<String> spellCheckIndex=spellcheck?new ArrayList<String>():null;
           
            int count=0;
            IndexReader reader = null;
            Searcher searcher = null;
            try {
              outer:for(int i=0;i<files.length;i++) {
              if(removeCorrupt(files[i]))continue;
                String strFile=files[i].toString();
                SearchIndex si = indexes.get(files[i].getName());
               
                if(si==null)continue;
                ct=si.getCategoryTree();
                c=ListUtil.arrayToList(si.getCategories(), ",");
               
                // check category tree
                if(!matchCategoryTree(ct,categoryTree))continue;
                if(!matchCategories(si.getCategories(),category))continue;
               
                Document doc;
                String id=files[i].getName();
                data.addRecordsSearched(_countDocs(strFile));
               
                reader = _getReader(id,false);
                if(query==null && "*".equals(criteria)) {
                  int len=reader.numDocs();
                  for(int y=0;y<len;y++) {
                    if(startrow>++count)continue;
                    if(maxrows>-1 && list.size()>=maxrows) break outer;
                    doc = reader.document(y);
                    list.add(createSearchResulItem(highlighter,analyzer,doc,id,1,ct,c,aa.getContextPassages(),aa.getContextBytes()));
                  }
                }
                else {
                  if(spellcheck)spellCheckIndex.add(id);
                  // search
                  searcher = new IndexSearcher(reader);
                    Hits hits = searcher.search(query);
                  int len=hits.length();
                  for (int y=0; y<len; y++) {
                    if(startrow>++count)continue;
                    if(maxrows>-1 && list.size()>=maxrows) break outer;
                    //list.add(new SearchResulItemHits(hits,y,highlighter,analyzer,id,ct,c,aa.getContextPassages(),aa.getContextBytes()));
                    doc = hits.doc(y);
                    list.add(createSearchResulItem(highlighter,analyzer,doc,id,hits.score(y),ct,c,aa.getContextPassages(),aa.getContextBytes()));
                 
                
                }
              
            }
View Full Code Here

TOP

Related Classes of railo.runtime.search.AddionalAttrs

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.