Package proj.zoie.service.api

Examples of proj.zoie.service.api.SearchHit


      ScoreDoc[] scoreDocs=docs.scoreDocs;
      ArrayList<SearchHit> hitList=new ArrayList<SearchHit>(scoreDocs.length);
      for (ScoreDoc scoreDoc : scoreDocs)
      {
        SearchHit hit=new SearchHit();
        hit.setScore(scoreDoc.score);
        int docid=scoreDoc.doc;
       
        Document doc=multiReader.document(docid);
        String content=doc.get("content");
       
        Scorer qs=new QueryScorer(q);
       
        SimpleHTMLFormatter formatter=new SimpleHTMLFormatter("<span class=\"hl\">","</span>");
        Highlighter hl=new Highlighter(formatter,qs);
        String[] fragments=hl.getBestFragments(analyzer, "content",content, 1);
       
        Map<String,String[]> fields=convert(doc);
        fields.put("fragment",fragments);
        hit.setFields(fields);
        hitList.add(hit);
      }
     
      result.setHits(hitList.toArray(new SearchHit[hitList.size()]));
      return result;
View Full Code Here


      result.setTotalHits(docs.totalHits);

      ScoreDoc[] scoreDocs = docs.scoreDocs;
      ArrayList<SearchHit> hitList = new ArrayList<SearchHit>(scoreDocs.length);
      for (ScoreDoc scoreDoc : scoreDocs) {
        SearchHit hit = new SearchHit();
        hit.setScore(scoreDoc.score);
        int docid = scoreDoc.doc;

        Document doc = multiReader.document(docid);
        String content = doc.get("content");

        Scorer qs = new QueryScorer(q);

        SimpleHTMLFormatter formatter = new SimpleHTMLFormatter("<span class=\"hl\">", "</span>");
        Highlighter hl = new Highlighter(formatter, qs);
        String[] fragments = hl.getBestFragments(analyzer, "content", content, 1);

        Map<String, String[]> fields = convert(doc);
        fields.put("fragment", fragments);
        hit.setFields(fields);
        hitList.add(hit);
      }

      result.setHits(hitList.toArray(new SearchHit[hitList.size()]));
      return result;
View Full Code Here

TOP

Related Classes of proj.zoie.service.api.SearchHit

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.