@Override public void delete(T object) throws SearchException { if (object == null) { return; } try { doDelete(object); } catch (SearchException se) { throw se; } catch (Exception e) { throw new SearchException(e); } }
@Override public void indexSpellCheckerDictionaries(SearchContext searchContext) throws SearchException { try { for (String languageId : _SUPPORTED_LOCALES) { indexKeywords( searchContext, languageId, PropsKeys.INDEX_SEARCH_SPELL_CHECKER_DICTIONARY, Field.SPELL_CHECK_WORD, SuggestionConstants.TYPE_SPELL_CHECKER, 0); } } catch (Exception e) { throw new SearchException(e); } }
@Override public void indexQuerySuggestionDictionaries(SearchContext searchContext) throws SearchException { try { for (String languageId : _SUPPORTED_LOCALES) { indexKeywords( searchContext, languageId, PropsKeys.INDEX_SEARCH_QUERY_SUGGESTION_DICTIONARY, Field.KEYWORD_SEARCH, SuggestionConstants.TYPE_QUERY_SUGGESTION, _querySuggestionMaxNGramLength); } } catch (Exception e) { throw new SearchException(e); } }
@Override public void delete(long companyId, String uid) throws SearchException { try { IndexWriterHelperUtil.deleteDocument( getSearchEngineId(), companyId, uid, _commitImmediately); } catch (SearchException se) { throw se; } catch (Exception e) { throw new SearchException(e); } }
@Override public void indexSpellCheckerDictionary(SearchContext searchContext) throws SearchException { try { indexKeywords( searchContext, searchContext.getLanguageId(), PropsKeys.INDEX_SEARCH_SPELL_CHECKER_DICTIONARY, Field.SPELL_CHECK_WORD, SuggestionConstants.TYPE_SPELL_CHECKER, 0); } catch (Exception e) { throw new SearchException(e); } }
@Override public void indexQuerySuggestionDictionary(SearchContext searchContext) throws SearchException { try { indexKeywords( searchContext, searchContext.getLanguageId(), PropsKeys.INDEX_SEARCH_QUERY_SUGGESTION_DICTIONARY, Field.KEYWORD_SEARCH, SuggestionConstants.TYPE_QUERY_SUGGESTION, _querySuggestionMaxNGramLength); } catch (Exception e) { throw new SearchException(e); } }
@Override public Summary getSummary( Document document, String snippet, PortletRequest portletRequest, PortletResponse portletResponse) throws SearchException { try { Locale locale = getLocale(portletRequest); Summary summary = doGetSummary( document, locale, snippet, portletRequest, portletResponse); for (IndexerPostProcessor indexerPostProcessor : _indexerPostProcessors) { indexerPostProcessor.postProcessSummary( summary, document, locale, snippet); } return summary; } catch (SearchException se) { throw se; } catch (Exception e) { throw new SearchException(e); } }
throw new SearchException(e.getMessage(), e);
@Override public void reindex(T object) throws SearchException { try { if (IndexWriterHelperUtil.isIndexReadOnly() || IndexWriterHelperUtil.isIndexReadOnly(getClassName()) || !isIndexerEnabled()) { return; } if (object == null) { return; } doReindex(object); } catch (SearchException se) { throw se; } catch (Exception e) { throw new SearchException(e); } }
@Override public Document getDocument(T object) throws SearchException { try { Document document = doGetDocument(object); for (IndexerPostProcessor indexerPostProcessor : _indexerPostProcessors) { indexerPostProcessor.postProcessDocument(document, object); } if (document == null) { return null; } Map<String, Field> fields = document.getFields(); Field groupIdField = fields.get(Field.GROUP_ID); if (groupIdField != null) { long groupId = GetterUtil.getLong(groupIdField.getValue()); addStagingGroupKeyword(document, groupId); } return document; } catch (SearchException se) { throw se; } catch (Exception e) { throw new SearchException(e); } }
@Override public void reindex(String className, long classPK) throws SearchException { try { if (IndexWriterHelperUtil.isIndexReadOnly() || IndexWriterHelperUtil.isIndexReadOnly(getClassName()) || !isIndexerEnabled() || (classPK <= 0)) { return; } doReindex(className, classPK); } catch (NoSuchModelException nsme) { if (_log.isWarnEnabled()) { _log.warn( StringBundler.concat( "Unable to index ", className, " ", String.valueOf(classPK)), nsme); } } catch (SearchException se) { throw se; } catch (Exception e) { throw new SearchException(e); } }
@Override public void reindex(String[] ids) throws SearchException { long companyThreadLocalCompanyId = CompanyThreadLocal.getCompanyId(); try { if (IndexWriterHelperUtil.isIndexReadOnly() || IndexWriterHelperUtil.isIndexReadOnly(getClassName()) || !isIndexerEnabled()) { return; } if (ids.length > 0) { long companyId = GetterUtil.getLong(ids[0]); CompanyThreadLocal.setCompanyId(companyId); } doReindex(ids); } catch (SearchException se) { throw se; } catch (Exception e) { throw new SearchException(e); } finally { CompanyThreadLocal.setCompanyId(companyThreadLocalCompanyId); } }
@Override public String search(HttpServletRequest request, String url) throws SearchException { try { long userId = PortalUtil.getUserId(request); if (userId == 0) { long companyId = PortalUtil.getCompanyId(request); userId = UserLocalServiceUtil.getDefaultUserId(companyId); } String keywords = GetterUtil.getString( HttpUtil.getParameter(url, "keywords", false)); int startPage = GetterUtil.getInteger( HttpUtil.getParameter(url, "p", false), 1); int itemsPerPage = GetterUtil.getInteger( HttpUtil.getParameter(url, "c", false), SearchContainer.DEFAULT_DELTA); String format = GetterUtil.getString( HttpUtil.getParameter(url, "format", false)); return search( request, userId, keywords, startPage, itemsPerPage, format); } catch (SearchException se) { throw se; } catch (Exception e) { throw new SearchException(e); } }
@Override protected Hits doSearch(SearchContext searchContext) throws SearchException { try { searchContext.setSearchEngineId(getSearchEngineId()); BooleanFilter queryBooleanFilter = new BooleanFilter(); queryBooleanFilter.addRequiredTerm( Field.COMPANY_ID, searchContext.getCompanyId()); Query fullQuery = createFullQuery( queryBooleanFilter, searchContext); if (!fullQuery.hasChildren()) { BooleanFilter preBooleanFilter = fullQuery.getPreBooleanFilter(); fullQuery = new MatchAllQuery(); fullQuery.setPreBooleanFilter(preBooleanFilter); } QueryConfig queryConfig = searchContext.getQueryConfig(); fullQuery.setQueryConfig(queryConfig); return IndexSearcherHelperUtil.search(searchContext, fullQuery); } catch (Exception e) { throw new SearchException(e); } }
@Override public void indexQuerySuggestionDictionary(SearchContext searchContext) throws SearchException { try { indexKeywords( searchContext, searchContext.getLanguageId(), PropsKeys.INDEX_SEARCH_QUERY_SUGGESTION_DICTIONARY, Field.KEYWORD_SEARCH, SuggestionConstants.TYPE_QUERY_SUGGESTION, _querySuggestionMaxNGramLength); } catch (Exception e) { throw new SearchException(e); } }
@Override public void indexSpellCheckerDictionary(SearchContext searchContext) throws SearchException { try { indexKeywords( searchContext, searchContext.getLanguageId(), PropsKeys.INDEX_SEARCH_SPELL_CHECKER_DICTIONARY, Field.SPELL_CHECK_WORD, SuggestionConstants.TYPE_SPELL_CHECKER, 0); } catch (Exception e) { throw new SearchException(e); } }