Examples of TopDocs


Examples of org.apache.lucene.search.TopDocs

            // Lucene 3 insists on a hard limit and will not provide
            // a total hits value. Take at least 100 which is
            // an optimal limit for Lucene as any more
            // will trigger writing results to disk.
            int maxResults = (limit == 0 ? 100 : limit) + offset;
            TopDocs docs = searcher.search(query, maxResults);
            if (limit == 0) {
                limit = docs.totalHits;
            }
            for (int i = 0, len = docs.scoreDocs.length;
                    i < limit && i + offset < docs.totalHits
View Full Code Here

Examples of org.apache.lucene.search.TopDocs

    IndexSearcher oSearch = new IndexSearcher(sSegments);
   
    Document oDoc;

    if (iLimit>0) {
      TopDocs oTopSet = oSearch.search(oQry, null, iLimit);
      if (oTopSet.scoreDocs!=null) {
        ScoreDoc[] oTopDoc = oTopSet.scoreDocs;
        int iDocCount = oTopDoc.length;
        aRetArr = new BugRecord[iDocCount];
        for (int d=0; d<iDocCount; d++) {
View Full Code Here

Examples of org.apache.lucene.search.TopDocs

    Document oDoc;

    ContactRecord aRetArr[] = null;
    //Recorremos los resultados y los vamos añadiendo al map
   
      TopDocs oTopSet = oSearch.search(oQry, null, 20);
      if (oTopSet.scoreDocs!=null) {
        ScoreDoc[] oTopDoc = oTopSet.scoreDocs;
        int iDocCount = oTopDoc.length;
        aRetArr = new ContactRecord[iDocCount];
        for (int d=0; d<iDocCount; d++) {
View Full Code Here

Examples of org.apache.lucene.search.TopDocs

    Document oDoc;

    if (iLimit>0) {
      System.out.println("IndexSearcher.search("+oQrx.toString()+")");
      if (DebugFile.trace) DebugFile.writeln("IndexSearcher.search("+oQrx.toString()+")");
      TopDocs oTopSet = oSearch.search(oQrx, null, iLimit);
      if (oTopSet.scoreDocs!=null) {
        ScoreDoc[] oTopDoc = oTopSet.scoreDocs;
        int iDocCount = oTopDoc.length;
        aRetArr = new NewsMessageRecord[iDocCount];
        for (int d=0; d<iDocCount; d++) {
View Full Code Here

Examples of org.apache.lucene.search.TopDocs

    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

Examples of org.apache.lucene.search.TopDocs

      } catch (Exception ex) {
        throw new QueryException("Rewrite-Exception query because too many clauses. Query=" + query);
      }
      long startTime = System.currentTimeMillis();
      int n = SearchServiceImpl.getInstance().getSearchModuleConfig().getMaxHits() + 1;
      TopDocs docs = searcher.search(query, n);
      long queryTime = System.currentTimeMillis() - startTime;
      if (log.isDebug()) log.debug("hits.length()=" + docs.totalHits);
      SearchResultsImpl searchResult = new SearchResultsImpl(searcher, docs, query, analyzer, identity, roles, doHighlighting);
      searchResult.setQueryTime(queryTime);
      searchResult.setNumberOfIndexDocuments(searcher.maxDoc());
View Full Code Here

Examples of org.apache.lucene.search.TopDocs

    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

Examples of org.apache.lucene.search.TopDocs

    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

Examples of org.apache.lucene.search.TopDocs

     
      //使用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

Examples of org.apache.lucene.search.TopDocs

    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.