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