001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.kernel.search;
016    
017    import com.liferay.portal.kernel.search.filter.BooleanFilter;
018    import com.liferay.portal.security.permission.PermissionChecker;
019    
020    import java.util.Collection;
021    import java.util.Locale;
022    
023    import javax.portlet.PortletRequest;
024    import javax.portlet.PortletResponse;
025    
026    /**
027     * @author Brian Wing Shun Chan
028     * @author Raymond Aug??
029     * @author Ryan Park
030     */
031    public interface Indexer<T> {
032    
033            public static final int DEFAULT_INTERVAL = 10000;
034    
035            public void delete(long companyId, String uid) throws SearchException;
036    
037            @Bufferable
038            public void delete(T object) throws SearchException;
039    
040            public String getClassName();
041    
042            /**
043             * @deprecated As of 7.0.0, replaced by {@link #getSearchClassNames}
044             */
045            @Deprecated
046            public String[] getClassNames();
047    
048            public Document getDocument(T object) throws SearchException;
049    
050            public BooleanFilter getFacetBooleanFilter(
051                            String className, SearchContext searchContext)
052                    throws Exception;
053    
054            public BooleanQuery getFullQuery(SearchContext searchContext)
055                    throws SearchException;
056    
057            public IndexerPostProcessor[] getIndexerPostProcessors();
058    
059            /**
060             * @deprecated As of 7.0.0, replaced by {@link #getClassName}
061             */
062            @Deprecated
063            public String getPortletId();
064    
065            public String[] getSearchClassNames();
066    
067            public String getSearchEngineId();
068    
069            public String getSortField(String orderByCol);
070    
071            public String getSortField(String orderByCol, int sortType);
072    
073            /**
074             * @deprecated As of 7.0.0, replaced by {@link #getSummary(Document, String,
075             *             PortletRequest, PortletResponse)}
076             */
077            @Deprecated
078            public Summary getSummary(Document document, Locale locale, String snippet)
079                    throws SearchException;
080    
081            public Summary getSummary(
082                            Document document, String snippet, PortletRequest portletRequest,
083                            PortletResponse portletResponse)
084                    throws SearchException;
085    
086            public boolean hasPermission(
087                            PermissionChecker permissionChecker, String entryClassName,
088                            long entryClassPK, String actionId)
089                    throws Exception;
090    
091            public boolean isCommitImmediately();
092    
093            /**
094             * Return <code>true</code> if the indexer participates in post-search
095             * result filtering.
096             *
097             * @return <code>true</code> if the indexer participates in post-search
098             *         result filtering; <code>false</code> otherwise
099             * @see    SearchResultPermissionFilter
100             */
101            public boolean isFilterSearch();
102    
103            public boolean isIndexerEnabled();
104    
105            /**
106             * Returns <code>true</code> if the indexer adds permission related filters
107             * to the search query prior to execution
108             *
109             * @return <code>true</code> if the indexer adds permission related filters
110             *         to the search query prior to execution; <code>false</code>
111             *         otherwise
112             * @see    SearchPermissionChecker
113             */
114            public boolean isPermissionAware();
115    
116            public boolean isStagingAware();
117    
118            public boolean isVisible(long classPK, int status) throws Exception;
119    
120            public boolean isVisibleRelatedEntry(long classPK, int status)
121                    throws Exception;
122    
123            public void postProcessContextBooleanFilter(
124                            BooleanFilter contextBooleanFilter, SearchContext searchContext)
125                    throws Exception;
126    
127            /**
128             * @deprecated As of 7.0.0, replaced by {@link
129             *             #postProcessContextBooleanFilter(BooleanFilter,
130             *             SearchContext)}
131             */
132            @Deprecated
133            public void postProcessContextQuery(
134                            BooleanQuery contextQuery, SearchContext searchContext)
135                    throws Exception;
136    
137            public void postProcessSearchQuery(
138                            BooleanQuery searchQuery, BooleanFilter fullQueryBooleanFilter,
139                            SearchContext searchContext)
140                    throws Exception;
141    
142            /**
143             * @deprecated As of 7.0.0, replaced by {@link
144             *             #postProcessSearchQuery(BooleanQuery, BooleanFilter,
145             *             SearchContext)}
146             */
147            @Deprecated
148            public void postProcessSearchQuery(
149                            BooleanQuery searchQuery, SearchContext searchContext)
150                    throws Exception;
151    
152            public void registerIndexerPostProcessor(
153                    IndexerPostProcessor indexerPostProcessor);
154    
155            @Bufferable
156            public void reindex(Collection<T> objects) throws SearchException;
157    
158            @Bufferable
159            public void reindex(String className, long classPK) throws SearchException;
160    
161            public void reindex(String[] ids) throws SearchException;
162    
163            @Bufferable
164            public void reindex(T object) throws SearchException;
165    
166            public Hits search(SearchContext searchContext) throws SearchException;
167    
168            public Hits search(
169                            SearchContext searchContext, String... selectedFieldNames)
170                    throws SearchException;
171    
172            public long searchCount(SearchContext searchContext) throws SearchException;
173    
174            public void setIndexerEnabled(boolean indexerEnabled);
175    
176            public void unregisterIndexerPostProcessor(
177                    IndexerPostProcessor indexerPostProcessor);
178    
179    }