1
19
20 package com.liferay.portal.kernel.search;
21
22
28 public class SearchEngineUtil {
29
30
34 public static final int ALL_POS = -1;
35
36 public static void addDocument(long companyId, Document doc)
37 throws SearchException {
38
39 getSearchEngine().getWriter().addDocument(companyId, doc);
40 }
41
42 public static void deleteDocument(long companyId, String uid)
43 throws SearchException {
44
45 getSearchEngine().getWriter().deleteDocument(companyId, uid);
46 }
47
48 public static void deletePortletDocuments(long companyId, String portletId)
49 throws SearchException {
50
51 getSearchEngine().getWriter().deletePortletDocuments(
52 companyId, portletId);
53 }
54
55 public static SearchEngine getSearchEngine() {
56 return _searchEngine;
57 }
58
59 public static boolean isIndexReadOnly() {
60 return getSearchEngine().isIndexReadOnly();
61 }
62
63 public static void register(String name) {
64 getSearchEngine().register(name);
65 }
66
67 public static void registerDefaultSearchEngine() {
68 SearchEngineUtil.register(_defaultSearchEngineName);
69 }
70
71 public static Hits search(long companyId, Query query, int start, int end)
72 throws SearchException {
73
74 return getSearchEngine().getSearcher().search(
75 companyId, query, _DEFAULT_SORT, start, end);
76 }
77
78 public static Hits search(
79 long companyId, Query query, Sort sort, int start, int end)
80 throws SearchException {
81
82 return getSearchEngine().getSearcher().search(
83 companyId, query, new Sort[] {sort}, start, end);
84 }
85
86 public static Hits search(
87 long companyId, Query query, Sort[] sorts, int start, int end)
88 throws SearchException {
89
90 return getSearchEngine().getSearcher().search(
91 companyId, query, sorts, start, end);
92 }
93
94 public static void unregister(String fromName) {
95 getSearchEngine().unregister(fromName);
96 }
97
98 public static void updateDocument(long companyId, String uid, Document doc)
99 throws SearchException {
100
101 getSearchEngine().getWriter().updateDocument(companyId, uid, doc);
102 }
103
104 public void setDefaultSearchEngineName(String defaultSearchEngineName) {
105 _defaultSearchEngineName = defaultSearchEngineName;
106 }
107
108 public void setSearchEngine(SearchEngine searchEngine) {
109 _searchEngine = searchEngine;
110 }
111
112 private static final Sort[] _DEFAULT_SORT = new Sort[] {
113 new Sort(Field.MODIFIED, Sort.LONG_TYPE, true)
114 };
115
116 private static String _defaultSearchEngineName;
117 private static SearchEngine _searchEngine;
118
119 }