public class SearchGenerator extends AbstractSearchGenerator
| Modifier and Type | Class and Description | 
|---|---|
protected static class  | 
SearchGenerator.ContentTypeSearch
Enumeration for content type search 
 | 
(package private) static class  | 
SearchGenerator.ContentTypeSearchField  | 
AbstractSearchGenerator.ContentTypeFacetField, AbstractSearchGenerator.FacetField, AbstractSearchGenerator.MetadataFacetField| Modifier and Type | Field and Description | 
|---|---|
private static String | 
__FACETS_CACHE  | 
protected QueryAdapterFOSearchExtensionPoint | 
_queryAdapterFOSearchEP
The query adapter extension point 
 | 
protected SiteTypesExtensionPoint | 
_siteTypeEP
The site type manager 
 | 
_contentHelper, _contentTypesHelper, _context, _cTypeExtPt, _dcProvider, _metadataManager, _resolver, _searcherFactory, _searchHelper, _siteManager, _tagExtPt, _TEXTFIELD_PATTERN, _uriResolverEP, DOCUMENT_TYPE_IS_PAGE_RESOURCE_FACET_NAMEmanagerobjectModel, parameters, resolver, sourcecontentHandler, EMPTY_CONTENT_HANDLER, lexicalHandler, xmlConsumerATTACHMENT_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_RESOURCEACL_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 | 
|---|
SearchGenerator()  | 
| Modifier and Type | Method and Description | 
|---|---|
protected void | 
_additionalSearchProcessing(SearcherFactory.Searcher searcher)
Allow to perform other searcher configuration 
 | 
protected void | 
_addMetadataFacet(Map<String,AbstractSearchGenerator.FacetField> facets,
                 Collection<String> contentTypes,
                 String metadataPath)
Add metadata facet to facets map 
 | 
private String | 
_buildSubQuery(Query subQuery)  | 
private String | 
_escapedTextForSearch(String value)  | 
private String | 
_escapeQueryCharsButNotQuotes(String text)  | 
private Set<String> | 
_getAllContentTypes()  | 
private Collection<String> | 
_getAvailableContentTypes(Request request)  | 
private Expression | 
_getContentTypeExpression(String parentCTypeId)  | 
private Map<String,Integer> | 
_getFacetQueryResults(SearchResults<AmetysObject> results)  | 
private int | 
_getNbResource(Map<String,Integer> facetQueryResults)  | 
private SearchResults<AmetysObject> | 
_getResultsForContentType(Query queryObject,
                         Collection<Query> filterQueries,
                         Collection<SearchField> facets,
                         List<Sort> sorts,
                         Map<String,List<String>> initialFacetValues,
                         String forceContentType)  | 
private List<QueryAdapterFOSearch> | 
_getSortedListQueryAdapter()  | 
protected Query | 
_getStringMetadataQuery(String language,
                       String metadataPath,
                       String value,
                       MetadataDefinition metadataDefinition)
Get query from string metadata 
 | 
private void | 
_handleFacetResults(Request request,
                   int start,
                   int maxResults,
                   SearchResults<AmetysObject> results,
                   String currentCtype)  | 
private boolean | 
_isPrivate(Site site)  | 
private void | 
_saxAllWords(Request request)  | 
private void | 
_saxContentType(Request request)  | 
private void | 
_saxContentTypeCriteria(Request request)  | 
private void | 
_saxDates(Request request)  | 
private void | 
_saxExactWording(Request request)  | 
private void | 
_saxMetadataCriteria(Request request,
                    String language)  | 
private void | 
_saxMetadataValues(Request request)  | 
private void | 
_saxMultisite(Request request)  | 
private void | 
_saxNoWords(Request request)  | 
private void | 
_saxPages(Request request)  | 
private void | 
_saxSitemapCriteria()  | 
private void | 
_saxTag(Tag tag,
       boolean recursive)  | 
private void | 
_saxTags(Request request)  | 
private void | 
_saxTagsCriteria(String siteName)  | 
private void | 
_saxTextField(Request request)  | 
private LocalDate | 
_toDate(String dateStr)  | 
protected void | 
addAllWordsTextFieldQuery(Collection<Query> queries,
                         String language,
                         Request request)
Add content query for "all words" 
 | 
protected void | 
addContentTypeQuery(Collection<Query> queries,
                   Request request)
Add the content type query 
 | 
protected void | 
addDateQuery(Collection<Query> queries,
            Request request)
Add the query on start and end dates 
 | 
protected void | 
addExactWordingTextFieldQuery(Collection<Query> queries,
                             String language,
                             Request request)
Add content query for exact wording or phrase 
 | 
