1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
13   */
14  
15  package com.liferay.portal.search;
16  
17  import com.liferay.portal.kernel.messaging.DestinationNames;
18  import com.liferay.portal.kernel.messaging.MessageBusUtil;
19  import com.liferay.portal.kernel.search.Hits;
20  import com.liferay.portal.kernel.search.IndexSearcher;
21  import com.liferay.portal.kernel.search.Query;
22  import com.liferay.portal.kernel.search.SearchException;
23  import com.liferay.portal.kernel.search.Sort;
24  import com.liferay.portal.kernel.search.messaging.SearchRequest;
25  
26  /**
27   * <a href="IndexSearcherImpl.java.html"><b><i>View Source</i></b></a>
28   *
29   * @author Bruno Farache
30   */
31  public class IndexSearcherImpl implements IndexSearcher {
32  
33      public Hits search(
34              long companyId, Query query, Sort[] sorts, int start, int end)
35          throws SearchException {
36  
37          try {
38              SearchRequest searchRequest = SearchRequest.search(
39                  companyId, query, sorts, start, end);
40  
41              Hits hits = (Hits)MessageBusUtil.sendSynchronousMessage(
42                  DestinationNames.SEARCH_READER, searchRequest,
43                  DestinationNames.SEARCH_READER_RESPONSE);
44  
45              return hits;
46          }
47          catch (Exception e) {
48              throw new SearchException(e);
49          }
50      }
51  
52  }