Compartilhar via


CosmosQuery Class

  • java.lang.Object
    • com.azure.spring.data.cosmos.core.query.CosmosQuery

public class CosmosQuery

Class for cosmos query

Constructor Summary

Constructor Description
CosmosQuery(Criteria criteria)

Initialization

Method Summary

Modifier and Type Method and Description
Optional<Object> getPartitionKeyValue(Class<T> domainType)

Returns partition key value based on the criteria.

Criteria getCriteria()

To get Criteria object

Optional<Criteria> getCriteriaByType(CriteriaType criteriaType)

To get criteria by type

int getLimit()

To get limit number

long getOffset()

To get offset number

org.springframework.data.domain.Pageable getPageable()

To get Pageable object

org.springframework.data.domain.Sort getSort()

To get Sort object

boolean hasPartitionKeyCriteria(String partitionKeyFieldName)

Returns true if this criteria or sub-criteria has partition key field present as one of the subjects.

boolean isCrossPartitionQuery(List<String> partitionKeys)

Indicate if DocumentQuery should enable cross partition query.

void setLimit(int limit)

Deprecated

use withLimit instead

To set limit number

CosmosQuery with(Pageable pageable)

With Sort

CosmosQuery with(Sort sort)

With Sort

CosmosQuery withLimit(int limit)

To set limit number

CosmosQuery withOffsetAndLimit(long offset, int limit)

To set limit number and offset number

Methods inherited from java.lang.Object

Constructor Details

CosmosQuery

public CosmosQuery(Criteria criteria)

Initialization

Parameters:

criteria - object

Method Details

getPartitionKeyValue

public Optional getPartitionKeyValue(Class domainType)

Returns partition key value based on the criteria.

Parameters:

domainType - domain type

Returns:

Optional of partition key value

getCriteria

public Criteria getCriteria()

To get Criteria object

Returns:

Criteria

getCriteriaByType

public Optional getCriteriaByType(CriteriaType criteriaType)

To get criteria by type

Parameters:

criteriaType - the criteria type

Returns:

Optional

getLimit

public int getLimit()

To get limit number

Returns:

int limit

getOffset

public long getOffset()

To get offset number

Returns:

long offset

getPageable

public Pageable getPageable()

To get Pageable object

Returns:

Pageable

getSort

public Sort getSort()

To get Sort object

Returns:

Sort

hasPartitionKeyCriteria

public boolean hasPartitionKeyCriteria(String partitionKeyFieldName)

Returns true if this criteria or sub-criteria has partition key field present as one of the subjects.

Parameters:

partitionKeyFieldName - partition key field name

Returns:

returns true if this criteria or sub criteria has partition key field present as one of the subjects.

isCrossPartitionQuery

public boolean isCrossPartitionQuery(List partitionKeys)

Indicate if DocumentQuery should enable cross partition query.

Parameters:

partitionKeys - The list of partitionKey names.

Returns:

If DocumentQuery should enable cross partition query

setLimit

@Deprecated
public void setLimit(int limit)

Deprecated

use withLimit instead

To set limit number

Parameters:

limit - int

with

public CosmosQuery with(Pageable pageable)

With Sort

Parameters:

pageable - Sort

Returns:

CosmosQuery object

with

public CosmosQuery with(Sort sort)

With Sort

Parameters:

sort - Sort

Returns:

CosmosQuery object

withLimit

public CosmosQuery withLimit(int limit)

To set limit number

Parameters:

limit - int

Returns:

CosmosQuery object

withOffsetAndLimit

public CosmosQuery withOffsetAndLimit(long offset, int limit)

To set limit number and offset number

Parameters:

offset - long
limit - int

Returns:

CosmosQuery object

Applies to