protected void | 
addMetadataQuery(Collection<Query> queries,
                String language,
                Request request)
Add query for each metadata 
 | 
protected void | 
addNoWordsTextFieldQuery(Collection<Query> queries,
                        String language,
                        Request request)
Add content query for "none of these words" 
 | 
protected void | 
addPagesQuery(Collection<Query> queries,
             Request request)
Add the pages query 
 | 
protected void | 
addTagsQuery(Collection<Query> queries,
            Request request)
Add the tags query 
 | 
protected void | 
addTextFieldQuery(Collection<Query> queries,
                 String language,
                 Request request)
Add the text field query 
 | 
protected List<Query> | 
getContentQueries(Request request,
                 Collection<String> siteNames,
                 String language)
Get the queries to be apply on joined contents ONLY 
 | 
protected List<Query> | 
getContentResourcesOrAttachmentQueries(Query subQuery)
Get the queries for content's attachments and resources 
 | 
protected String | 
getContentTypeFilterValue(Request request)
Get the content type's filter value 
 | 
protected Collection<String> | 
getContentTypes(Request request)
Get the content type's 
 | 
protected SearchGenerator.ContentTypeSearch | 
getContentTypeSearch(Request request)
Return the type of content type's search 
 | 
protected Map<String,String> | 
getContentValues(String cTypeId,
                String language)
Get values for contents enumeration 
 | 
protected Collection<String> | 
getDocumentTypes(Request request)
Get the document types. 
 | 
protected Map<String,AbstractSearchGenerator.FacetField> | 
getFacets(Request request)
Get the facets from request parameters 
 | 
protected Map<String,List<String>> | 
getFacetValues(Request request,
              Collection<String> siteNames,
              String language)
Get the facet values 
 | 
protected Collection<String> | 
getFields()
Get the searchable fields 
 | 
protected Collection<Query> | 
getFilterQueries(Request request,
                Collection<String> siteNames,
                String language)
Get the filter queries from the request parameters. 
 | 
protected Collection<Query> | 
getFixedCTypeFilterQueries(Request request,
                          String cType,
                          Collection<String> siteNames,
                          String language)
Get the filter queries for a single fixed content type. 
 | 
protected List<Query> | 
getPageQueries(Request request,
              Collection<String> siteNames,
              String language)
Get the queries to be apply on pages ONLY 
 | 
protected List<Query> | 
getPageResourcesOrAttachmentQueries(Query subQuery)
Get the queries for page's attachments and resources 
 | 
protected List<Sort> | 
getPrimarySortFields(Request request)
Get the primary sort fields 
 | 
protected Query | 
getQuery(Request request,
        Collection<String> siteNames,
        String language)
Get the query from request parameters 
 | 
protected Set<FrontOfficeSearcherFactory.QueryFacet> | 
getQueryFacets(Request request)
Get the facet.queries 
 | 
protected Collection<String> | 
getQueryFacetValues(Request request)
Get the facet.query values 
 | 
protected Sort | 
getSortField(Request request)
Get the sort field 
 | 
protected List<Query> | 
getWordingQueries(Request request,
                 Collection<String> siteNames,
                 String language)
Get the queries on wording (keywords, no words, exact wording, no words) 
 | 
protected void | 
saxEnumeratorValueForMetadata(MetadataDefinition metadataDef,
                             String metadataPath,
                             String language)
Sax enumeration value for enum or a content metadata 
 | 
protected void | 
saxFormFields(Request request,
             String siteName,
             String lang)
SAX the form search criteria 
 | 
protected void | 
saxFormValues(Request request,
             int start,
             int offset)
SAX the form search criteria values 
 | 
protected void | 
saxHits(SearchResults<AmetysObject> results,
       int start,
       int maxResults)
SAX the result hits 
 | 
protected void | 
saxMetadataDef(MetadataDefinition metadataDef,
              String metadataPath,
              String language)
Sax metadata set information for metadata 
 | 
protected SearchResults<AmetysObject> | 
search(Request request,
      Collection<String> siteNames,
      String language,
      int pageIndex,
      int start,
      int maxResults)
Search 
 | 
