In this article:

This service is designed to search for documents.


SearchDocumentService searchDocumentService = Imcms.getServices().getSearchDocumentService();


List<DocumentStoredFieldsDTO> searchDocuments(SearchQueryDTO searchQuery, boolean limitSearch);

List<DocumentStoredFieldsDTO> searchDocuments(SearchQueryDTO searchQuery);

SolrDocumentList searchDocumentsReturnSolrDocumentList(SearchQueryDTO searchQuery, boolean limitSearch);

SolrDocumentList searchDocumentsReturnSolrDocumentList(SearchQueryDTO searchQuery);

List<DocumentStoredFieldsDTO> searchDocuments(String searchQuery, boolean limitSearch);

List<DocumentStoredFieldsDTO> searchDocuments(String searchQuery);

SolrDocumentList searchDocumentsReturnSolrDocumentList(String stringSearchQuery, boolean limitSearch);

SolrDocumentList searchDocumentsReturnSolrDocumentList(String stringSearchQuery);

List<DocumentStoredFieldsDTO> searchDocuments(String searchQuery, PageRequestDTO page, boolean limitSearch);

List<DocumentStoredFieldsDTO> searchDocuments(String searchQuery, PageRequestDTO page);

SolrDocumentList searchDocumentsReturnSolrDocumentList(String stringSearchQuery, PageRequestDTO page, boolean limitSearch);

SolrDocumentList searchDocumentsReturnSolrDocumentList(String stringSearchQuery, PageRequestDTO page);


SearchQueryDTO searchQuery - represent a query as an object.

PageRequestDTO page - represent sorting and paging.

String searchQuery - represent a custom query as a string.

By default, the search returns only published documents and those to which the user has access. To remove this condition set boolean limitSearch to false.

Return Types

List<DocumentStoredFieldsDTO> - a list of objects that represent basic data about a document.

SolrDocumentList - represent a list of SolrDocuments returned from a search. Use a key name from DocumentIndex to get needed values.


Additional classes



contain the names of the fields by which the values are obtained and by which the values are set during the indexing of the document.



String term - free text. Use “” to search a quote.

Integer userId - filter by creator id.

List<Integer> categoriesId - the document must have these categories.

PageRequestDTO page - represent sorting and paging.



String property - sort key. Use a key name from DocumentIndex.

Sort.Direction direction - sorting direction.

int skip - number of documents to skip.

int size - number of documents to return.



represent basic data about a document.

Usage examples

SearchDocumentService searchDocumentService = Imcms.getServices().getSearchDocumentService();

// search using SearchQueryDTO and get List<DocumentStoredFieldsDTO>
final SearchQueryDTO searchQuery = new SearchQueryDTO("some text");
searchQuery.setPage(new PageRequestDTO(DocumentIndex.FIELD__ID,, 10, 20));
final List<DocumentStoredFieldsDTO> documentStoredFieldsDTOList = searchDocumentService.searchDocuments(searchQuery);
for(DocumentStoredFieldsDTO documentStoredFields: documentStoredFieldsDTOList){
    System.out.println("id: " + documentStoredFields.getId());
    System.out.println("title: " + documentStoredFields.getTitle());

// search using query as string and get SolrDocumentList
final String query = "+" + DocumentIndex.FIELD__TEXT + ":" + "some text" + " " +
        "+" + DocumentIndex.FIELD__CREATOR_ID + ":" + "1";
final SolrDocumentList solrDocuments = searchDocumentService.searchDocumentsReturnSolrDocumentList();
for (final SolrDocument solrDocument : solrDocuments) {
    System.out.println("id: " + solrDocument.getFieldValue(DocumentIndex.FIELD__ID));
    System.out.println("title: " + solrDocument.getFieldValue(DocumentIndex.FIELD__META_HEADLINE));