Package railo.runtime.search.lucene2.query

Examples of railo.runtime.search.lucene2.query.OpUtil


          analyzer= new CJKAnalyzer();

        else if(language.equals("italian"))
          analyzer= new ItalianAnalyzer();
        else if(language.equals("danish"))
          analyzer= new DanishAnalyzer();
        else if(language.equals("norwegian"))
          analyzer= new NorwegianAnalyzer();
        else if(language.equals("finnish"))
          analyzer= new SnowballAnalyzer( "Finnish" );
        else if(language.equals("swedish"))
View Full Code Here


          analyzer= new CJKAnalyzer();
        else if(language.equals("korean"))
          analyzer= new CJKAnalyzer();

        else if(language.equals("italian"))
          analyzer= new ItalianAnalyzer();
        else if(language.equals("danish"))
          analyzer= new DanishAnalyzer();
        else if(language.equals("norwegian"))
          analyzer= new NorwegianAnalyzer();
        else if(language.equals("finnish"))
View Full Code Here

        else if(language.equals("dutch"))    
          analyzer= new DutchAnalyzer();
        else if(language.equals("french"))    
          analyzer= new FrenchAnalyzer();
        else if(language.equals("norwegian"))  
          analyzer= new NorwegianAnalyzer();
        else if(language.equals("portuguese"))  
          analyzer= new PortugueseAnalyzer();
        else if(language.equals("spanish"))  
          analyzer= new SpanishAnalyzer();
        else if(language.equals("brazilian"))  
          analyzer= new BrazilianAnalyzer();
        else if(language.equals("chinese"))  
          analyzer= new ChineseAnalyzer();
        else if(language.startsWith("czech"))  
          analyzer= new CzechAnalyzer();
        else if(language.equals("greek"))    
          analyzer= new GreekAnalyzer();
        else if(language.equals("thai"))
          analyzer= new ThaiAnalyzer();
        else if(language.equals("japanese"))
          analyzer= new CJKAnalyzer();
        else if(language.equals("korean"))
          analyzer= new CJKAnalyzer();

        else if(language.equals("italian"))
          analyzer= new ItalianAnalyzer();
        else if(language.equals("danish"))
          analyzer= new DanishAnalyzer();
        else if(language.equals("norwegian"))
          analyzer= new NorwegianAnalyzer();
        else if(language.equals("finnish"))
          analyzer= new SnowballAnalyzer( "Finnish" );
        else if(language.equals("swedish"))
          analyzer= new SnowballAnalyzer( "Swedish" );
       
View Full Code Here

        else if(language.equals("french"))    
          analyzer= new FrenchAnalyzer();
        else if(language.equals("norwegian"))  
          analyzer= new NorwegianAnalyzer();
        else if(language.equals("portuguese"))  
          analyzer= new PortugueseAnalyzer();
        else if(language.equals("spanish"))  
          analyzer= new SpanishAnalyzer();
        else if(language.equals("brazilian"))  
          analyzer= new BrazilianAnalyzer();
        else if(language.equals("chinese"))  
View Full Code Here

        else if(language.equals("norwegian"))  
          analyzer= new NorwegianAnalyzer();
        else if(language.equals("portuguese"))  
          analyzer= new PortugueseAnalyzer();
        else if(language.equals("spanish"))  
          analyzer= new SpanishAnalyzer();
        else if(language.equals("brazilian"))  
          analyzer= new BrazilianAnalyzer();
        else if(language.equals("chinese"))  
          analyzer= new ChineseAnalyzer();
        else if(language.startsWith("czech"))  
View Full Code Here

 
  public static Document getDocument(Resource res,String charset)  {
    Document doc = new Document();
    doc.add(FieldUtil.Text("uid", uid(res), false));
   
    HTMLParser parser = new HTMLParser();
    try {
      parser.parse(res,charset);
    }
    catch (Throwable t) {
        return doc;
    }
    addContent(doc,parser);
View Full Code Here

  }

  public static Document getDocument(StringBuffer content, Reader reader) {
      Document doc = new Document();
     
      HTMLParser parser = new HTMLParser();
      try {
        String str = IOUtil.toString(reader);
        if(content!=null)content.append(str);
        doc.add(FieldUtil.UnIndexed("size", Caster.toString(str.length())));
        StringReader sr = new StringReader(str);
          parser.parse(sr);
      }
      catch (Throwable t) {
        //t.printStackTrace();
          return doc;
      }
View Full Code Here

        int before=getDocumentCount(id);
        IndexWriter writer=null;
        synchronized(token){
          try {
              writer = _getWriter(id,true);
              new WebCrawler(log).parse(writer, url, extensions, recurse,timeout);
             
              writer.optimize();
          }
          catch (Exception e) {
              throw new SearchException(e);
View Full Code Here

        try {
         
            if(type!=SEARCH_TYPE_SIMPLE) throw new SearchException("search type explicit not supported");
            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()));
                 
                
                }
              
            }
            }
          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());
              }
            }
           
          return list.toArray(new SearchResulItem[list.size()]);
        }
View Full Code Here

TOP

Related Classes of railo.runtime.search.lucene2.query.OpUtil

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.