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 java.util.Collection;
018    import java.util.List;
019    import java.util.Locale;
020    import java.util.Map;
021    
022    /**
023     * @author     Bruno Farache
024     * @author     Raymond Aug??
025     * @author     Michael C. Han
026     * @deprecated As of 7.0.0, replaced by {@link IndexWriterHelperUtil,
027     *             IndexSearcherHelperUtil, SearchEngineHelperUtil}
028     */
029    @Deprecated
030    public class SearchEngineUtil extends SearchEngineHelperUtil {
031    
032            @Deprecated
033            public static final String GENERIC_ENGINE_ID =
034                    SearchEngineHelper.GENERIC_ENGINE_ID;
035    
036            @Deprecated
037            public static final String SYSTEM_ENGINE_ID =
038                    SearchEngineHelper.SYSTEM_ENGINE_ID;
039    
040            /**
041             * @deprecated As of 7.0.0, replaced by {@link
042             *             IndexWriterHelperUtil#addDocument(String, long, Document,
043             *             boolean)}
044             */
045            @Deprecated
046            public static void addDocument(
047                            String searchEngineId, long companyId, Document document)
048                    throws SearchException {
049    
050                    IndexWriterHelperUtil.addDocument(
051                            searchEngineId, companyId, document, false);
052            }
053    
054            /**
055             * @deprecated As of 7.0.0, replaced by {@link
056             *             IndexWriterHelperUtil#addDocuments(String, long, Collection,
057             *             boolean)}
058             */
059            @Deprecated
060            public static void addDocument(
061                            String searchEngineId, long companyId, Document document,
062                            boolean commitImmediately)
063                    throws SearchException {
064    
065                    IndexWriterHelperUtil.addDocument(
066                            searchEngineId, companyId, document, commitImmediately);
067            }
068    
069            /**
070             * @deprecated As of 7.0.0, replaced by {@link
071             *             IndexWriterHelperUtil#addDocuments(String, long, Collection,
072             *             boolean)}
073             */
074            @Deprecated
075            public static void addDocuments(
076                            String searchEngineId, long companyId,
077                            Collection<Document> documents)
078                    throws SearchException {
079    
080                    IndexWriterHelperUtil.addDocuments(
081                            searchEngineId, companyId, documents, false);
082            }
083    
084            /**
085             * @deprecated As of 7.0.0, replaced by {@link
086             *             IndexWriterHelperUtil#addDocuments(String, long, Collection,
087             *             boolean)}
088             */
089            @Deprecated
090            public static void addDocuments(
091                            String searchEngineId, long companyId,
092                            Collection<Document> documents, boolean commitImmediately)
093                    throws SearchException {
094    
095                    IndexWriterHelperUtil.addDocuments(
096                            searchEngineId, companyId, documents, commitImmediately);
097            }
098    
099            /**
100             * @deprecated As of 7.0.0, replaced by {@link
101             *             IndexWriterHelperUtil#commit(String)}
102             */
103            @Deprecated
104            public static void commit(String searchEngineId) throws SearchException {
105                    IndexWriterHelperUtil.commit(searchEngineId);
106            }
107    
108            /**
109             * @deprecated As of 7.0.0, replaced by {@link
110             *             IndexWriterHelperUtil#commit(String, long)}
111             */
112            @Deprecated
113            public static void commit(String searchEngineId, long companyId)
114                    throws SearchException {
115    
116                    IndexWriterHelperUtil.commit(searchEngineId, companyId);
117            }
118    
119            /**
120             * @deprecated As of 7.0.0, replaced by {@link
121             *             IndexWriterHelperUtil#deleteDocument(String, long, String,
122             *             boolean)}
123             */
124            @Deprecated
125            public static void deleteDocument(
126                            String searchEngineId, long companyId, String uid)
127                    throws SearchException {
128    
129                    IndexWriterHelperUtil.deleteDocument(
130                            searchEngineId, companyId, uid, false);
131            }
132    
133            /**
134             * @deprecated As of 7.0.0, replaced by {@link
135             *             IndexWriterHelperUtil#deleteDocument(String, long, String,
136             *             boolean)}
137             */
138            @Deprecated
139            public static void deleteDocument(
140                            String searchEngineId, long companyId, String uid,
141                            boolean commitImmediately)
142                    throws SearchException {
143    
144                    IndexWriterHelperUtil.deleteDocument(
145                            searchEngineId, companyId, uid, commitImmediately);
146            }
147    
148            /**
149             * @deprecated As of 7.0.0, replaced by {@link
150             *             IndexWriterHelperUtil#deleteDocuments(String, long,
151             *             Collection, boolean)}
152             */
153            @Deprecated
154            public static void deleteDocuments(
155                            String searchEngineId, long companyId, Collection<String> uids)
156                    throws SearchException {
157    
158                    IndexWriterHelperUtil.deleteDocuments(
159                            searchEngineId, companyId, uids, false);
160            }
161    
162            /**
163             * @deprecated As of 7.0.0, replaced by {@link
164             *             IndexWriterHelperUtil#deleteDocuments(String, long,
165             *             Collection, boolean)}
166             */
167            @Deprecated
168            public static void deleteDocuments(
169                            String searchEngineId, long companyId, Collection<String> uids,
170                            boolean commitImmediately)
171                    throws SearchException {
172    
173                    IndexWriterHelperUtil.deleteDocuments(
174                            searchEngineId, companyId, uids, commitImmediately);
175            }
176    
177            /**
178             * @deprecated As of 7.0.0, replaced by {@link
179             *             IndexWriterHelperUtil#deleteEntityDocuments(String, long,
180             *             String, boolean)}
181             */
182            @Deprecated
183            public static void deleteEntityDocuments(
184                            String searchEngineId, long companyId, String className,
185                            boolean commitImmediately)
186                    throws SearchException {
187    
188                    IndexWriterHelperUtil.deleteEntityDocuments(
189                            searchEngineId, companyId, className, commitImmediately);
190            }
191    
192            /**
193             * @deprecated As of 7.0.0, replaced by {@link
194             *             IndexWriterHelperUtil#deleteEntityDocuments(String, long,
195             *             String, boolean)}
196             */
197            @Deprecated
198            public static void deletePortletDocuments(
199                            String searchEngineId, long companyId, String portletId)
200                    throws SearchException {
201    
202                    IndexWriterHelperUtil.deleteEntityDocuments(
203                            searchEngineId, companyId, portletId, false);
204            }
205    
206            /**
207             * @deprecated As of 7.0.0, replaced by {@link
208             *             IndexSearcherHelperUtil#getQueryString(SearchContext, Query)}
209             */
210            @Deprecated
211            public static String getQueryString(
212                    SearchContext searchContext, Query query) {
213    
214                    return IndexSearcherHelperUtil.getQueryString(searchContext, query);
215            }
216    
217            /**
218             * @deprecated As of 7.0.0, replaced by {@link
219             *             IndexWriterHelperUtil#indexKeyword(long, String, float,
220             *             String, Locale)}
221             */
222            @Deprecated
223            public static void indexKeyword(
224                            long companyId, String querySuggestion, float weight,
225                            String keywordType, Locale locale)
226                    throws SearchException {
227    
228                    IndexWriterHelperUtil.indexKeyword(
229                            companyId, querySuggestion, weight, keywordType, locale);
230            }
231    
232            /**
233             * @deprecated As of 7.0.0, replaced by {@link
234             *             IndexWriterHelperUtil#indexKeyword(String, long, String,
235             *             float, String, Locale)}
236             */
237            @Deprecated
238            public static void indexKeyword(
239                            String searchEngineId, long companyId, String querySuggestion,
240                            float weight, String keywordType, Locale locale)
241                    throws SearchException {
242    
243                    IndexWriterHelperUtil.indexKeyword(
244                            searchEngineId, companyId, querySuggestion, weight, keywordType,
245                            locale);
246            }
247    
248            /**
249             * @deprecated As of 7.0.0, replaced by {@link
250             *             IndexWriterHelperUtil#indexQuerySuggestionDictionaries(long)}
251             */
252            @Deprecated
253            public static void indexQuerySuggestionDictionaries(long companyId)
254                    throws SearchException {
255    
256                    IndexWriterHelperUtil.indexQuerySuggestionDictionaries(companyId);
257            }
258    
259            /**
260             * @deprecated As of 7.0.0, replaced by {@link
261             *             IndexWriterHelperUtil#indexQuerySuggestionDictionaries(
262             *             String, long)}
263             */
264            @Deprecated
265            public static void indexQuerySuggestionDictionaries(
266                            String searchEngineId, long companyId)
267                    throws SearchException {
268    
269                    IndexWriterHelperUtil.indexQuerySuggestionDictionaries(
270                            searchEngineId, companyId);
271            }
272    
273            /**
274             * @deprecated As of 7.0.0, replaced by {@link
275             *             IndexWriterHelperUtil#indexQuerySuggestionDictionary(long,
276             *             Locale)}
277             */
278            @Deprecated
279            public static void indexQuerySuggestionDictionary(
280                            long companyId, Locale locale)
281                    throws SearchException {
282    
283                    IndexWriterHelperUtil.indexQuerySuggestionDictionary(companyId, locale);
284            }
285    
286            /**
287             * @deprecated As of 7.0.0, replaced by {@link
288             *             IndexWriterHelperUtil#indexQuerySuggestionDictionary(String,
289             *             long, Locale)}
290             */
291            @Deprecated
292            public static void indexQuerySuggestionDictionary(
293                            String searchEngineId, long companyId, Locale locale)
294                    throws SearchException {
295    
296                    IndexWriterHelperUtil.indexQuerySuggestionDictionary(
297                            searchEngineId, companyId, locale);
298            }
299    
300            /**
301             * @deprecated As of 7.0.0, replaced by {@link
302             *             IndexWriterHelperUtil#indexSpellCheckerDictionaries(long)}
303             */
304            @Deprecated
305            public static void indexSpellCheckerDictionaries(long companyId)
306                    throws SearchException {
307    
308                    IndexWriterHelperUtil.indexSpellCheckerDictionaries(companyId);
309            }
310    
311            /**
312             * @deprecated As of 7.0.0, replaced by {@link
313             *             IndexWriterHelperUtil#indexSpellCheckerDictionaries(String,
314             *             long)}
315             */
316            @Deprecated
317            public static void indexSpellCheckerDictionaries(
318                            String searchEngineId, long companyId)
319                    throws SearchException {
320    
321                    IndexWriterHelperUtil.indexSpellCheckerDictionaries(
322                            searchEngineId, companyId);
323            }
324    
325            /**
326             * @deprecated As of 7.0.0, replaced by {@link
327             *             IndexWriterHelperUtil#indexSpellCheckerDictionary(long,
328             *             Locale)}
329             */
330            @Deprecated
331            public static void indexSpellCheckerDictionary(
332                            long companyId, Locale locale)
333                    throws SearchException {
334    
335                    IndexWriterHelperUtil.indexSpellCheckerDictionary(companyId, locale);
336            }
337    
338            /**
339             * @deprecated As of 7.0.0, replaced by {@link
340             *             IndexWriterHelperUtil#indexSpellCheckerDictionary(String,
341             *             long, Locale)}
342             */
343            @Deprecated
344            public static void indexSpellCheckerDictionary(
345                            String searchEngineId, long companyId, Locale locale)
346                    throws SearchException {
347    
348                    IndexWriterHelperUtil.indexSpellCheckerDictionary(
349                            searchEngineId, companyId, locale);
350            }
351    
352            /**
353             * @deprecated As of 7.0.0, replaced by {@link
354             *             IndexWriterHelperUtil#isIndexReadOnly()}
355             */
356            @Deprecated
357            public static boolean isIndexReadOnly() {
358                    return IndexWriterHelperUtil.isIndexReadOnly();
359            }
360    
361            /**
362             * @deprecated As of 7.0.0, replaced by {@link
363             *             IndexWriterHelperUtil#partiallyUpdateDocument(String, long,
364             *             Document, boolean)}
365             */
366            @Deprecated
367            public static void partiallyUpdateDocument(
368                            String searchEngineId, long companyId, Document document,
369                            boolean commitImmediately)
370                    throws SearchException {
371    
372                    IndexWriterHelperUtil.partiallyUpdateDocument(
373                            searchEngineId, companyId, document, commitImmediately);
374            }
375    
376            /**
377             * @deprecated As of 7.0.0, replaced by {@link
378             *             IndexWriterHelperUtil#partiallyUpdateDocuments(String, long,
379             *             Collection, boolean)}
380             */
381            @Deprecated
382            public static void partiallyUpdateDocuments(
383                            String searchEngineId, long companyId,
384                            Collection<Document> documents, boolean commitImmediately)
385                    throws SearchException {
386    
387                    IndexWriterHelperUtil.partiallyUpdateDocuments(
388                            searchEngineId, companyId, documents, commitImmediately);
389            }
390    
391            /**
392             * @deprecated As of 7.0.0, replaced by {@link
393             *             IndexSearcherHelperUtil#search(SearchContext, Query)}
394             */
395            @Deprecated
396            public static Hits search(SearchContext searchContext, Query query)
397                    throws SearchException {
398    
399                    return IndexSearcherHelperUtil.search(searchContext, query);
400            }
401    
402            /**
403             * @deprecated As of 7.0.0, replaced by {@link
404             *             IndexSearcherHelperUtil#search(SearchContext, Query)}
405             */
406            @Deprecated
407            public static Hits search(
408                            String searchEngineId, long companyId, Query query, int start,
409                            int end)
410                    throws SearchException {
411    
412                    return search(
413                            searchEngineId, companyId, query, SortFactoryUtil.getDefaultSorts(),
414                            start, end);
415            }
416    
417            /**
418             * @deprecated As of 7.0.0, replaced by {@link
419             *             IndexSearcherHelperUtil#search(SearchContext, Query)}
420             */
421            @Deprecated
422            public static Hits search(
423                            String searchEngineId, long companyId, Query query, Sort sort,
424                            int start, int end)
425                    throws SearchException {
426    
427                    return search(
428                            searchEngineId, companyId, query, new Sort[] {sort}, start, end);
429            }
430    
431            /**
432             * @deprecated As of 7.0.0, replaced by {@link
433             *             IndexSearcherHelperUtil#search(SearchContext, Query)}
434             */
435            @Deprecated
436            public static Hits search(
437                            String searchEngineId, long companyId, Query query, Sort[] sorts,
438                            int start, int end)
439                    throws SearchException {
440    
441                    SearchContext searchContext = new SearchContext();
442    
443                    searchContext.setCompanyId(companyId);
444                    searchContext.setEnd(end);
445                    searchContext.setSearchEngineId(searchEngineId);
446                    searchContext.setSorts(sorts);
447                    searchContext.setStart(start);
448    
449                    return IndexSearcherHelperUtil.search(searchContext, query);
450            }
451    
452            /**
453             * @deprecated As of 7.0.0, replaced by {@link
454             *             IndexSearcherHelperUtil#searchCount(SearchContext, Query)}
455             */
456            @Deprecated
457            public static long searchCount(SearchContext searchContext, Query query)
458                    throws SearchException {
459    
460                    return IndexSearcherHelperUtil.searchCount(searchContext, query);
461            }
462    
463            /**
464             * @deprecated As of 7.0.0, replaced by {@link
465             *             IndexWriterHelperUtil#setIndexReadOnly(boolean)}
466             */
467            @Deprecated
468            public static void setIndexReadOnly(boolean readOnly) {
469                    IndexWriterHelperUtil.setIndexReadOnly(readOnly);
470            }
471    
472            /**
473             * @deprecated As of 7.0.0, replaced by {@link
474             *             IndexSearcherHelperUtil#spellCheckKeywords(SearchContext)}
475             */
476            @Deprecated
477            public static String spellCheckKeywords(SearchContext searchContext)
478                    throws SearchException {
479    
480                    return IndexSearcherHelperUtil.spellCheckKeywords(searchContext);
481            }
482    
483            /**
484             * @deprecated As of 7.0.0, replaced by {@link
485             *             IndexSearcherHelperUtil#spellCheckKeywords(SearchContext,
486             *             int)}
487             */
488            @Deprecated
489            public static Map<String, List<String>> spellCheckKeywords(
490                            SearchContext searchContext, int max)
491                    throws SearchException {
492    
493                    return IndexSearcherHelperUtil.spellCheckKeywords(searchContext, max);
494            }
495    
496            /**
497             * @deprecated As of 7.0.0, replaced by {@link
498             *             IndexSearcherHelperUtil#suggestKeywordQueries(SearchContext,
499             *             int)}
500             */
501            @Deprecated
502            public static String[] suggestKeywordQueries(
503                            SearchContext searchContext, int max)
504                    throws SearchException {
505    
506                    return IndexSearcherHelperUtil.suggestKeywordQueries(
507                            searchContext, max);
508            }
509    
510            /**
511             * @deprecated As of 7.0.0, replaced by {@link
512             *             IndexWriterHelperUtil#updateDocument(String, long, Document,
513             *             boolean)}
514             */
515            @Deprecated
516            public static void updateDocument(
517                            String searchEngineId, long companyId, Document document)
518                    throws SearchException {
519    
520                    IndexWriterHelperUtil.updateDocument(
521                            searchEngineId, companyId, document, false);
522            }
523    
524            /**
525             * @deprecated As of 7.0.0, replaced by {@link
526             *             IndexWriterHelperUtil#updateDocument(String, long, Document,
527             *             boolean)}
528             */
529            @Deprecated
530            public static void updateDocument(
531                            String searchEngineId, long companyId, Document document,
532                            boolean commitImmediately)
533                    throws SearchException {
534    
535                    IndexWriterHelperUtil.updateDocument(
536                            searchEngineId, companyId, document, commitImmediately);
537            }
538    
539            /**
540             * @deprecated As of 7.0.0, replaced by {@link
541             *             IndexWriterHelperUtil#updateDocuments(String, long,
542             *             Collection, boolean)}
543             */
544            @Deprecated
545            public static void updateDocuments(
546                            String searchEngineId, long companyId,
547                            Collection<Document> documents)
548                    throws SearchException {
549    
550                    IndexWriterHelperUtil.updateDocuments(
551                            searchEngineId, companyId, documents, false);
552            }
553    
554            /**
555             * @deprecated As of 7.0.0, replaced by {@link
556             *             IndexWriterHelperUtil#updateDocuments(String, long,
557             *             Collection, boolean)}
558             */
559            @Deprecated
560            public static void updateDocuments(
561                            String searchEngineId, long companyId,
562                            Collection<Document> documents, boolean commitImmediately)
563                    throws SearchException {
564    
565                    IndexWriterHelperUtil.updateDocuments(
566                            searchEngineId, companyId, documents, commitImmediately);
567            }
568    
569            /**
570             * @deprecated As of 7.0.0, replaced by {@link
571             *             IndexWriterHelperUtil#updatePermissionFields(String, String)}
572             */
573            @Deprecated
574            public static void updatePermissionFields(String name, String primKey) {
575                    IndexWriterHelperUtil.updatePermissionFields(name, primKey);
576            }
577    
578    }