Package railo.runtime.search

Examples of railo.runtime.search.SearchDataImpl


        String[] cols = new String[]{"title","url","summary","score","recordssearched","key","custom1","custom2","custom3","custom4",
                      "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]));
              keywordScore.set(key, clazz.getMethod("getKeywordScore", new Class[0]).invoke(obj, new Object[0]));
            }
              catch (Exception e) {}
            }
           
           
           
          }
         
         
          String query = data.getSuggestionQuery();
          if(query!=null) {
            String html = StringUtil.replace(query, "<suggestion>", "<b>", false);
            html = StringUtil.replace(html, "</suggestion>", "</b>", false);
            sct.set("suggestedQueryHTML", html);
           
View Full Code Here

TOP

Related Classes of railo.runtime.search.SearchDataImpl

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.