Package org.apache.lucene.search.highlight

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


   if (queryString.length() > 0)
   { Query query = qp.parse(queryString.toString());
     QueryScorer qScorer = new QueryScorer(query);
     SimpleHTMLFormatter formatter = new SimpleHTMLFormatter("<span class=\"hlight\">", "</span>");
     Highlighter highlighter = new Highlighter(formatter, qScorer);
     Fragmenter fragmenter = new SimpleFragmenter(80);        //*-- use fragments of 50 bytes each
     highlighter.setTextFragmenter(fragmenter);
     TokenStream tokenStream = sAnalyzer.tokenStream("contents", new StringReader(text));
     result = highlighter.getBestFragments(tokenStream, text, 3, "...<br>")//*-- collect upto three fragments
   }
  }
View Full Code Here


        // create tokenstream
        TokenStream tokenStream = getwgacore().getLuceneManager().createTokenStream(analyzeText, content());
       
        // create fragmenter and set fragmentsize to itemText.length to ensure only one fragments with the whole itemText is returned       
        Fragmenter fragmenter = new SimpleFragmenter(originalText.length() + 1); // if analyzeText.length == originalText.length we might get two fragments from lucene without the +1 (possible lucene bug)
        highlighter.setTextFragmenter(fragmenter);
               
        try {
            String highlighted = highlighter.getBestFragment(tokenStream, originalText.toString());
            if (highlighted != null) {
View Full Code Here

       
        // create tokenstream
        TokenStream tokenStream = getwgacore().getLuceneManager().createTokenStream(originalText, content());
       
        // create fragmenter and set fragmentsize to metaText.length to ensure only one fragments with the whole metaText is returned       
        Fragmenter fragmenter = new SimpleFragmenter(originalText.length() + 1); // +1 is necessary here
        highlighter.setTextFragmenter(fragmenter);
               
        try {
            String highlighted = highlighter.getBestFragment(tokenStream, originalText);
            if (highlighted != null) {
View Full Code Here

       
        // create tokenstream
        TokenStream tokenStream = getwgacore().getLuceneManager().createTokenStream(text, content());
               
        // create fragmenter
        Fragmenter fragmenter = new SimpleFragmenter(fragmentSize);
        highlighter.setTextFragmenter(fragmenter);
       
        try {
            String[] highlighted = highlighter.getBestFragments(tokenStream, text, maxFragments);           
            if (highlighted != null) {
View Full Code Here

    }

    int fragmentLength = SearchObjectType.commit == result.type ? 512 : 150;

    QueryScorer scorer = new QueryScorer(query, "content");
    Fragmenter fragmenter = new SimpleSpanFragmenter(scorer, fragmentLength);

    // use an artificial delimiter for the token
    String termTag = "!!--[";
    String termTagEnd = "]--!!";
    SimpleHTMLFormatter formatter = new SimpleHTMLFormatter(termTag, termTagEnd);
View Full Code Here

    QueryScorer scorer = new QueryScorer(query);

    Highlighter highlighter = new Highlighter(scorer);

    Fragmenter fragmenter = new SimpleFragmenter(5);
    highlighter.setTextFragmenter(fragmenter);

    Analyzer a = new KoreanAnalyzer(false);
    TokenStream tokenStream = a.tokenStream("f", new StringReader(text));
View Full Code Here

TOP

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

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.