Package railo.runtime.search

Examples of railo.runtime.search.SearchIndex


            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()));
                 
                
                }
              
            }
            }
          finally {
            close(reader);
            close(searcher);
          }  
           
            // spellcheck
            //SearchData data=ThreadLocalSearchData.get();
            if(spellcheck && data!=null) {
              if(data.getSuggestionMax()>=list.size()) {
               
                Map suggestions = data.getSuggestion();
                Iterator it = spellCheckIndex.iterator();
                String id;
                Literal[] literals = queryParser.getLiteralSearchedTerms();
                String[] strLiterals = queryParser.getStringSearchedTerms();
                boolean setSuggestionQuery=false;
                while(it.hasNext()) {
                  id=(String) it.next();
                  // add to set to remove duplicate values
                  SuggestionItem si;
                  SpellChecker sc = getSpellChecker(id);
                  for(int i=0;i<strLiterals.length;i++) {
                    String[] arr = sc.suggestSimilar(strLiterals[i], 1000);
                    if(arr.length>0){
                      literals[i].set("<suggestion>"+arr[0]+"</suggestion>");
                      setSuggestionQuery=true;
                     
                      si=(SuggestionItem) suggestions.get(strLiterals[i]);
                      if(si==null)suggestions.put(strLiterals[i],new SuggestionItem(arr));
                      else si.add(arr);
                    }
                  }
              }
                if(setSuggestionQuery)data.setSuggestionQuery(op.toString());
              }
View Full Code Here


    String[] cats;
    String catTree;
    Double tmp;
   
    while(it.hasNext()) {
      SearchIndex index=indexes.get(it.next());
     
      // category tree
      catTree = index.getCategoryTree();
      tmp=(Double) categorytrees.get(catTree,null);
      if(tmp==null) categorytrees.setEL(catTree,Caster.toDouble(1));
      else categorytrees.setEL(catTree,Caster.toDouble(tmp.doubleValue()+1));
     
      // categories
      cats = index.getCategories();
      for(int i=0;i<cats.length;i++) {
        tmp=(Double) categories.get(cats[i],null);
        if(tmp==null) categories.setEL(cats[i],Caster.toDouble(1));
        else categories.setEL(cats[i],Caster.toDouble(tmp.doubleValue()+1));
      }
View Full Code Here

TOP

Related Classes of railo.runtime.search.SearchIndex

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.