Package org.ametys.web.frontoffice
Class AbstractSearchGenerator
java.lang.Object
org.apache.avalon.framework.logger.AbstractLogEnabled
org.apache.cocoon.xml.AbstractXMLProducer
org.apache.cocoon.generation.AbstractGenerator
org.apache.cocoon.generation.ServiceableGenerator
org.ametys.web.frontoffice.AbstractSearchGenerator
- All Implemented Interfaces:
- SolrFieldNames,- SolrWebFieldNames,- Poolable,- Recyclable,- Disposable,- Component,- Contextualizable,- LogEnabled,- Serviceable,- Generator,- SitemapModelComponent,- XMLProducer
- Direct Known Subclasses:
- SearchGenerator,- SearchResourcesGenerator
public abstract class AbstractSearchGenerator
extends ServiceableGenerator
implements Contextualizable, SolrWebFieldNames
Abstract class for solr search
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionprotected classFacet field for an attributeprotected classFacet field for content typesprotected static interfaceInterface representing a facet field
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected ContentTypesHelperThe helper to handler content typesprotected ContextThe cocoon contextprotected ContentTypeExtensionPointTheContentTypemanagerprotected AmetysObjectResolverThe Ametys resolverprotected FrontOfficeSearcherFactoryThe searcher factoryprotected ContentSearchHelperThe content searcherprotected SiteManagerThe sites managerprotected TagProviderExtensionPointThe tag extension pointprotected static final PatternTextfield patternprotected URIResolverExtensionPointThe uri resolver extension pointstatic final StringThe name of the facet.query testing the pageResourcesFields inherited from class org.apache.cocoon.generation.ServiceableGeneratormanagerFields inherited from class org.apache.cocoon.generation.AbstractGeneratorobjectModel, parameters, resolver, sourceFields inherited from class org.apache.cocoon.xml.AbstractXMLProducercontentHandler, EMPTY_CONTENT_HANDLER, lexicalHandler, xmlConsumerFields inherited from interface org.ametys.cms.content.indexing.solr.SolrFieldNamesACL_INIT_VALUE_ALLOWED_GROUPS, ACL_INIT_VALUE_ALLOWED_USERS, ACL_INIT_VALUE_ANONYMOUS, ACL_INIT_VALUE_ANYCONNECTED, ACL_INIT_VALUE_DENIED_GROUPS, ACL_INIT_VALUE_DENIED_USERS, ALL_CONTENT_TYPES, ALL_MIXIN_TYPES, ALL_TAGS, ATTACHMENT_CONTENT_ID, CONTENT_COMMENTS_NONVALIDATED, CONTENT_COMMENTS_VALIDATED, CONTENT_CREATOR, CONTENT_FIRST_VALIDATOR, CONTENT_LANGUAGE, CONTENT_LANGUAGES, CONTENT_LAST_CONTRIBUTOR, CONTENT_LAST_MAJOR_VALIDATOR, CONTENT_LAST_VALIDATOR, CONTENT_NAME, CONTENT_OUTGOING_REFEERENCES_RESOURCE_IDS, CONTENT_TITLES, CONTENT_TYPE_RESOURCE, CONTENT_TYPES, CONTENT_VISIBLE_ATTACHMENT_RESOURCE_IDS, CREATION_DATE, DC_CONTRIBUTOR, DC_COVERAGE, DC_CREATOR, DC_DATE, DC_DESCRIPTION, DC_FORMAT, DC_IDENTIFIER, DC_LANGUAGE, DC_PUBLISHER, DC_RELATION, DC_RIGHTS, DC_SOURCE, DC_SUBJECT, DC_TITLE, DC_TYPE, DOCUMENT_TYPE, EXACT_WS_OPERATOR, EXCERPT, FILENAME, FULL, ID, ID_DV, IS_AMETYS_OBJECT, LANGUAGE_SEPARATOR, LAST_MODIFIED, LENGTH, MIME_TYPES, MIXIN_TYPES, PATH, PSEUDO_CONTENT_TYPE_VALUE_RESOURCE, PSEUDO_CONTENT_TYPES, REPEATER_ENTRY_POSITION, RESOURCE_ANCESTOR_AND_SELF_IDS, RESOURCE_ANCESTOR_IDS, RESOURCE_CREATOR, RESOURCE_DATE, RESOURCE_LAST_MODIFIED, RESOURCE_MIME_TYPE_GROUP, RESOURCE_ROOT_ID, SIMPLE_CONTENT_PARENTS, STEMMED_OPERATOR, SUB_CONTENT, SYSTEM_FULL, TAGS, TITLE, TITLE_SORT, TYPE_CONTENT, TYPE_CONTENT_ATTACHMENT_RESOURCE, TYPE_CONTENT_ATTRIBUTE_RESOURCE, TYPE_REPEATER, TYPE_RESOURCE, TYPE_WF_ENTRY, TYPE_WF_STEP, WORKFLOW_CURRENT_STEPS, WORKFLOW_CURRENT_STEPS_DV, WORKFLOW_ENTRY_STATE, WORKFLOW_HISTORY_STEPS, WORKFLOW_HISTORY_STEPS_DV, WORKFLOW_NAME, WORKFLOW_REF, WORKFLOW_REF_DV, WORKFLOW_STEP_ACTIONID, WORKFLOW_STEP_CALLER, WORKFLOW_STEP_DUEDATE, WORKFLOW_STEP_FINISHDATE, WORKFLOW_STEP_ID, WORKFLOW_STEP_OWNER, WORKFLOW_STEP_STARTDATE, WORKFLOW_STEP_STATUSFields inherited from interface org.ametys.web.indexing.solr.SolrWebFieldNamesATTACHMENT_PAGE_ID, CONTENT_IDS, CONTENT_INTERESTING_DATES, DATE_FOR_SORTING, DATES_FACET, FACETABLE_CONTENT_FIELD_PREFIX, LASTNAME_FOR_SORTING, PAGE_ANCESTOR_IDS, PAGE_CONTENT_TYPES, PAGE_DEPTH, PAGE_IDS, PAGE_LONG_TITLE, PAGE_OUTGOING_REFEERENCES_RESOURCE_IDS, PAGE_PARENT_ID, PAGE_TITLE, PAGE_TYPE, PAGE_VISIBLE_ATTACHMENT_RESOURCE_IDS, SECTION_PAGE_TITLE, SERVICE_IDS, SHARED, SITE_NAME, SITE_TYPE, SITEMAP_NAME, TEMPLATE, TYPE_PAGE, TYPE_PAGE_RESOURCE
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionprotected voidAllow to perform other searcher configurationprotected booleantrueto check rights during searchvoidcontextualize(Context context) voidgenerate()protected abstract Collection<String>getDocumentTypes(Request request) Get the document types.protected QuerygetDocumentTypesQuery(Collection<String> documentTypes) Build the search query to have results matching at least one of the given document typesprotected abstract Map<String,AbstractSearchGenerator.FacetField> Get the facets from request parametersgetFacetValues(Request request, Collection<String> siteNames, String language) Get the facet valuesprotected abstract Collection<Query>getFilterQueries(Request request, Collection<String> siteNames, String language) Get the filter queries from the request parameters.protected intgetPageIndex(Request request) Get the page indexgetPrimarySortFields(Request request) Get the primary sort fieldsprotected abstract QuerygetQuery(Request request, Collection<String> siteNames, String language) Get the query from request parametersprotected abstract Set<FrontOfficeSearcherFactory.QueryFacet>getQueryFacets(Request request) Get the facet.queriesprotected abstract Collection<String>getQueryFacetValues(Request request) Get the facet.query valuesprotected StringGet the search mode.protected abstract SortgetSortField(Request request) Get the sort fieldprotected ZoneItemgetZoneItem(Request request) Get the zone itemprotected booleanCheck if the input is valid.protected voidGenerate any additional information.protected voidSAX additional information on page hitprotected voidsaxContent(String contentId, String viewName, Locale defaultLocale) SAX the view of a content if existsprotected voidsaxFacets(Request request, SearchResults<AmetysObject> searchResults, String siteName, String lang) SAX the facets resultsprotected abstract voidsaxFormFields(Request request, String siteName, String lang) SAX the form search criteriaprotected voidsaxFormParameters(Request request, SearchResults<AmetysObject> searchResults, int start, int offset, String siteName, String lang) SAX the search parameters from the request parametersprotected abstract voidsaxFormValues(Request request, int start, int offset) SAX the form search criteria valuesprotected abstract voidsaxHits(SearchResults<AmetysObject> results, int start, int maxResults) SAX the result hitsprotected voidsaxPageHit(float score, float maxScore, Page page) SAX a hit of type page.protected voidsaxPagination(long totalHits, int start, int offset) SAX elements for paginationprotected voidsaxResourceHit(float score, float maxScore, Resource resource) SAX a hit of type "resource".protected voidsaxRichTextExcerpt(String attributePath, String contentId, RichText richText) SAX excerpt for rich textprotected voidGenerate the service identifiers: service group ID, ZoneItem ID, ...protected voidSAX sortprotected SearchResults<AmetysObject>search(Request request, Collection<String> siteNames, String language, int pageIndex, int start, int maxResults) Searchprotected SearchResults<AmetysObject>search(Request request, Collection<String> siteNames, String language, int pageIndex, int start, int maxResults, boolean saxResults) Searchvoidservice(ServiceManager smanager) protected booleanTemplate methods to disable/enable the processing of the facets during the search.Methods inherited from class org.apache.cocoon.generation.ServiceableGeneratordisposeMethods inherited from class org.apache.cocoon.generation.AbstractGeneratorrecycle, setupMethods inherited from class org.apache.cocoon.xml.AbstractXMLProducersetConsumer, setContentHandler, setLexicalHandlerMethods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabledenableLogging, getLogger, setupLogger, setupLogger, setupLoggerMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.cocoon.xml.XMLProducersetConsumer
- 
Field Details- 
DOCUMENT_TYPE_IS_PAGE_RESOURCE_FACET_NAMEThe name of the facet.query testing the pageResources- See Also:
 
