org.apache.lucene.search.suggest.document

## Class PrefixCompletionQuery

- java.lang.Object
- - org.apache.lucene.search.Query
  - - org.apache.lucene.search.suggest.document.CompletionQuery
    - - org.apache.lucene.search.suggest.document.PrefixCompletionQuery

- Direct Known Subclasses:
    FuzzyCompletionQuery

      public class PrefixCompletionQuery
      extends CompletionQuery

  A `CompletionQuery` which takes an `Analyzer` to analyze the prefix of the query term.

  Example usage of querying an analyzed prefix 'sugg' against a field 'suggest_field' is as follows:

        CompletionQuery query = new PrefixCompletionQuery(analyzer, new Term("suggest_field", "sugg"));

  WARNING: This API is experimental and might change in incompatible ways in the next release.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected CompletionAnalyzer` | `analyzer` Used to analyze the term text

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `PrefixCompletionQuery(Analyzer analyzer, Term term)` Calls `PrefixCompletionQuery(Analyzer, Term, BitsProducer)` with no filter
    `PrefixCompletionQuery(Analyzer analyzer, Term term, BitsProducer filter)` Constructs an analyzed prefix completion query

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `Weight` | `createWeight(IndexSearcher searcher, boolean needsScores, float boost)`
    `boolean` | `equals(Object o)`
    `Analyzer` | `getAnalyzer()` Gets the analyzer used to analyze the prefix.
    `int` | `hashCode()`

    - ### Methods inherited from class org.apache.lucene.search.suggest.document.CompletionQuery

      `getField, getFilter, getTerm, rewrite, toString`

    - ### Methods inherited from class org.apache.lucene.search.Query

      `classHash, sameClassAs, toString`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### analyzer

          protected final CompletionAnalyzer analyzer

      Used to analyze the term text

  - ### Constructor Detail

    - #### PrefixCompletionQuery

          public PrefixCompletionQuery(Analyzer analyzer,
                                       Term term)

      Calls `PrefixCompletionQuery(Analyzer, Term, BitsProducer)` with no filter

    - #### PrefixCompletionQuery

          public PrefixCompletionQuery(Analyzer analyzer,
                                       Term term,
                                       BitsProducer filter)

      Constructs an analyzed prefix completion query
      Parameters:
        `analyzer` - used to analyze the provided `Term.text()`
        `term` - query is run against `Term.field()` and `Term.text()` is analyzed with `analyzer`
        `filter` - used to query on a sub set of documents

  - ### Method Detail

    - #### createWeight

          public Weight createWeight(IndexSearcher searcher,
                                     boolean needsScores,
                                     float boost)
                              throws IOException

      Overrides:
        `createWeight` in class `Query`
      Throws:
        `IOException`

    - #### getAnalyzer

          public Analyzer getAnalyzer()

      Gets the analyzer used to analyze the prefix.

    - #### equals

          public boolean equals(Object o)

      Specified by:
        `equals` in class `Query`

    - #### hashCode

          public int hashCode()

      Specified by:
        `hashCode` in class `Query`

Copyright © 2000-2018 Apache Software Foundation. All Rights Reserved.