public abstract class AbstractSearchGenerator extends ServiceableGenerator implements Contextualizable, SolrWebFieldNames
Modifier and Type | Class and Description |
---|---|
protected class |
AbstractSearchGenerator.ContentTypeFacetField
Facet field for content types
|
protected static interface |
AbstractSearchGenerator.FacetField
Interface representing a facet field
|
protected class |
AbstractSearchGenerator.MetadataFacetField
Facet field for a metadata
|
Modifier and Type | Field and Description |
---|---|
protected ContentHelper |
_contentHelper
The helper to handler contents
|
protected ContentTypesHelper |
_contentTypesHelper
The helper to handler content types
|
protected Context |
_context
The cocoon context
|
protected ContentTypeExtensionPoint |
_cTypeExtPt
The
ContentType manager |
protected DublinCoreMetadataProvider |
_dcProvider
DublinCore provider
|
protected MetadataManager |
_metadataManager
Metadata manager.
|
protected AmetysObjectResolver |
_resolver
The Ametys resolver
|
protected FrontOfficeSearcherFactory |
_searcherFactory
The searcher factory
|
protected ContentSearchHelper |
_searchHelper
The content searcher
|
protected SiteManager |
_siteManager
The sites manager
|
protected TagProviderExtensionPoint |
_tagExtPt
The tag extension point
|
protected static Pattern |
_TEXTFIELD_PATTERN
Textfield pattern
|
protected URIResolverExtensionPoint |
_uriResolverEP
The uri resolver extension point
|
static String |
DOCUMENT_TYPE_IS_PAGE_RESOURCE_FACET_NAME
The name of the facet.query testing the pageResources
|
manager
objectModel, parameters, resolver, source
contentHandler, EMPTY_CONTENT_HANDLER, lexicalHandler, xmlConsumer
ATTACHMENT_PAGE_ID, CONTENT_IDS, CONTENT_INTERESTING_DATES, DATE_FOR_SORTING, DATES_FACET, FACETABLE_CONTENT_FIELD_PREFIX, LASTNAME_FOR_SORTING, ORPHAN, 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, PRIVACY, SECTION_PAGE_TITLE, SERVICE_IDS, SHARED, SITE_NAME, SITE_TYPE, SITEMAP_NAME, TEMPLATE, TYPE_PAGE, TYPE_PAGE_RESOURCE
ACL_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, CONTENT_COMMENTS_NONVALIDATED, CONTENT_COMMENTS_VALIDATED, CONTENT_CREATOR, CONTENT_LANGUAGE, CONTENT_LANGUAGES, CONTENT_LAST_CONTRIBUTOR, 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, EXCERPT, FILENAME, FIRST_VALIDATION, FULL_EXACT_WS, FULL_GENERAL, FULL_PREFIX, FULL_STEMMED_PREFIX, ID, IS_AMETYS_OBJECT, LAST_MAJOR_VALIDATION, LAST_MODIFIED, LAST_VALIDATION, 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_ROOT_ID, SIMPLE_CONTENT_PARENTS, SUB_CONTENT, 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, WORKFLOW_STEP_ACTIONID, WORKFLOW_STEP_CALLER, WORKFLOW_STEP_DUEDATE, WORKFLOW_STEP_FINISHDATE, WORKFLOW_STEP_ID, WORKFLOW_STEP_OWNER, WORKFLOW_STEP_STARTDATE, WORKFLOW_STEP_STATUS
Constructor and Description |
---|
AbstractSearchGenerator() |
Modifier and Type | Method and Description |
---|---|
protected void |
_additionalSearchProcessing(SearcherFactory.Searcher searcher)
Allow to perform other searcher configuration
|
private String |
_encodePath(String path) |
private String |
_getResourceExcerpt(Resource resource) |
private Page |
_getResourcePage(Resource resource) |
private void |
_saxIcon(String filename) |
private void |
_saxLastModifiedDate(Page page) |
private void |
_saxLastValidationDate(Page page) |
private void |
_saxPageContents(Page page) |
private void |
_saxSize(long size) |
void |
contextualize(Context context) |
void |
generate() |
protected abstract Collection<String> |
getDocumentTypes(Request request)
Get the document types.
|
protected Query |
getDocumentTypesQuery(Collection<String> documentTypes)
Build the search query to have results matching at least one of the given document types
|
protected abstract Map<String,AbstractSearchGenerator.FacetField> |
getFacets(Request request)
Get the facets from request parameters
|
protected abstract Map<String,List<String>> |
getFacetValues(Request request,
Collection<String> siteNames,
String language)
Get the facet values
|
protected abstract Collection<String> |
getFields()
Get the searchable fields
|
protected abstract Collection<Query> |
getFilterQueries(Request request,
Collection<String> siteNames,
String language)
Get the filter queries from the request parameters.
|
protected int |
getPageIndex(Request request)
Get the page index
|
protected abstract List<Sort> |
getPrimarySortFields(Request request)
Get the primary sort fields
|
protected abstract Query |
getQuery(Request request,
Collection<String> siteNames,
String language)
Get the query from request parameters
|
protected abstract Set<FrontOfficeSearcherFactory.QueryFacet> |
getQueryFacets(Request request)
Get the facet.queries
|
protected abstract Collection<String> |
getQueryFacetValues(Request request)
Get the facet.query values
|
protected String |
getSearchMode()
Get the search mode.
|
protected abstract Sort |
getSortField(Request request)
Get the sort field
|
protected ZoneItem |
getZoneItem(Request request)
Get the zone item
|
protected boolean |
isInputValid()
Check if the input is valid.
|
protected void |
saxAdditionalInfos()
Generate any additional information.
|
protected void |
saxAdditionalInfosOnPageHit(Page page)
SAX additional information on page hit
|
protected void |
saxContent(String contentId,
String metadataSetName,
Locale defaultLocale)
SAX the metadata set of a content if exists
|
protected void |
saxFacets(Request request,
SearchResults<AmetysObject> searchResults,
String siteName,
String lang)
SAX the facets results
|
protected abstract void |
saxFormFields(Request request,
String siteName,
String lang)
SAX the form search criteria
|
protected void |
saxFormParameters(Request request,
SearchResults<AmetysObject> searchResults,
int start,
int offset,
String siteName,
String lang)
SAX the search parameters from the request parameters
|
protected abstract void |
saxFormValues(Request request,
int start,
int offset)
SAX the form search criteria values
|
protected abstract void |
saxHits(SearchResults<AmetysObject> results,
int start,
int maxResults)
SAX the result hits
|
protected void |
saxPageHit(float score,
float maxScore,
Page page)
SAX a hit of type page.
|
protected void |
saxPagination(long totalHits,
int start,
int offset)
SAX elements for pagination
|
protected void |
saxResourceHit(float score,
float maxScore,
Resource resource)
SAX a hit of type "resource".
|
protected void |
saxRichTextExcerpt(String metadataPath,
String contentId,
RichText richText)
SAX excerpt for rich text
|
protected void |
saxServiceIdentifiers()
Generate the service identifiers: service group ID, ZoneItem ID, ...
|
protected void |
saxSort(Sort sort)
SAX sort
|
protected SearchResults<AmetysObject> |
search(Request request,
Collection<String> siteNames,
String language,
int pageIndex,
int start,
int maxResults)
Search
|
protected SearchResults<AmetysObject> |
search(Request request,
Collection<String> siteNames,
String language,
int pageIndex,
int start,
int maxResults,
boolean saxResults)
Search
|
void |
service(ServiceManager smanager) |
protected boolean |
useFacets()
Template methods to disable/enable the processing of the facets during the search.
|
dispose
recycle, setup
setConsumer, setContentHandler, setLexicalHandler
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
setConsumer
public static final String DOCUMENT_TYPE_IS_PAGE_RESOURCE_FACET_NAME
protected static final Pattern _TEXTFIELD_PATTERN
protected ContentTypeExtensionPoint _cTypeExtPt
ContentType
managerprotected SiteManager _siteManager
protected TagProviderExtensionPoint _tagExtPt
protected AmetysObjectResolver _resolver
protected DublinCoreMetadataProvider _dcProvider
protected ContentTypesHelper _contentTypesHelper
protected ContentHelper _contentHelper
protected URIResolverExtensionPoint _uriResolverEP
protected MetadataManager _metadataManager
protected FrontOfficeSearcherFactory _searcherFactory
protected ContentSearchHelper _searchHelper
public AbstractSearchGenerator()
public void service(ServiceManager smanager) throws ServiceException
service
in interface Serviceable
service
in class ServiceableGenerator
ServiceException
public void contextualize(Context context) throws ContextException
contextualize
in interface Contextualizable
ContextException
public void generate() throws IOException, SAXException, ProcessingException
generate
in interface Generator
IOException
SAXException
ProcessingException
protected ZoneItem getZoneItem(Request request)
request
- The requestprotected SearchResults<AmetysObject> search(Request request, Collection<String> siteNames, String language, int pageIndex, int start, int maxResults) throws Exception
request
- the requestsiteNames
- The name of the sites to search inlanguage
- The language code to searchpageIndex
- the page indexstart
- The offset for search resultsmaxResults
- The maximum number of resultsException
- If an error occurred during searchprotected SearchResults<AmetysObject> search(Request request, Collection<String> siteNames, String language, int pageIndex, int start, int maxResults, boolean saxResults) throws Exception
request
- the requestsiteNames
- The name of the sites to search inlanguage
- The language code to searchpageIndex
- the page indexstart
- The offset for search resultsmaxResults
- The maximum number of resultssaxResults
- false to not sax resultsException
- If an error occurred during searchprotected void saxSort(Sort sort) throws SAXException
sort
- the current sortSAXException
- SAXException If an error occurs while SAXingprotected void _additionalSearchProcessing(SearcherFactory.Searcher searcher)
searcher
- The searcher that will be used for the search operationprotected Query getDocumentTypesQuery(Collection<String> documentTypes)
documentTypes
- The document typesprotected abstract Collection<String> getDocumentTypes(Request request)
request
- The request.protected abstract Sort getSortField(Request request)
request
- The requestprotected abstract List<Sort> getPrimarySortFields(Request request)
request
- The requestprotected void saxFormParameters(Request request, SearchResults<AmetysObject> searchResults, int start, int offset, String siteName, String lang) throws SAXException
request
- The requestsearchResults
- The search resultsstart
- The start indexoffset
- The number of resultssiteName
- The current site namelang
- The current languageSAXException
- If an error occurs while SAXingprotected abstract void saxFormFields(Request request, String siteName, String lang) throws SAXException
request
- The requestsiteName
- The current site namelang
- The current languageSAXException
- if an error occurs while SAXingprotected void saxFacets(Request request, SearchResults<AmetysObject> searchResults, String siteName, String lang) throws SAXException
request
- The requestsearchResults
- The search resultsiteName
- The site namelang
- The languageSAXException
- if an error occurred while saxingprotected abstract void saxFormValues(Request request, int start, int offset) throws SAXException
request
- The requeststart
- The start indexoffset
- The number of resultsSAXException
- if an error occurs while SAXingprotected abstract Query getQuery(Request request, Collection<String> siteNames, String language) throws IllegalArgumentException
request
- The requestsiteNames
- The site names.language
- The languageIllegalArgumentException
- If the search field is invalid.protected abstract Collection<Query> getFilterQueries(Request request, Collection<String> siteNames, String language) throws IllegalArgumentException
request
- The request.siteNames
- The site names.language
- The language.IllegalArgumentException
- If a search field is invalid.protected boolean useFacets()
true
to enable facetsprotected abstract Map<String,AbstractSearchGenerator.FacetField> getFacets(Request request) throws IllegalArgumentException
request
- The requestIllegalArgumentException
- If the search field is invalid.protected abstract Set<FrontOfficeSearcherFactory.QueryFacet> getQueryFacets(Request request)
request
- The requestIllegalArgumentException
- If the search field is invalid.protected abstract Map<String,List<String>> getFacetValues(Request request, Collection<String> siteNames, String language)
request
- The requestsiteNames
- The site nameslanguage
- The languageprotected abstract Collection<String> getQueryFacetValues(Request request)
request
- The requestprotected abstract void saxHits(SearchResults<AmetysObject> results, int start, int maxResults) throws SAXException, IOException
results
- The search results.start
- The start indexmaxResults
- The number of results to generate.SAXException
- If an error occurs while SAXingIOException
- If there is a low-level IO errorprotected abstract Collection<String> getFields()
protected void saxPageHit(float score, float maxScore, Page page) throws SAXException
score
- The score of the pagemaxScore
- The maximum score of the search resultspage
- The pageSAXException
- If an error occurs while SAXingprivate void _saxPageContents(Page page) throws SAXException
SAXException
private void _saxLastModifiedDate(Page page) throws SAXException
SAXException
private void _saxLastValidationDate(Page page) throws SAXException
SAXException
protected void saxAdditionalInfosOnPageHit(Page page) throws SAXException
page
- the pageSAXException
- if something goes wrong when saxing the informationprotected void saxResourceHit(float score, float maxScore, Resource resource) throws SAXException
score
- The score of the pagemaxScore
- The maximum score of the search resultsresource
- The resourceSAXException
- If an error occurs while SAXingprivate String _getResourceExcerpt(Resource resource)
private Page _getResourcePage(Resource resource)
private String _encodePath(String path)
protected void saxPagination(long totalHits, int start, int offset) throws SAXException
totalHits
- The total number of resultstart
- The start index of searchoffset
- The max number of results per pageSAXException
- SAXException If an error occurs while SAXingprotected int getPageIndex(Request request)
request
- The requestprivate void _saxIcon(String filename) throws SAXException
SAXException
private void _saxSize(long size) throws SAXException
SAXException
protected void saxServiceIdentifiers() throws SAXException, IOException, ProcessingException
SAXException
- if an error occurs SAXing data.IOException
- if an error occurs SAXing data.ProcessingException
- if a processing error occurs.protected void saxAdditionalInfos() throws SAXException, IOException, ProcessingException
SAXException
- if an error occurs SAXing data.IOException
- if an error occurs SAXing data.ProcessingException
- if a processing error occurs.protected String getSearchMode()
protected boolean isInputValid()
protected void saxContent(String contentId, String metadataSetName, Locale defaultLocale) throws SAXException
contentId
- the id of the contentmetadataSetName
- The name of metadata set to saxdefaultLocale
- 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.SAXException
- if an exception occurs while saxingprotected void saxRichTextExcerpt(String metadataPath, String contentId, RichText richText)
metadataPath
- The path of metadatacontentId
- The content idrichText
- The rich text