Examples of QueryScorer


Examples of org.apache.lucene.search.highlight.QueryScorer

    try {
     
      logger.debug("query for highlighter : {}" , query);

      QueryScorer scorer = new QueryScorer(query);

      Highlighter highlighter = new Highlighter(formatter, scorer);
      highlighter.setTextFragmenter(new SimpleFragmenter(50));

View Full Code Here

Examples of org.apache.lucene.search.highlight.QueryScorer

  public int numToHighlight() {
    return numToHighlight;
  }
 
  protected BenchmarkHighlighter getBenchmarkHighlighter(Query q){
    highlighter = new Highlighter(new SimpleHTMLFormatter(), new QueryScorer(q));
    highlighter.setMaxDocCharsToAnalyze(maxDocCharsToAnalyze);
    return new BenchmarkHighlighter(){
      public int doHighlight(IndexReader reader, int doc, String field,
          Document document, Analyzer analyzer, String text) throws Exception {
        TokenStream ts = TokenSources.getAnyTokenStream(reader, doc, field, document, analyzer);
View Full Code Here

Examples of org.apache.lucene.search.highlight.QueryScorer

    }
    return document;
  }

  public BenchmarkHighlighter getBenchmarkHighlighter(Query q) {
    highlighter = new Highlighter(new SimpleHTMLFormatter(), new QueryScorer(q));
    return new BenchmarkHighlighter() {
      public int doHighlight(IndexReader reader, int doc, String field, Document document, Analyzer analyzer, String text) throws Exception {
        TokenStream ts = TokenSources.getAnyTokenStream(reader, doc, field, document, analyzer);
        TextFragment[] frag = highlighter.getBestTextFragments(ts, text, mergeContiguous, maxFrags);
        numHighlightedResults += frag != null ? frag.length : 0;
View Full Code Here

Examples of org.apache.lucene.search.highlight.QueryScorer

    return numToHighlight;
  }
 
  @Override
  protected BenchmarkHighlighter getBenchmarkHighlighter(Query q){
    highlighter = new Highlighter(new SimpleHTMLFormatter(), new QueryScorer(q));
    highlighter.setMaxDocCharsToAnalyze(maxDocCharsToAnalyze);
    return new BenchmarkHighlighter(){
      @Override
      public int doHighlight(IndexReader reader, int doc, String field,
          Document document, Analyzer analyzer, String text) throws Exception {
View Full Code Here

Examples of org.apache.lucene.search.highlight.QueryScorer

            if( (flags & FLAG_CONTEXTS) != 0 )
            {
                highlighter = new Highlighter(new SimpleHTMLFormatter("<span class=\"searchmatch\">", "</span>"),
                                              new SimpleHTMLEncoder(),
                                              new QueryScorer(luceneQuery));
            }

            try
            {
                File dir = new File(m_luceneDirectory);
View Full Code Here

Examples of org.apache.lucene.search.highlight.QueryScorer

   * @param fields 字段名
   */
  public List<T> keywordsHighlight(BooleanQuery query, List<T> list, int subLength, String... fields){
    Analyzer analyzer = new IKAnalyzer();
    Formatter formatter = new SimpleHTMLFormatter("<span class=\"highlight\">", "</span>");  
    Highlighter highlighter = new Highlighter(formatter, new QueryScorer(query));
    highlighter.setTextFragmenter(new SimpleFragmenter(subLength));
    for(T entity : list){
      try {
        for (String field : fields){
          String text = StringUtils.replaceHtml((String)Reflections.invokeGetter(entity, field));
View Full Code Here

Examples of org.apache.lucene.search.highlight.QueryScorer

        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);
View Full Code Here

Examples of org.apache.lucene.search.highlight.QueryScorer

    return numToHighlight;
  }
 
  @Override
  protected BenchmarkHighlighter getBenchmarkHighlighter(Query q){
    highlighter = new Highlighter(new SimpleHTMLFormatter(), new QueryScorer(q));
    highlighter.setMaxDocCharsToAnalyze(maxDocCharsToAnalyze);
    return new BenchmarkHighlighter(){
      @Override
      public int doHighlight(IndexReader reader, int doc, String field,
          Document document, Analyzer analyzer, String text) throws Exception {
View Full Code Here

Examples of org.apache.lucene.search.highlight.QueryScorer

    return document;
  }

  @Override
  public BenchmarkHighlighter getBenchmarkHighlighter(Query q) {
    highlighter = new Highlighter(new SimpleHTMLFormatter(), new QueryScorer(q));
    return new BenchmarkHighlighter() {
      @Override
      public int doHighlight(IndexReader reader, int doc, String field, Document document, Analyzer analyzer, String text) throws Exception {
        TokenStream ts = TokenSources.getAnyTokenStream(reader, doc, field, document, analyzer);
        TextFragment[] frag = highlighter.getBestTextFragments(ts, text, mergeContiguous, maxFrags);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.