Examples of QueryScorer


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

        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
        {
          throw new IOException("Couldn't find the correct index directory for this bot, channel, and server combination");
        }
View Full Code Here

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

        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++)
        {
          if (i >= hits.length())
View Full Code Here

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

    try {
      IndexSearcherManager manager = IndexSearcherManager.getInstance(mIndexConfig.getDirectory());
      // The highlighter needs a rewritten query to work with wildcard and fuzzy queries
      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);
View Full Code Here

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

     */
    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

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

   * @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

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

      System.out.println(query);
      System.out.println("Searching for: " + query.toString(FIELD_NAME));
      Hits hits = searcher.search(query);
     
      BoldFormatter formatter = new BoldFormatter();
      Highlighter highlighter =new Highlighter(formatter,new QueryScorer(query));
      highlighter.setTextFragmenter(new SimpleFragmenter(50));
      for (int i = 0; i < hits.length(); i++)
      {
        String text = hits.doc(i).get(FIELD_NAME);
        int maxNumFragmentsRequired = 5;
View Full Code Here

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

    query = query.rewrite(reader);
    System.out.println("Searching for: " + query.toString(FIELD_NAME));
    TopDocs hits = searcher.search(query, 10);

    BoldFormatter formatter = new BoldFormatter();
    Highlighter highlighter = new Highlighter(formatter, new QueryScorer(
        query));
    highlighter.setTextFragmenter(new SimpleFragmenter(50));
    for (int i = 0; i < hits.scoreDocs.length; i++) {
      int docId = hits.scoreDocs[i].doc;
      Document hit = searcher.doc(docId);
View Full Code Here

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

    query = query.rewrite(reader);
    System.out.println("Searching for: " + query.toString(FIELD_NAME));
    TopDocs hits = searcher.search(query, 10);   

    BoldFormatter formatter = new BoldFormatter();
    Highlighter highlighter = new Highlighter(formatter, new QueryScorer(
        query));
    highlighter.setTextFragmenter(new SimpleFragmenter(50));
    for (int i = 0; i < hits.scoreDocs.length; i++) {
      int docId = hits.scoreDocs[i].doc;
      Document hit = searcher.doc(docId);
View Full Code Here

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

    query = query.rewrite(reader);
    System.out.println("Searching for: " + query.toString(FIELD_NAME));
    TopDocs hits = searcher.search(query, 10);   

    BoldFormatter formatter = new BoldFormatter();
    Highlighter highlighter = new Highlighter(formatter, new QueryScorer(
        query));
    highlighter.setTextFragmenter(new SimpleFragmenter(50));
    for (int i = 0; i < hits.scoreDocs.length; i++) {
      int docId = hits.scoreDocs[i].doc;
      Document hit = searcher.doc(docId);
View Full Code Here

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

    query = query.rewrite(reader);
    System.out.println("Searching for: " + query.toString(FIELD_NAME));
    TopDocs hits = searcher.search(query, 10);

    BoldFormatter formatter = new BoldFormatter();
    Highlighter highlighter = new Highlighter(formatter, new QueryScorer(
        query));
    highlighter.setTextFragmenter(new SimpleFragmenter(50));
    for (int i = 0; i < hits.scoreDocs.length; i++) {
      int docId = hits.scoreDocs[i].doc;
      Document hit = searcher.doc(docId);
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.