- 
_TEXTFIELD_PATTERNTextfield pattern
- 
_cTypeExtPtTheContentTypemanager
- 
_siteManagerThe sites manager
- 
_contextThe cocoon context
- 
_tagExtPtThe tag extension point
- 
_resolverThe Ametys resolver
- 
_contentTypesHelperThe helper to handler content types
- 
_uriResolverEPThe uri resolver extension point
- 
_searcherFactoryThe searcher factory
- 
_searchHelperThe content searcher
 
- 
- 
Constructor Details- 
AbstractSearchGeneratorpublic AbstractSearchGenerator()
 
- 
- 
Method Details- 
service- Specified by:
- servicein interface- Serviceable
- Overrides:
- servicein class- ServiceableGenerator
- Throws:
- ServiceException
 
- 
contextualize- Specified by:
- contextualizein interface- Contextualizable
- Throws:
- ContextException
 
- 
generate- Specified by:
- generatein interface- Generator
- Throws:
- IOException
- SAXException
- ProcessingException
 
- 
getZoneItemGet the zone item- Parameters:
- request- The request
- Returns:
- the zone item
 
- 
searchprotected SearchResults<AmetysObject> search(Request request, Collection<String> siteNames, String language, int pageIndex, int start, int maxResults) throws Exception Search- Parameters:
- request- the request
- siteNames- The name of the sites to search in
- language- The language code to search
- pageIndex- the page index
- start- The offset for search results
- maxResults- The maximum number of results
- Returns:
- The search results
- Throws:
- Exception- If an error occurred during search
 
