Package org.apache.lucene.search

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


        }
      };

      /* Perform the Search */
      try {
        currentSearcher.search(bQuery, collector);
        return resultList;
      } finally {
        disposeIfNecessary(currentSearcher);
      }
    } catch (IOException e) {
View Full Code Here


    try {
      ObjectCollector collector = new ObjectCollector(objects);
      String query = buildQueryString(search);
      IndexSearcher indexSearcher = new IndexSearcher(indexDirectory,
          true);
      indexSearcher.search(queryParser.parse(query), collector);
      indexSearcher.close();
      return collector.getOutput();
    } catch (Exception e) {
      throw new Exception("Query Syntax Error: " + search);
    }
View Full Code Here

    if (DebugFile.trace) DebugFile.writeln("new IndexSearcher("+sSegments+")");
    IndexSearcher oSearch = new IndexSearcher(sSegments);

    if (iLimit>0) {
      if (DebugFile.trace) DebugFile.writeln("IndexSearcher.search("+oQry.toString()+", null, "+String.valueOf(iLimit)+")");
      TopDocs oTopSet = oSearch.search(oQry, null, iLimit);
      if (oTopSet.scoreDocs!=null) {
        ScoreDoc[] oTopDoc = oTopSet.scoreDocs;
        int iDocCount = oTopDoc.length;
        if (DebugFile.trace) DebugFile.writeln("doc count is "+String.valueOf(iDocCount));
        aRetArr = new MailRecord[iDocCount];
View Full Code Here

      } else {
        aRetArr = null;
      }
    } else {
      if (DebugFile.trace) DebugFile.writeln("IndexSearcher.search("+oQry.toString()+")");
      Hits oHitSet = oSearch.search(oQry);
      int iHitCount = oHitSet.length();
      if (DebugFile.trace) DebugFile.writeln("hit count is "+String.valueOf(iHitCount));
      if (iHitCount>0) {
        aRetArr = new MailRecord[iHitCount];
        for (int h=0; h<iHitCount; h++) {
View Full Code Here

      System.out.println(query);
      Searcher searcher = new IndexSearcher(ramDir);
      query = query.rewrite(reader);
      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++)
View Full Code Here

    QueryParser parser = new QueryParser(Version.LUCENE_CURRENT, FIELD_NAME, analyzer);
    Query query = parser.parse(queryString);
    Searcher searcher = new IndexSearcher(ramDir);
    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));
View Full Code Here

    QueryParser parser = new QueryParser(Version.LUCENE_CURRENT, FIELD_NAME, analyzer);
    Query query = parser.parse(queryString);
    Searcher searcher = new IndexSearcher(ramDir);
    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));
View Full Code Here

     
      //使用IKQueryParser查询分析器构造Query对象
      Query query = IKQueryParser.parse(fieldName, keyword);
     
      //搜索相似度最高的5条记录
      TopDocs topDocs = isearcher.search(query , 5);
      System.out.println("命中:" + topDocs.totalHits);
      //输出结果
      ScoreDoc[] scoreDocs = topDocs.scoreDocs;
      for (int i = 0; i < topDocs.totalHits; i++){
        Document targetDoc = isearcher.doc(scoreDocs[i].doc);
View Full Code Here

    QueryParser parser = new QueryParser(Version.LUCENE_CURRENT, FIELD_NAME, analyzer);
    Query query = parser.parse(queryString);
    Searcher searcher = new IndexSearcher(ramDir);
    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));
View Full Code Here

    QueryParser parser = new QueryParser(Version.LUCENE_CURRENT, FIELD_NAME, analyzer);
    Query query = parser.parse(queryString);
    Searcher searcher = new IndexSearcher(ramDir);
    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));
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.