Package org.apache.lucene.search.highlight

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


        }

        if (readerDir != null)
        {
          IndexReader     reader = IndexReader.open(readerDir);
          SimpleHTMLFormatter formatter = new SimpleHTMLFormatter("<span class=\"highlighted\">", "</span>");

          mHighlighter = new Highlighter(formatter, new QueryScorer(query.rewrite(reader)));
        }
        else
        {
View Full Code Here


        Query           keywordQuery = search_tool.getKeywordQuery();
        Highlighter       highlighter = null;
        if (keywordQuery != null)
        {
          Query         rewritten_query =  keywordQuery.rewrite(reader);
          SimpleHTMLFormatter formatter = new SimpleHTMLFormatter("<span class=\"highlighted\">", "</span>");
         
          highlighter = new Highlighter(formatter, new QueryScorer(rewritten_query));
        }

        for (int i = offset; i < LIMIT + offset; i++)
View Full Code Here

      Query rewrittenQuery = manager.rewrite(mQuery);
      QueryScorer queryScorer = new QueryScorer(rewrittenQuery);
      // End added by Anders

      Highlighter highlighter = new Highlighter(
              new SimpleHTMLFormatter("<span class=\"highlight\">", "</span>"), queryScorer);

      // Remark: the summary is at this point not a summary. It contains the
      // first n characters from the document. n is configurable (default: 250000)
      // We transform this summary into
      // a) a summary matching the search terms (highlighting)
View Full Code Here

     */
    protected String escapeBestFragments(Query query, Fragmenter fragmenter,
                                         String indexedText, int numOfFragments, int alternativeLength) {

        // The HTML escaping forces us to first fragment with internal placeholders...
        Highlighter highlighter = new Highlighter(new SimpleHTMLFormatter(INTERNAL_BEGIN_HIT, INTERNAL_END_HIT), new QueryScorer(query));
        highlighter.setTextFragmenter(fragmenter);
        try {
            // Use the same analyzer as the indexer!
            TokenStream tokenStream = new StandardAnalyzer().tokenStream(null, new StringReader(indexedText));

View Full Code Here

   * @param doc
   * @param resultDocument
   * @throws IOException
   */
  private void doHighlight(Query query, Analyzer analyzer, Document doc, ResultDocument resultDocument) throws IOException {
    Highlighter highlighter = new Highlighter(new SimpleHTMLFormatter(HIGHLIGHT_PRE_TAG,HIGHLIGHT_POST_TAG) , new QueryScorer(query));
    // Get 3 best fragments of content and seperate with a "..."
    String content = doc.get(OlatDocument.CONTENT_FIELD_NAME);
    String title = doc.get(OlatDocument.TITLE_FIELD_NAME);
   
    Set terms = new HashSet();
View Full Code Here

    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

    numRequests++;
    if( defaults != null ) {
      params = new DefaultSolrParams( params, defaults );
    }
   
    return new SimpleHTMLFormatter(
        params.getFieldParam(fieldName, HighlightParams.SIMPLE_PRE,  "<em>" ),
        params.getFieldParam(fieldName, HighlightParams.SIMPLE_POST, "</em>"));
  }
View Full Code Here

        //int end = Math.min(numTotalHits, hitsPerPage);
        int end = 0;

        end = Math.min(hits.length, start + hitsPerPage);

        SimpleHTMLFormatter htmlFormatter = new SimpleHTMLFormatter();
        Highlighter highlighter = new Highlighter(htmlFormatter, new QueryScorer(query));


        for (int i = start; i < end; i++) {
            /* if (raw) {                              // output raw format
View Full Code Here

    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

    Query fixedQuery = fixSuperQuery(query, null, fieldLessFieldName);

    Analyzer analyzer = fieldManager.getAnalyzerForQuery();

    SimpleHTMLFormatter htmlFormatter = new SimpleHTMLFormatter(preTag, postTag);
    Document result = new Document();
    for (IndexableField f : document) {
      String name = f.name();
      if (fieldLessFieldName.equals(name) || FIELDS_NOT_TO_HIGHLIGHT.contains(name)) {
        result.add(f);
View Full Code Here

TOP

Related Classes of org.apache.lucene.search.highlight.SimpleHTMLFormatter

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.