Serializable serializable = searchContext.getAttribute(field); (searchContext.getFacet(field) != null)) { value = searchContext.getKeywords(); if (searchContext.isAndSearch()) { query = searchQuery.addRequiredTerm(field, value, like);
private BooleanFilter _getFacetBooleanFilter( String className, SearchContext searchContext) throws Exception { BooleanFilter facetBooleanFilter = new BooleanFilter(); facetBooleanFilter.addTerm(Field.ENTRY_CLASS_NAME, className); if (searchContext.getUserId() > 0) { SearchPermissionChecker searchPermissionChecker = SearchEngineHelperUtil.getSearchPermissionChecker(); facetBooleanFilter = searchPermissionChecker.getPermissionBooleanFilter( searchContext.getCompanyId(), searchContext.getGroupIds(), searchContext.getUserId(), className, facetBooleanFilter, searchContext); } return facetBooleanFilter; }
protected Map<String, Query> addSearchLocalizedTerm( BooleanQuery searchQuery, SearchContext searchContext, String field, boolean like) throws Exception { Map<String, Query> queries = new HashMap<>(); Query query = addSearchTerm(searchQuery, searchContext, field, like); queries.put(field, query); String localizedFieldName = Field.getLocalizedName( searchContext.getLocale(), field); Query localizedQuery = addSearchTerm( searchQuery, searchContext, localizedFieldName, like); queries.put(localizedFieldName, localizedQuery); return queries; }
/** * @deprecated As of Wilberforce (7.0.x), replaced by {@link * IndexSearcherHelperUtil#search(SearchContext, Query)} */ @Deprecated public static Hits search( String searchEngineId, long companyId, Query query, Sort[] sorts, int start, int end) throws SearchException { SearchContext searchContext = new SearchContext(); searchContext.setCompanyId(companyId); searchContext.setEnd(end); searchContext.setSearchEngineId(searchEngineId); searchContext.setSorts(sorts); searchContext.setStart(start); return IndexSearcherHelperUtil.search(searchContext, query); }
public static SearchContext getInstance( long[] assetCategoryIds, String[] assetTagNames, Map<String, Serializable> attributes, long companyId, String keywords, Layout layout, Locale locale, long scopeGroupId, TimeZone timeZone, long userId) { SearchContext searchContext = new SearchContext(); // Theme display searchContext.setCompanyId(companyId); searchContext.setGroupIds(new long[] {scopeGroupId}); searchContext.setLayout(layout); searchContext.setLocale(locale); searchContext.setTimeZone(timeZone); searchContext.setUserId(userId); // Attributes if (attributes != null) { searchContext.setAttributes(attributes); } else { searchContext.setAttributes(new HashMap<String, Serializable>()); } // Asset searchContext.setAssetCategoryIds(assetCategoryIds); searchContext.setAssetTagNames(assetTagNames); // Keywords searchContext.setKeywords(keywords); // Query config QueryConfig queryConfig = searchContext.getQueryConfig(); queryConfig.setLocale(locale); return searchContext; }
@Override public String spellCheckKeywords(SearchContext searchContext) throws SearchException { Map<String, List<String>> suggestions = spellCheckKeywords( searchContext, 1); String localizedFieldName = Field.getLocalizedName( searchContext.getLanguageId(), Field.SPELL_CHECK_WORD); List<String> keywords = TokenizerUtil.tokenize( localizedFieldName, searchContext.getKeywords(), searchContext.getLanguageId()); return CollatorUtil.collate(suggestions, keywords); }
int end, Sort sort) { SearchContext searchContext = new SearchContext(); searchContext.setAndSearch(andSearch); attributes.put("params", params); searchContext.setAttributes(attributes); searchContext.setCompanyId(companyId); searchContext.setEnd(end); searchContext.setFolderIds(folderIds); searchContext.setGroupIds(new long[] {groupId}); searchContext.setIncludeDiscussions( GetterUtil.getBoolean(params.get("includeDiscussions"))); searchContext.setKeywords(keywords); QueryConfig queryConfig = searchContext.getQueryConfig(); searchContext.setSorts(sort); searchContext.setStart(start);
@Override public void indexQuerySuggestionDictionaries( String searchEngineId, long companyId) throws SearchException { SearchEngine searchEngine = _searchEngineHelper.getSearchEngine( searchEngineId); IndexWriter indexWriter = searchEngine.getIndexWriter(); SearchContext searchContext = new SearchContext(); searchContext.setCompanyId(companyId); searchContext.setSearchEngineId(searchEngineId); indexWriter.indexQuerySuggestionDictionaries(searchContext); }
_request); searchContext.setAttribute("paginationType", "more"); searchContext.setCategoryIds(categoryIdsArray); searchContext.setEnd(searchContainer.getEnd()); searchContext.setIncludeAttachments(true); searchContext.setKeywords(keywords); searchContext.setSorts(sort); searchContext.setStart(searchContainer.getStart());
protected SearchContext buildSearchContext( long groupId, long userId, long creatorUserId, int status, int start, int end) throws PortalException { SearchContext searchContext = new SearchContext(); searchContext.setAttribute(Field.STATUS, status); searchContext.setAttribute("paginationType", "none"); if (creatorUserId > 0) { searchContext.setAttribute( Field.USER_ID, String.valueOf(creatorUserId)); } Group group = groupLocalService.getGroup(groupId); searchContext.setCompanyId(group.getCompanyId()); searchContext.setEnd(end); searchContext.setGroupIds(new long[] {groupId}); searchContext.setSorts(new Sort(Field.MODIFIED_DATE, true)); searchContext.setStart(start); searchContext.setUserId(userId); return searchContext; }
request); searchContext.setAttribute("paginationType", "more"); searchContext.setGroupIds(null); searchContext.setGroupIds(new long[] {groupId}); searchContext.setEnd(end); !layoutGroup.isControlPanel()) { searchContext.setIncludeStagingGroups(false); searchContext.setKeywords(keywords); searchContext.setScopeStrict(false); searchContext.setStart(start); searchContext.setUserId(userId);
String keywords = searchContext.getKeywords(); searchContext.getAttribute(Field.GROUP_ID)); searchContext.getCompanyId(), false); for (String entryClassName : searchContext.getEntryClassNames()) { Indexer<?> indexer = IndexerRegistryUtil.getIndexer(entryClassName); String searchEngineId = searchContext.getSearchEngineId(); Map<String, Facet> facets = searchContext.getFacets(); searchContext.getBooleanClauses(); for (String entryClassName : searchContext.getEntryClassNames()) { Indexer<?> indexer = IndexerRegistryUtil.getIndexer(entryClassName); String searchEngineId = searchContext.getSearchEngineId();
@Override public void indexKeyword( String searchEngineId, long companyId, String querySuggestion, float weight, String keywordType, Locale locale) throws SearchException { SearchEngine searchEngine = _searchEngineHelper.getSearchEngine( searchEngineId); IndexWriter indexWriter = searchEngine.getIndexWriter(); SearchContext searchContext = new SearchContext(); searchContext.setCompanyId(companyId); searchContext.setSearchEngineId(searchEngineId); searchContext.setKeywords(querySuggestion); searchContext.setLocale(locale); indexWriter.indexKeyword(searchContext, weight, keywordType); }
searchContext.setSearchEngineId(getSearchEngineId()); searchContext.getFullQueryEntryClassNames(); searchContext.setAttribute( "relatedEntryClassNames", getSearchClassNames()); getSearchClassNames(), fullQueryEntryClassNames); searchContext.setEntryClassNames(entryClassNames); entryClassNames, searchContext.getSearchEngineId()); fullQueryBooleanFilter, searchContext); fullQuery.setQueryConfig(searchContext.getQueryConfig());
@Override protected Hits doSearch(SearchContext searchContext) throws SearchException { String keywords = StringUtil.trim(searchContext.getKeywords()); if (Validator.isBlank(keywords) && !GetterUtil.getBoolean( searchContext.getAttribute( SearchContextAttributes.ATTRIBUTE_KEY_EMPTY_SEARCH))) { return new HitsImpl(); } try { searchContext.setSearchEngineId(getSearchEngineId()); BooleanFilter booleanFilter = new BooleanFilter(); booleanFilter.addRequiredTerm( Field.COMPANY_ID, searchContext.getCompanyId()); Query query = _getFinalQuery( createFullQuery(booleanFilter, searchContext)); QueryConfig queryConfig = searchContext.getQueryConfig(); query.setQueryConfig(queryConfig); return _indexSearcherHelper.search(searchContext, query); } catch (Exception e) { throw new SearchException(e); } }
@Override public Hits search(SearchContext searchContext) throws SearchException { QueryConfig queryConfig = searchContext.getQueryConfig(); int end = searchContext.getEnd(); int start = searchContext.getStart(); searchContext.setEnd(amplifiedEnd); searchContext.setStart(offset);
@Override public boolean process(SearchContext searchContext, Hits hits) throws SearchException { QueryConfig queryConfig = searchContext.getQueryConfig(); if (!queryConfig.isQueryIndexingEnabled()) { return true; } if (hits.getLength() >= queryConfig.getQueryIndexingThreshold()) { addDocument( searchContext.getCompanyId(), searchContext.getKeywords(), searchContext.getLocale()); } return true; }
String value = String.valueOf(searchContext.getAttribute(field)); value = searchContext.getKeywords(); searchContext.getLocale(), field); if (Validator.isNull(searchContext.getKeywords())) { BooleanQuery localizedQuery = new BooleanQueryImpl(); if (searchContext.isAndSearch()) { booleanClauseOccur = BooleanClauseOccur.MUST;
@Override protected boolean isGroupAdmin(SearchContext searchContext) { long groupId = GetterUtil.getLong( searchContext.getAttribute(Field.GROUP_ID)); if (groupId == 0) { return false; } if (!_permissionChecker.isGroupAdmin(groupId)) { return false; } return true; }
long[] groupIds = searchContext.getGroupIds(); searchContext, groupId, searchContext.getLanguageId(), searchContext.getKeywords(), weight, keywordFieldName, typeFieldValue, maxNGramLength);