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