1. 程式人生 > >lucene原始碼分析(5)Query分析

lucene原始碼分析(5)Query分析

查詢的入口

  /** Lower-level search API.
   *
   * <p>{@link LeafCollector#collect(int)} is called for every matching document.
   *
   * @throws BooleanQuery.TooManyClauses If a query would exceed 
   *         {@link BooleanQuery#getMaxClauseCount()} clauses.
   */
  public void search(Query query, Collector results)
    
throws IOException { query = rewrite(query); search(leafContexts, createWeight(query, results.needsScores(), 1), results); }

可以看到,查詢時需要傳入Query介面的實現,其實現主要有:

/** The abstract base class for queries.
    <p>Instantiable subclasses are:
    <ul>
    <li> {@link TermQuery
} <li> {@link BooleanQuery} <li> {@link WildcardQuery} <li> {@link PhraseQuery} <li> {@link PrefixQuery} <li> {@link MultiPhraseQuery} <li> {@link FuzzyQuery} <li> {@link RegexpQuery} <li> {@link TermRangeQuery} <li> {@link PointRangeQuery
} <li> {@link ConstantScoreQuery} <li> {@link DisjunctionMaxQuery} <li> {@link MatchAllDocsQuery} </ul> <p>See also the family of {@link org.apache.lucene.search.spans Span Queries} and additional queries available in the <a href
="{@docRoot}/../queries/overview-summary.html">Queries module</a> */

還有spanQuery跨度查詢

太多了,需要一個個看