List of usage examples for com.liferay.portal.kernel.search SearchContext setCompanyId
public void setCompanyId(long companyId)
From source file:com.liferay.user.groups.admin.web.internal.search.test.UserGroupIndexerTest.java
License:Open Source License
protected SearchContext getSearchContext(long companyId) { SearchContext searchContext = new SearchContext(); searchContext.setCompanyId(companyId); return searchContext; }
From source file:com.liferay.users.admin.indexer.test.OrganizationIndexerTest.java
License:Open Source License
protected Hits search(String keywords) throws Exception { SearchContext searchContext = new SearchContext(); searchContext.setCompanyId(TestPropsValues.getCompanyId()); searchContext.setEntryClassNames(new String[] { Organization.class.getName() }); searchContext.setKeywords(keywords); QueryConfig queryConfig = searchContext.getQueryConfig(); queryConfig.setSelectedFieldNames(Field.NAME); return _indexer.search(searchContext); }
From source file:com.liferay.users.admin.indexer.test.UserIndexerTest.java
License:Open Source License
protected SearchContext getSearchContext() throws Exception { SearchContext searchContext = new SearchContext(); searchContext.setCompanyId(TestPropsValues.getCompanyId()); searchContext.setGroupIds(new long[] { TestPropsValues.getGroupId() }); return searchContext; }
From source file:com.portlet.sample.service.impl.SampleEntryLocalServiceImpl.java
License:Open Source License
@Override public Hits search(long companyId, String title, String content, int start, int end) throws PortalException, SystemException { Indexer indexer = IndexerRegistryUtil.getIndexer(SampleEntry.class.getName()); SearchContext searchContext = new SearchContext(); searchContext.setCompanyId(companyId); searchContext.setStart(start);/* ww w . java 2 s .co m*/ searchContext.setEnd(end); searchContext.setAttribute(Field.TITLE, title); searchContext.setAttribute(Field.CONTENT, content); return indexer.search(searchContext); }
From source file:com.slayer.service.impl.LMSBookLocalServiceImpl.java
License:Open Source License
public Hits getHits(String keyword, long companyId, long groupId) { // 1. Preparing a Search Context SearchContext searchContext = new SearchContext(); searchContext.setCompanyId(companyId); String[] CLASS_NAMES = { LMSBook.class.getName() }; searchContext.setEntryClassNames(CLASS_NAMES); long[] groupIds = { groupId }; searchContext.setGroupIds(groupIds); // 2. Preparing a Query to search BooleanQuery searchQuery = BooleanQueryFactoryUtil.create(searchContext); String[] terms = { Field.TITLE, "author" }; try {//from w ww.j a va2s .com searchQuery.addTerms(terms, keyword); } catch (ParseException e) { e.printStackTrace(); } // 3. Firing the query to get hits Hits hits = null; try { hits = SearchEngineUtil.search(searchContext, searchQuery); } catch (SearchException e) { e.printStackTrace(); } return hits; }
From source file:com.slayer.service.impl.LMSBookLocalServiceImpl.java
License:Open Source License
protected Hits getHits(long companyId, long groupId, String bookTitle, String author, boolean andSearch) throws SystemException { // 1. Preparing the Search Context SearchContext searchContext = new SearchContext(); searchContext.setAndSearch(andSearch); searchContext.setCompanyId(companyId); long[] groupIds = { groupId }; searchContext.setGroupIds(groupIds); BooleanQuery searchQuery = BooleanQueryFactoryUtil.create(searchContext); appendSearchTerm(Field.TITLE, bookTitle, searchContext.isAndSearch(), searchQuery); appendSearchTerm("author", author, searchContext.isAndSearch(), searchQuery); // 2. Firing the query and getting the hits Hits hits = null;/*from w w w. j ava2s. co m*/ try { hits = SearchEngineUtil.search(searchContext, searchQuery); } catch (SearchException e) { e.printStackTrace(); } return hits; }
From source file:jorgediazest.indexchecker.model.IndexCheckerModel.java
License:Open Source License
public SearchContext getIndexSearchContext(long companyId) { SearchContext searchContext = new SearchContext(); searchContext.setCompanyId(companyId); searchContext.setEntryClassNames(new String[] { this.getClassName() }); return searchContext; }
From source file:jorgediazest.indexchecker.model.IndexCheckerModelQuery.java
License:Open Source License
public SearchContext getIndexSearchContext(long companyId) { SearchContext searchContext = new SearchContext(); searchContext.setCompanyId(companyId); searchContext.setEntryClassNames(new String[] { getModel().getClassName() }); return searchContext; }