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            public boolean isFilterSearch();
094    
095            public boolean isIndexerEnabled();
096    
097            public boolean isPermissionAware();
098    
099            public boolean isStagingAware();
100    
101            public boolean isVisible(long classPK, int status) throws Exception;
102    
103            public boolean isVisibleRelatedEntry(long classPK, int status)
104                    throws Exception;
105    
106            public void postProcessContextBooleanFilter(
107                            BooleanFilter contextBooleanFilter, SearchContext searchContext)
108                    throws Exception;
109    
110            /**
111             * @deprecated As of 7.0.0, replaced by {@link
112             *             #postProcessContextBooleanFilter(BooleanFilter,
113             *             SearchContext)}
114             */
115            @Deprecated
116            public void postProcessContextQuery(
117                            BooleanQuery contextQuery, SearchContext searchContext)
118                    throws Exception;
119    
120            public void postProcessSearchQuery(
121                            BooleanQuery searchQuery, BooleanFilter fullQueryBooleanFilter,
122                            SearchContext searchContext)
123                    throws Exception;
124    
125            /**
126             * @deprecated As of 7.0.0, replaced by {@link
127             *             #postProcessSearchQuery(BooleanQuery, BooleanFilter,
128             *             SearchContext)}
129             */
130            @Deprecated
131            public void postProcessSearchQuery(
132                            BooleanQuery searchQuery, SearchContext searchContext)
133                    throws Exception;
134    
135            public void registerIndexerPostProcessor(
136                    IndexerPostProcessor indexerPostProcessor);
137    
138            @Bufferable
139            public void reindex(Collection<T> objects) throws SearchException;
140    
141            @Bufferable
142            public void reindex(String className, long classPK) throws SearchException;
143    
144            public void reindex(String[] ids) throws SearchException;
145    
146            @Bufferable
147            public void reindex(T object) throws SearchException;
148    
149            public Hits search(SearchContext searchContext) throws SearchException;
150    
151            public Hits search(
152                            SearchContext searchContext, String... selectedFieldNames)
153                    throws SearchException;
154    
155            public long searchCount(SearchContext searchContext) throws SearchException;
156    
157            public void setIndexerEnabled(boolean indexerEnabled);
158    
159            public void unregisterIndexerPostProcessor(
160                    IndexerPostProcessor indexerPostProcessor);
161    
162    }