- 
searchprotected SearchResults<AmetysObject> search(Request request, Collection<String> siteNames, String language, int pageIndex, int start, int maxResults, boolean saxResults) throws Exception Search- Parameters:
- request- the request
- siteNames- The name of the sites to search in
- language- The language code to search
- pageIndex- the page index
- start- The offset for search results
- maxResults- The maximum number of results
- saxResults- false to not sax results
- Returns:
- The search results
- Throws:
- Exception- If an error occurred during search
 
- 
saxSortSAX sort- Parameters:
- sort- the current sort
- Throws:
- SAXException- SAXException If an error occurs while SAXing
 
- 
_additionalSearchProcessingAllow to perform other searcher configuration- Parameters:
- searcher- The searcher that will be used for the search operation
 
- 
getDocumentTypesQueryBuild the search query to have results matching at least one of the given document types- Parameters:
- documentTypes- The document types
- Returns:
- The document type query
 
- 
getDocumentTypesGet the document types.- Parameters:
- request- The request.
- Returns:
- the document types to search.
 
- 
getSortFieldGet the sort field- Parameters:
- request- The request
- Returns:
- The sort field or null to sort by score
 
- 
getPrimarySortFieldsGet the primary sort fields- Parameters:
- request- The request
- Returns:
- the list additional sort fields or empty list.
 
- 
saxFormParametersprotected void saxFormParameters(Request request, SearchResults<AmetysObject> searchResults, int start, int offset, String siteName, String lang) throws SAXException SAX the search parameters from the request parameters- Parameters:
- request- The request
- searchResults- The search results
- start- The start index
- offset- The number of results
- siteName- The current site name
- lang- The current language
- Throws:
- SAXException- If an error occurs while SAXing
 
- 
saxFormFieldsprotected abstract void saxFormFields(Request request, String siteName, String lang) throws SAXException SAX the form search criteria- Parameters:
- request- The request
- siteName- The current site name
- lang- The current language
- Throws:
- SAXException- if an error occurs while SAXing
 
- 
saxFacetsprotected void saxFacets(Request request, SearchResults<AmetysObject> searchResults, String siteName, String lang) throws SAXException SAX the facets results- Parameters:
- request- The request
- searchResults- The search result
- siteName- The site name
- lang- The language
- Throws:
- SAXException- if an error occurred while saxing
 
