com.atlassian.confluence.api.service.search
Interface CQLSearchService


@ExperimentalApi
public interface CQLSearchService

Entry point into CQL Search. Provides methods for executing the Confluence Query Language queries to fetch indexed Content. See Advanced Searching using CQL

Since:
5.7

Method Summary
 int countContent(String cqlInput)
          Execute a CQL search query and fetch the number of results found.
 int countContent(String cqlInput, SearchContext searchContext)
          Execute a CQL search query and fetch the number of results found.
 PageResponse<Content> searchContent(String cqlInput, Expansion... expansions)
          Execute a CQL search query and fetch a page results.
 PageResponse<Content> searchContent(String cqlInput, PageRequest pageRequest, Expansion... expansions)
          Execute a CQL search query and fetch a page results.
 PageResponse<Content> searchContent(String cqlInput, SearchContext searchContext, PageRequest pageRequest, Expansion... expansions)
          Execute a CQL search query and fetch a page results.
 

Method Detail

searchContent

PageResponse<Content> searchContent(String cqlInput,
                                    SearchContext searchContext,
                                    PageRequest pageRequest,
                                    Expansion... expansions)
Execute a CQL search query and fetch a page results.

For example, to fetch the first 10 pieces of content in the DEV space with a title containing 'Specs' :

 cqlSearchService.searchContent("space = DEV AND title ~ 'Specs' ORDER BY title", SearchContext.builder().build(), new SimplePageRequest(0, 10));
 

The service will verify the execution context, confirming that the passed entity ids exist, throwing NotFoundException if they don't exist.

Parameters:
cqlInput - - the CQL query to execute
searchContext - - the context to execute the search in
pageRequest - - the pagination request, indicating the start position and limit for the result
expansions - - the optional properties to expand on the result

searchContent

PageResponse<Content> searchContent(String cqlInput,
                                    PageRequest pageRequest,
                                    Expansion... expansions)
Execute a CQL search query and fetch a page results.

For example, to fetch the first 10 pieces of content in the DEV space with a title containing 'Specs' :

 cqlSearchService.searchContent("space = DEV AND title ~ 'Specs' ORDER BY title", new SimplePageRequest(0, 10));
 

This variant of the method executes with the default search context of just the logged in user.

Parameters:
cqlInput - - the CQL query to execute
pageRequest - - the pagination request, indicating the start position and limit for the result
expansions - - the optional properties to expand on the result

searchContent

PageResponse<Content> searchContent(String cqlInput,
                                    Expansion... expansions)
Execute a CQL search query and fetch a page results.

For example, to fetch the first page of content in the DEV space with a title containing 'Specs' :

 cqlSearchService.searchContent("space = DEV AND title ~ 'Specs' ORDER BY title", ExpansionParser.parse("space, history"));
 

This variant executes with the default execution context and a default page size.

Parameters:
cqlInput - - the CQL query to execute
expansions - - optional properties to expand on the result, if an expandable property is not specified here that property will not be accessible

countContent

int countContent(String cqlInput)
Execute a CQL search query and fetch the number of results found.

For example to count the number of pages and blogs in the DEV space created by admin :

 cqlSearchService.countContent("type in (page, blogpost) and space = DEV and creator = admin");
 

Parameters:
cqlInput - - the cql query to count the results of
Returns:
a count of the results that match the cql query

countContent

int countContent(String cqlInput,
                 SearchContext searchContext)
Execute a CQL search query and fetch the number of results found.

For example to count the number of pages and blogs in the DEV space created by admin :

 cqlSearchService.countContent("type in (page, blogpost) and space = DEV and creator = admin", SearchContext.builder().build());
 

Parameters:
cqlInput - - the cql query to count the results of
searchContext - - the context to execute the search in
Returns:
a count of the results that match the cql query


Copyright © 2003–2015 Atlassian. All rights reserved.