Package org.apache.lucene.search

Examples of org.apache.lucene.search.IndexSearcher.rewrite()


    //ADD SUPPORT FOR LEADING WILDCARDS
    parser.setAllowLeadingWildcard(true);
    parser.setMultiTermRewriteMethod(MultiTermQuery.SCORING_BOOLEAN_QUERY_REWRITE);
    Query parsedQuery = parser.parse("content:t*");
    IndexSearcher searcher = lucene.getSearcher();
    parsedQuery = searcher.rewrite(parsedQuery);
    Document d = reader.document(0);
    String highlighted = advancedHighlighter.highlight(parsedQuery, reader, 0, SimpleLucene.CONTENT_ATTRIBUTE);
    System.out.println(highlighted);
    assertEquals("Could not properly highlight", "<b>this</b> word9 <b>the</b> word1 <b>tat</b>", highlighted);
  }
View Full Code Here


        tdocs= searcher.search(query,filter, offset + groupSize * groupCount * slackFactor, sort);
      }
      statistics.notifyEventValue("lucene work time", System.currentTimeMillis() - startTime);

      // Exceptions are thrown to upper layer, but if we got here, assume everything is ok.
      Query rewrittenQuery = searcher.rewrite(query);
      GroupedSearchResults results = pageResults(tdocs, searcher, offset, groupCount, groupBy, groupSize);
      if (null == results) {
        throw new RuntimeException("GroupedSearchResults is NULL");
      }
      return(new Pair<GroupedSearchResults, Query>(results, rewrittenQuery));
View Full Code Here

      final String shard = shardNames[i];
      final IndexSearcher searcher = getSearcherByShard(shard);
      if (searcher == null) {
        throw new IllegalStateException("no index-server for shard '" + shard + "' found - probably undeployed");
      } else {
        queries[i] = searcher.rewrite(original);
      }
    }
    if (queries.length > 0 && queries[0] != null) {
      return queries[0].combine(queries);
    } else {
View Full Code Here

      qp = new QueryParser(luceneVersion, Lucene.content.name(), analyzer);
      qp.setAllowLeadingWildcard(true);
      query.add(qp.parse(text), Occur.SHOULD);

      IndexSearcher searcher = getSearcher();
      Query rewrittenQuery = searcher.rewrite(query);

      log.debug(rewrittenQuery.toString());

      TopScoreDocCollector collector = TopScoreDocCollector.create(5000, true);
      searcher.search(rewrittenQuery, collector);
View Full Code Here

    try {
      QueryParser qp = new QueryParser(luceneVersion, Lucene.content.name(), analyzer);
      Query query = qp.parse(queryText);

      IndexSearcher searcher = getSearcher();
      Query rewrittenQuery = searcher.rewrite(query);

      log.debug(rewrittenQuery.toString());

      Sort sort;
      if (sortBy == null) {
View Full Code Here

      qp = new QueryParser(luceneVersion, Lucene.content.name(), analyzer);
      qp.setAllowLeadingWildcard(true);
      query.add(qp.parse(text), Occur.SHOULD);

      IndexSearcher searcher = getSearcher();
      Query rewrittenQuery = searcher.rewrite(query);

      log.debug(rewrittenQuery.toString());

      TopScoreDocCollector collector = TopScoreDocCollector.create(5000, true);
      searcher.search(rewrittenQuery, collector);
View Full Code Here

    try {
      QueryParser qp = new QueryParser(luceneVersion, Lucene.content.name(), analyzer);
      Query query = qp.parse(queryText);

      IndexSearcher searcher = getSearcher();
      Query rewrittenQuery = searcher.rewrite(query);

      log.debug(rewrittenQuery.toString());

      Sort sort;
      if (sortBy == null) {
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.