Package org.ametys.cms.search.content
Class ContentSearcherFactory.SimpleContentSearcher
- java.lang.Object
-
- org.ametys.cms.search.content.ContentSearcherFactory.SimpleContentSearcher
-
- Enclosing class:
- ContentSearcherFactory
public class ContentSearcherFactory.SimpleContentSearcher extends Object
A ContentSearcher on a list of content types.
-
-
Field Summary
Fields Modifier and Type Field Description private boolean_checkRightsprivate Set<String>_contentTypesprivate List<String>_facetsprivate List<Query>_filterQueriesprivate List<String>_filterQueryStringsprivate int_maxResultsprivate List<Sort>_sortprivate int_start
-
Constructor Summary
Constructors Constructor Description SimpleContentSearcher(Collection<String> contentTypes)Build a content searcher on a list of content types.
-
Method Summary
-
-
-
Field Detail
-
_contentTypes
private Set<String> _contentTypes
-
_start
private int _start
-
_maxResults
private int _maxResults
-
_checkRights
private boolean _checkRights
-
_filterQueryStrings
private List<String> _filterQueryStrings
-
_filterQueries
private List<Query> _filterQueries
-
-
Constructor Detail
-
SimpleContentSearcher
public SimpleContentSearcher(Collection<String> contentTypes)
Build a content searcher on a list of content types.- Parameters:
contentTypes- A collection of content types to search on.
-
-
Method Detail
-
withFilterQueries
public ContentSearcherFactory.SimpleContentSearcher withFilterQueries(List<Query> filterQueries)
Set the filter queries.- Parameters:
filterQueries- the filter queries.- Returns:
- The ContentSearcher itself.
-
withFilterQueryStrings
public ContentSearcherFactory.SimpleContentSearcher withFilterQueryStrings(List<String> filterQueryStrings)
Set the filter queries.- Parameters:
filterQueryStrings- the filter queries.- Returns:
- The ContentSearcher itself.
-
withSort
public ContentSearcherFactory.SimpleContentSearcher withSort(List<Sort> sortCriteria)
Set the sort criteria.- Parameters:
sortCriteria- The sort criteria as a List.- Returns:
- The ContentSearcher itself.
-
addSort
public ContentSearcherFactory.SimpleContentSearcher addSort(String fieldRef, Sort.Order order)
Add a sort criterion.- Parameters:
fieldRef- The field reference (name of a SearchField).order- The sort order.- Returns:
- The ContentSearcher itself.
-
withFacets
public ContentSearcherFactory.SimpleContentSearcher withFacets(Collection<String> facets)
Set the facets.- Parameters:
facets- The facets list.- Returns:
- The ContentSearcher itself.
-
withFacets
public ContentSearcherFactory.SimpleContentSearcher withFacets(String... facets)
Set the facets.- Parameters:
facets- The facets list.- Returns:
- The ContentSearcher itself.
-
withLimits
public ContentSearcherFactory.SimpleContentSearcher withLimits(int start, int maxResults)
Set the limits to use.- Parameters:
start- The start index.maxResults- The maximum number of results.- Returns:
- The ContentSearcher itself.
-
setCheckRights
public ContentSearcherFactory.SimpleContentSearcher setCheckRights(boolean checkRights)
Whether to check rights when searching, false otherwise.- Parameters:
checkRights-trueto check rights,falseotherwise.- Returns:
- The ContentSearcher itself.
-
search
public <C extends Content> AmetysObjectIterable<C> search(Query query) throws Exception
Search the contents.- Type Parameters:
C- The type Content- Parameters:
query- The query object to execute.- Returns:
- The search results as
AmetysObjects. - Throws:
Exception- if an error occurs.
-
search
public <C extends Content> AmetysObjectIterable<C> search(String query) throws Exception
Search the contents.- Type Parameters:
C- The type Content- Parameters:
query- The query string to execute.- Returns:
- The search results as
AmetysObjects. - Throws:
Exception- if an error occurs.
-
searchWithFacets
public <C extends Content> SearchResults<C> searchWithFacets(Query query) throws Exception
Search the contents.- Type Parameters:
C- The type Content- Parameters:
query- The query objet to execute.- Returns:
- The search results.
- Throws:
Exception- if an error occurs.
-
searchWithFacets
public <C extends Content> SearchResults<C> searchWithFacets(String query) throws Exception
Search the contents.- Type Parameters:
C- The type Content- Parameters:
query- The query string to execute.- Returns:
- The search results.
- Throws:
Exception- if an error occurs.
-
searchWithFacets
public <C extends Content> SearchResults<C> searchWithFacets(Query query, Map<String,List<String>> facetValues) throws Exception
Search the contents.- Type Parameters:
C- The type Content- Parameters:
query- The query object to execute.facetValues- The facet values.- Returns:
- The search results.
- Throws:
Exception- if an error occurs.
-
searchWithFacets
public <C extends Content> SearchResults<C> searchWithFacets(String query, Map<String,List<String>> facetValues) throws Exception
Search the contents.- Type Parameters:
C- The type Content- Parameters:
query- The query string to execute.facetValues- The facet values.- Returns:
- The search results.
- Throws:
Exception- if an error occurs.
-
_searcher
private SearcherFactory.Searcher _searcher(String query, Map<String,List<String>> facetValues)
-
_searcher
private SearcherFactory.Searcher _searcher(Query query, Map<String,List<String>> facetValues)
-
getSort
protected List<Sort> getSort()
Get the sort criteria from the specified field names.- Returns:
- The sort criteria.
-
getFacets
protected List<SearchField> getFacets()
Get the facet criteria as a list of SearchField from the specified field names.- Returns:
- The facets as a List of SearchField.
-
_exceptionMessageForEmptySearchField
private String _exceptionMessageForEmptySearchField(String fieldName)
-
-