docs: public CmsSolrQuery getQuery(CmsObject cms) {
  
          final CmsSolrQuery query = new CmsSolrQuery();
  
          // set categories
          query.setCategories(m_categories);
  
          // set container types
          if (null != m_containerTypes) {
              query.addFilterQuery(CmsSearchField.FIELD_CONTAINER_TYPES, m_containerTypes, false, false);
          }
  
          // Set date created time filter
          query.addFilterQuery(
              CmsSearchUtil.getDateCreatedTimeRangeFilterQuery(
                  CmsSearchField.FIELD_DATE_CREATED,
                  getDateCreatedRange().m_startTime,
                  getDateCreatedRange().m_endTime));
  
          // Set date last modified time filter
          query.addFilterQuery(
              CmsSearchUtil.getDateCreatedTimeRangeFilterQuery(
                  CmsSearchField.FIELD_DATE_LASTMODIFIED,
                  getDateLastModifiedRange().m_startTime,
                  getDateLastModifiedRange().m_endTime));
  
          // set scope / folders to search in
          m_foldersToSearchIn = new ArrayList<String>();
          addFoldersToSearchIn(m_folders);
          addFoldersToSearchIn(m_galleries);
          setSearchFolders(cms);
          query.addFilterQuery(
              CmsSearchField.FIELD_PARENT_FOLDERS,
              new ArrayList<String>(m_foldersToSearchIn),
              false,
              true);
  
          if (!m_ignoreSearchExclude) {
              // Reference for the values: CmsGallerySearchIndex.java, field EXCLUDE_PROPERTY_VALUES
              query.addFilterQuery(
                  "-" + CmsSearchField.FIELD_SEARCH_EXCLUDE,
                  Arrays.asList(
                      new String[] {
                          A_CmsSearchIndex.PROPERTY_SEARCH_EXCLUDE_VALUE_ALL,
                          A_CmsSearchIndex.PROPERTY_SEARCH_EXCLUDE_VALUE_GALLERY}),
                  false,
                  true);
          }
  
          // set matches per page
          query.setRows(new Integer(m_matchesPerPage));
  
          // set resource types
          if (null != m_resourceTypes) {
              List<String> resourceTypes = new ArrayList<>(m_resourceTypes);
              if (m_resourceTypes.contains(CmsResourceTypeFunctionConfig.TYPE_NAME)
                  && !m_resourceTypes.contains(CmsXmlDynamicFunctionHandler.TYPE_FUNCTION)) {
                  resourceTypes.add(CmsXmlDynamicFunctionHandler.TYPE_FUNCTION);
              }
              query.setResourceTypes(resourceTypes);
          }
  
          // set result page
          query.setStart(new Integer((m_resultPage - 1) * m_matchesPerPage));
  
          // set search locale
          if (null != m_locale) {
              query.setLocales(CmsLocaleManager.getLocale(m_locale));
          }
  
          // set search words
          if (null != m_words) {
              query.setQuery(m_words);
          }
  
          // set sort order
          query.setSort(getSort().getFirst(), getSort().getSecond());
  
          // set result collapsing by id
          query.addFilterQuery("{!collapse field=id}");
  
          query.setFields(CmsGallerySearchResult.getRequiredSolrFields());
  
          if ((m_allowedFunctions != null) && !m_allowedFunctions.isEmpty()) {
              String functionFilter = "((-type:("
                  + CmsXmlDynamicFunctionHandler.TYPE_FUNCTION
                  + " OR "
                  + CmsResourceTypeFunctionConfig.TYPE_NAME
                  + ")) OR (id:(";
              Iterator<CmsUUID> it = m_allowedFunctions.iterator();
              while (it.hasNext()) {
                  CmsUUID id = it.next();
                  functionFilter += id.toString();
                  if (it.hasNext()) {
                      functionFilter += " OR ";
                  }
              }
              functionFilter += ")))";
              query.addFilterQuery(functionFilter);
          }
  
          return query;
      }