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.
-
-
Constructor Summary
Constructors Constructor Description SimpleContentSearcher(Collection<String> contentTypes)
Build a content searcher on a list of content types.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ContentSearcherFactory.SimpleContentSearcher
addSort(String fieldRef, Sort.Order order)
Add a sort criterion.protected List<SearchField>
getFacets()
Get the facet criteria as a list of SearchField from the specified field names.protected List<Sort>
getSort()
Get the sort criteria from the specified field names.<C extends Content>
AmetysObjectIterable<C>search(String query)
Search the contents.<C extends Content>
AmetysObjectIterable<C>search(Query query)
Search the contents.<C extends Content>
SearchResults<C>searchWithFacets(String query)
Search the contents.<C extends Content>
SearchResults<C>searchWithFacets(String query, Map<String,List<String>> facetValues)
Search the contents.<C extends Content>
SearchResults<C>searchWithFacets(Query query)
Search the contents.<C extends Content>
SearchResults<C>searchWithFacets(Query query, Map<String,List<String>> facetValues)
Search the contents.ContentSearcherFactory.SimpleContentSearcher
setCheckRights(boolean checkRights)
Whether to check rights when searching, false otherwise.ContentSearcherFactory.SimpleContentSearcher
withFacets(String... facets)
Set the facets.ContentSearcherFactory.SimpleContentSearcher
withFacets(Collection<String> facets)
Set the facets.ContentSearcherFactory.SimpleContentSearcher
withFilterQueries(List<Query> filterQueries)
Set the filter queries.ContentSearcherFactory.SimpleContentSearcher
withFilterQueryStrings(List<String> filterQueryStrings)
Set the filter queries.ContentSearcherFactory.SimpleContentSearcher
withLimits(int start, int maxResults)
Set the limits to use.ContentSearcherFactory.SimpleContentSearcher
withSort(List<Sort> sortCriteria)
Set the sort criteria.
-
-
-
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
-true
to check rights,false
otherwise.- 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
AmetysObject
s. - 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
AmetysObject
s. - 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.
-
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.
-
-