Package railo.runtime.search

Examples of railo.runtime.search.SuggestionItem


                      "categoryTree","category","context","size","rank","author","type","collection"};
       
        // TODO support context
        String[] types = new String[]{v,v,v,d,d,v,v,v,v,v,v,v,v,d,d,v,v,v};
        SearchData data=new SearchDataImpl(suggestions);
        SuggestionItem item=null;// this is already here to make sure the classloader load this sinstance
       
       
        railo.runtime.type.Query qry=new QueryImpl(cols,types,0,"query");
       
      SearchCollection collection;
      long time=System.currentTimeMillis();
      AddionalAttrs.setAddionalAttrs(contextBytes,contextPassages,contextHighlightBegin,contextHighlightEnd);
      try {
        for(int i=0;i<collections.length;i++) {
          collection=collections[i];
          startrow=collection.search(data,qry,criteria,collection.getLanguage(),type,startrow,maxrows,categoryTree,category);
           
            if(maxrows>=0 && qry.getRecordcount()>=maxrows) break;
        }
        pageContext.setVariable(name,qry);
      }
      catch(SearchException se) {
          throw Caster.toPageException(se);
      }
      finally{
        AddionalAttrs.removeAddionalAttrs();
      }
     
      time=System.currentTimeMillis()-time;
      Double recSearched=new Double(data.getRecordsSearched());
      int len=qry.getRecordcount();
      for(int i=1;i<=len;i++) {
          qry.setAt("recordssearched",i,recSearched);
      }
     
      // status
      if(status!=null) {
        Struct sct=new StructImpl();
        pageContext.setVariable(status, sct);
        sct.set(FOUND, new Double(qry.getRecordcount()));
        sct.set(SEARCHED, recSearched);
        sct.set(KeyConstants._time, new Double(time));
       
        // TODO impl this values
       
        Map s = data.getSuggestion();
        if(s.size()>0) {
          String key;
         
          Iterator it = s.keySet().iterator();
          Struct keywords=new StructImpl();
          Struct keywordScore=new StructImpl();
          sct.set(KEYWORDS, keywords);
          sct.set(KEYWORD_SCORE, keywordScore);
          Object obj;
         
          while(it.hasNext()) {
            key=(String) it.next();
            // FUTURE add SuggestionItem as interface to public interface
           
            // the problem is a conflict between the SuggestionItem version from core and extension
            obj=s.get(key);
            if(obj instanceof SuggestionItem){
              item=(SuggestionItem)obj;
              keywords.set(key, item.getKeywords());
              keywordScore.set(key, item.getKeywordScore());
            }
            else {
              Class clazz = obj.getClass();
              try {
              keywords.set(key, clazz.getMethod("getKeywords", new Class[0]).invoke(obj, new Object[0]));
View Full Code Here


                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

TOP

Related Classes of railo.runtime.search.SuggestionItem

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.