void | 
service(ServiceManager smanager)  | 
contextualize, generate, getDocumentTypesQuery, getPageIndex, getSearchMode, getZoneItem, isInputValid, saxAdditionalInfos, saxAdditionalInfosOnPageHit, saxContent, saxFacets, saxFormParameters, saxPageHit, saxPagination, saxResourceHit, saxRichTextExcerpt, saxServiceIdentifiers, saxSort, search, useFacetsdisposerecycle, setupsetConsumer, setContentHandler, setLexicalHandlerenableLogging, getLogger, setupLogger, setupLogger, setupLoggerclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitsetConsumerprivate static final String __FACETS_CACHE
protected QueryAdapterFOSearchExtensionPoint _queryAdapterFOSearchEP
protected SiteTypesExtensionPoint _siteTypeEP
public SearchGenerator()
public void service(ServiceManager smanager) throws ServiceException
service in interface Serviceableservice in class AbstractSearchGeneratorServiceExceptionprotected SearchGenerator.ContentTypeSearch getContentTypeSearch(Request request)
request - The requestprotected SearchResults<AmetysObject> search(Request request, Collection<String> siteNames, String language, int pageIndex, int start, int maxResults) throws Exception
AbstractSearchGeneratorsearch in class AbstractSearchGeneratorrequest - 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 searchprivate Map<String,Integer> _getFacetQueryResults(SearchResults<AmetysObject> results)
private int _getNbResource(Map<String,Integer> facetQueryResults)
private SearchResults<AmetysObject> _getResultsForContentType(Query queryObject, Collection<Query> filterQueries, Collection<SearchField> facets, List<Sort> sorts, Map<String,List<String>> initialFacetValues, String forceContentType) throws Exception
Exceptionprotected void _additionalSearchProcessing(SearcherFactory.Searcher searcher)
AbstractSearchGenerator_additionalSearchProcessing in class AbstractSearchGeneratorsearcher - The searcher that will be used for the search operationprivate void _handleFacetResults(Request request, int start, int maxResults, SearchResults<AmetysObject> results, String currentCtype) throws SAXException, IOException
SAXExceptionIOExceptionprotected Query getQuery(Request request, Collection<String> siteNames, String language) throws IllegalArgumentException
AbstractSearchGeneratorgetQuery in class AbstractSearchGeneratorrequest - The requestsiteNames - The site names.language - The languageIllegalArgumentException - If the search field is invalid.protected List<Query> getWordingQueries(Request request, Collection<String> siteNames, String language)
request - the requestsiteNames - the site nameslanguage - the languageprotected List<Query> getContentQueries(Request request, Collection<String> siteNames, String language)
request - the requestsiteNames - the site nameslanguage - the languageprotected List<Query> getPageQueries(Request request, Collection<String> siteNames, String language)
request - the requestsiteNames - the site nameslanguage - the languageprotected Collection<Query> getFilterQueries(Request request, Collection<String> siteNames, String language) throws IllegalArgumentException
AbstractSearchGeneratorgetFilterQueries in class AbstractSearchGeneratorrequest - The request.siteNames - The site names.language - The language.IllegalArgumentException - If a search field is invalid.protected Map<String,List<String>> getFacetValues(Request request, Collection<String> siteNames, String language) throws IllegalArgumentException
AbstractSearchGeneratorgetFacetValues in class AbstractSearchGeneratorrequest - The requestsiteNames - The site nameslanguage - The languageIllegalArgumentExceptionprotected Collection<String> getQueryFacetValues(Request request)
AbstractSearchGeneratorgetQueryFacetValues in class AbstractSearchGeneratorrequest - The requestprotected Map<String,AbstractSearchGenerator.FacetField> getFacets(Request request) throws IllegalArgumentException
AbstractSearchGeneratorgetFacets in class AbstractSearchGeneratorrequest - The requestIllegalArgumentException - If the search field is invalid.protected void _addMetadataFacet(Map<String,AbstractSearchGenerator.FacetField> facets, Collection<String> contentTypes, String metadataPath)
facets - the facets mapcontentTypes - the content typesmetadataPath - the metadata pathprotected Set<FrontOfficeSearcherFactory.QueryFacet> getQueryFacets(Request request)
AbstractSearchGeneratorgetQueryFacets in class AbstractSearchGeneratorrequest - The requestprotected Collection<Query> getFixedCTypeFilterQueries(Request request, String cType, Collection<String> siteNames, String language)
request - The request.cType - The fixed content type.siteNames - the site names.language - The language.protected Collection<String> getDocumentTypes(Request request)
AbstractSearchGeneratorgetDocumentTypes in class AbstractSearchGeneratorrequest - The request.protected Collection<String> getFields()
AbstractSearchGeneratorgetFields in class AbstractSearchGeneratorprotected void saxHits(SearchResults<AmetysObject> results, int start, int maxResults) throws SAXException, IOException
AbstractSearchGeneratorsaxHits in class AbstractSearchGeneratorresults - 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 Sort getSortField(Request request)
AbstractSearchGeneratorgetSortField in class AbstractSearchGeneratorrequest - The requestprotected List<Sort> getPrimarySortFields(Request request)
AbstractSearchGeneratorgetPrimarySortFields in class AbstractSearchGeneratorrequest - The requestprotected void saxFormFields(Request request, String siteName, String lang) throws SAXException
AbstractSearchGeneratorsaxFormFields in class AbstractSearchGeneratorrequest - The requestsiteName - The current site namelang - The current languageSAXException - if an error occurs while SAXingprivate boolean _isPrivate(Site site)
private void _saxMetadataCriteria(Request request, String language) throws SAXException
SAXExceptionprotected void saxMetadataDef(MetadataDefinition metadataDef, String metadataPath, String language) throws SAXException
metadataDef - The metadata definition.metadataPath - The metadata pathlanguage - The current languageSAXException - If an error occurred while saxingprotected void saxEnumeratorValueForMetadata(MetadataDefinition metadataDef, String metadataPath, String language) throws SAXException
metadataDef - The metadata definition.metadataPath - The metadata pathlanguage - The current languageSAXException - If an error occurred while saxingprotected Map<String,String> getContentValues(String cTypeId, String language)
cTypeId - The id of content typelanguage - The current languageprivate Expression _getContentTypeExpression(String parentCTypeId)
protected void saxFormValues(Request request, int start, int offset) throws SAXException
AbstractSearchGeneratorsaxFormValues in class AbstractSearchGeneratorrequest - The requeststart - The start indexoffset - The number of resultsSAXException - if an error occurs while SAXingprivate void _saxDates(Request request) throws SAXException
SAXExceptionprivate void _saxTextField(Request request) throws SAXException
SAXExceptionprivate void _saxMetadataValues(Request request) throws SAXException
SAXExceptionprivate void _saxAllWords(Request request) throws SAXException
SAXExceptionprivate void _saxExactWording(Request request) throws SAXException
SAXExceptionprivate void _saxNoWords(Request request) throws SAXException
SAXExceptionprivate void _saxContentType(Request request) throws SAXException
SAXExceptionprivate void _saxTags(Request request) throws SAXException
SAXExceptionprivate void _saxPages(Request request) throws SAXException
SAXExceptionprivate void _saxMultisite(Request request) throws SAXException
SAXExceptionprotected Collection<String> getContentTypes(Request request)
request - The requestprivate Collection<String> _getAvailableContentTypes(Request request)
private Set<String> _getAllContentTypes()
private void _saxContentTypeCriteria(Request request) throws SAXException
SAXExceptionprivate void _saxTagsCriteria(String siteName) throws SAXException
SAXExceptionprivate void _saxTag(Tag tag, boolean recursive) throws SAXException
SAXExceptionprivate void _saxSitemapCriteria() throws SAXException
SAXExceptionprotected String getContentTypeFilterValue(Request request)
request - The requestprotected void addTextFieldQuery(Collection<Query> queries, String language, Request request)
queries - the querieslanguage - the languagerequest - the requestprotected List<Query> getContentResourcesOrAttachmentQueries(Query subQuery)
subQuery - the query for attachments and resourcesprotected List<Query> getPageResourcesOrAttachmentQueries(Query subQuery)
subQuery - the query for attachments and resourcesprivate String _buildSubQuery(Query subQuery) throws QuerySyntaxException
QuerySyntaxExceptionprivate String _escapeQueryCharsButNotQuotes(String text)
protected void addMetadataQuery(Collection<Query> queries, String language, Request request) throws IllegalArgumentException
queries - The list of querylanguage - The langrequest - The requestIllegalArgumentException - If an error occurredprotected Query _getStringMetadataQuery(String language, String metadataPath, String value, MetadataDefinition metadataDefinition)
language - the languagemetadataPath - the metadata pathvalue - the valuemetadataDefinition - the metadata definitionprivate String _escapedTextForSearch(String value)
protected void addAllWordsTextFieldQuery(Collection<Query> queries, String language, Request request)
queries - The querieslanguage - The current languagerequest - the requestprotected void addExactWordingTextFieldQuery(Collection<Query> queries, String language, Request request)
queries - The querieslanguage - The current languagerequest - the requestprotected void addNoWordsTextFieldQuery(Collection<Query> queries, String language, Request request)
queries - The querieslanguage - The current languagerequest - the requestprotected void addContentTypeQuery(Collection<Query> queries, Request request)
queries - The queriesrequest - The requestprotected void addTagsQuery(Collection<Query> queries, Request request)
queries - The queriesrequest - The requestprotected void addPagesQuery(Collection<Query> queries, Request request)
queries - The queriesrequest - The requestprotected void addDateQuery(Collection<Query> queries, Request request)
queries - The queriesrequest - The requestprivate List<QueryAdapterFOSearch> _getSortedListQueryAdapter()