org.apache.ignite.cache.query

## Class IndexQuery<K,V>

- java.lang.Object
- - org.apache.ignite.cache.query.Query<javax.cache.Cache.Entry<K,V>>
  - - org.apache.ignite.cache.query.IndexQuery<K,V>

- All Implemented Interfaces:
    Serializable

      public final class IndexQuery<K,V>
      extends Query<javax.cache.Cache.Entry<K,V>>

  Index queries work over distributed indexes and retrieve cache entries that match the specified criteria. `QueryCursor` delivers sorted cache entries by the order defined for queried index. `IndexQuery` has to be initialized with cache value class or type. The algorithm of discovering index is as follows: 1. If `idxName` is set, then use it. 2. If `idxName` is not set, then find an index that matches criteria fields. 3. If neither `idxName`, nor `setCriteria(List)` is used, then perform index scan over PK index for specified Value type. Conjuction of items in `criteria` has to represent a valid range to traverse the index tree.
  See Also:
    Serialized Form

- - ### Field Summary

    - ### Fields inherited from class org.apache.ignite.cache.query.Query

      `DFLT_PAGE_SIZE`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `IndexQuery(Class<?> valCls)` Specify index with cache value class.
    `IndexQuery(Class<?> valCls, @Nullable String idxName)` Specify index with cache value class and index name.
    `IndexQuery(String valType)` Specify index with cache value type.
    `IndexQuery(String valType, @Nullable String idxName)` Specify index with cache value type and index name.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `List<IndexQueryCriterion>` | `getCriteria()` Index query criteria.
    `IgniteBiPredicate<K,V>` | `getFilter()` Gets remote cache entries filter.
    `String` | `getIndexName()` Index name.
    `String` | `getValueType()` Cache Value type.
    `IndexQuery<K,V>` | `setCriteria(IndexQueryCriterion... criteria)` Sets conjunction (AND) criteria for index query.
    `IndexQuery<K,V>` | `setCriteria(List<IndexQueryCriterion> criteria)` Sets conjunction (AND) criteria for index query.
    `IndexQuery<K,V>` | `setFilter(IgniteBiPredicate<K,V> filter)` Sets remote cache entries filter.

    - ### Methods inherited from class org.apache.ignite.cache.query.Query

      `getPageSize, isLocal, prepare, setLocal, setPageSize, toString`

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

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

- - ### Constructor Detail

    - #### IndexQuery

          public IndexQuery(Class<?> valCls)

      Specify index with cache value class.
      Parameters:
        `valCls` - Cache value class.

    - #### IndexQuery

          public IndexQuery(String valType)

      Specify index with cache value type.
      Parameters:
        `valType` - Cache value type.

    - #### IndexQuery

          public IndexQuery(Class<?> valCls,
                            @Nullable
                            @Nullable String idxName)

      Specify index with cache value class and index name.
      Parameters:
        `valCls` - Cache value class.
        `idxName` - Index name.

    - #### IndexQuery

          public IndexQuery(String valType,
                            @Nullable
                            @Nullable String idxName)

      Specify index with cache value type and index name.
      Parameters:
        `valType` - Cache value type.
        `idxName` - Index name.

  - ### Method Detail

    - #### setCriteria

          public IndexQuery<K,V> setCriteria(IndexQueryCriterion... criteria)

      Sets conjunction (AND) criteria for index query.
      Parameters:
        `criteria` - Criteria to set.
      Returns:
        `this` for chaining.

    - #### setCriteria

          public IndexQuery<K,V> setCriteria(List<IndexQueryCriterion> criteria)

      Sets conjunction (AND) criteria for index query.
      Parameters:
        `criteria` - Criteria to set.
      Returns:
        `this` for chaining.

    - #### getCriteria

          public List<IndexQueryCriterion> getCriteria()

      Index query criteria.
      Returns:
        List of criteria for this index query.

    - #### getValueType

          public String getValueType()

      Cache Value type.
      Returns:
        Cache Value type.

    - #### getIndexName

          public String getIndexName()

      Index name.
      Returns:
        Index name.

    - #### setFilter

          public IndexQuery<K,V> setFilter(IgniteBiPredicate<K,V> filter)

      Sets remote cache entries filter.
      Parameters:
        `filter` - Predicate for remote filtering of query result cursor.
      Returns:
        `this` for chaining.

    - #### getFilter

          public IgniteBiPredicate<K,V> getFilter()

      Gets remote cache entries filter.
      Returns:
        Filter.

2022 Copyright © Apache Software Foundation
| Follow @ApacheIgnite
Ignite Database and Caching Platform | : ver. 2.12.0
Release Date | : January 10 2022