- 
saxFormValuesSAX the form search criteria values- Parameters:
- request- The request
- start- The start index
- offset- The number of results
- Throws:
- SAXException- if an error occurs while SAXing
 
- 
getQueryprotected abstract Query getQuery(Request request, Collection<String> siteNames, String language) throws IllegalArgumentException Get the query from request parameters- Parameters:
- request- The request
- siteNames- The site names.
- language- The language
- Returns:
- The query object.
- Throws:
- IllegalArgumentException- If the search field is invalid.
 
- 
getFilterQueriesprotected abstract Collection<Query> getFilterQueries(Request request, Collection<String> siteNames, String language) throws IllegalArgumentException Get the filter queries from the request parameters.- Parameters:
- request- The request.
- siteNames- The site names.
- language- The language.
- Returns:
- A collection of filter queries.
- Throws:
- IllegalArgumentException- If a search field is invalid.
 
- 
useFacetsTemplate methods to disable/enable the processing of the facets during the search.- Returns:
- trueto enable facets
 
- 
getFacetsprotected abstract Map<String,AbstractSearchGenerator.FacetField> getFacets(Request request) throws IllegalArgumentException Get the facets from request parameters- Parameters:
- request- The request
- Returns:
- The facet fields
- Throws:
- IllegalArgumentException- If the search field is invalid.
 
- 
getQueryFacetsGet the facet.queries- Parameters:
- request- The request
- Returns:
- The facet.queries
- Throws:
- IllegalArgumentException- If the search field is invalid.
 
- 
getFacetValuesprotected abstract Map<String,List<String>> getFacetValues(Request request, Collection<String> siteNames, String language) Get the facet values- Parameters:
- request- The request
- siteNames- The site names
- language- The language
- Returns:
- The facet values
 
- 
getQueryFacetValuesGet the facet.query values- Parameters:
- request- The request
- Returns:
- The facet.query values
 
- 
saxHitsprotected abstract void saxHits(SearchResults<AmetysObject> results, int start, int maxResults) throws SAXException, IOException SAX the result hits- Parameters:
- results- The search results.
- start- The start index
- maxResults- The number of results to generate.
- Throws:
- SAXException- If an error occurs while SAXing
- IOException- If there is a low-level IO error
 
- 
saxPageHitSAX a hit of type page.- Parameters:
- score- The score of the page
- maxScore- The maximum score of the search results
- page- The page
- Throws:
- SAXException- If an error occurs while SAXing
 
- 
saxAdditionalInfosOnPageHitSAX additional information on page hit- Parameters:
- page- the page
- Throws:
- SAXException- if something goes wrong when saxing the information
 
- 
saxResourceHitSAX a hit of type "resource".- Parameters:
- score- The score of the page
- maxScore- The maximum score of the search results
- resource- The resource
- Throws:
- SAXException- If an error occurs while SAXing
 
- 
saxPaginationSAX elements for pagination- Parameters:
- totalHits- The total number of result
- start- The start index of search
- offset- The max number of results per page
- Throws:
- SAXException- SAXException If an error occurs while SAXing
 
- 
getPageIndexGet the page index- Parameters:
- request- The request
- Returns:
- The page index
 
- 
saxServiceIdentifiersGenerate the service identifiers: service group ID, ZoneItem ID, ...- Throws:
- SAXException- if an error occurs SAXing data.
- IOException- if an error occurs SAXing data.
- ProcessingException- if a processing error occurs.
 
- 
saxAdditionalInfosGenerate any additional information.- Throws:
- SAXException- if an error occurs SAXing data.
- IOException- if an error occurs SAXing data.
- ProcessingException- if a processing error occurs.
 
- 
getSearchModeGet the search mode.- Returns:
- the search mode as a string.
 
- 
isInputValidCheck if the input is valid.- Returns:
- true if the input is valid, false otherwise.
 
- 
saxContentprotected void saxContent(String contentId, String viewName, Locale defaultLocale) throws SAXException SAX the view of a content if exists- Parameters:
- contentId- the id of the content
- viewName- The name of view to sax
- defaultLocale- The locale to use to sax localized values such as multilingual content or multilingual string. Only use if initial content's language is not null.
- Throws:
- SAXException- if an exception occurs while saxing
 
- 
saxRichTextExcerptSAX excerpt for rich text- Parameters:
- attributePath- The path of attribute
- contentId- The content id
- richText- The rich text
 
- 
_checkRightstrueto check rights during search- Returns:
- trueto check rights during search
 
 
-