protected void search( FileEntry fileEntry, boolean rootFolder, String keywords, boolean assertTrue) throws Exception { SearchContext searchContext = new SearchContext(); searchContext.setAttribute("paginationType", "regular"); searchContext.setCompanyId(fileEntry.getCompanyId()); searchContext.setFolderIds(new long[] {fileEntry.getFolderId()}); searchContext.setGroupIds(new long[] {fileEntry.getRepositoryId()}); searchContext.setKeywords(keywords); QueryConfig queryConfig = new QueryConfig(); queryConfig.setHighlightEnabled(false); queryConfig.setScoreEnabled(false); searchContext.setQueryConfig(queryConfig); Indexer indexer = IndexerRegistryUtil.getIndexer(DLFileEntryConstants.getClassName()); Hits hits = indexer.search(searchContext); List<Document> documents = hits.toList(); boolean found = false; for (Document document : documents) { long fileEntryId = GetterUtil.getLong(document.get(Field.ENTRY_CLASS_PK)); if (fileEntryId == fileEntry.getFileEntryId()) { found = true; break; } } String message = "Search engine could not find "; if (rootFolder) { message += "root file entry by " + keywords; } else { message += "file entry by " + keywords; } message += " using query " + hits.getQuery(); if (assertTrue) { Assert.assertTrue(message, found); } else { Assert.assertFalse(message, found); } }
public Hits search( long companyId, long[] groupIds, long userId, String className, String keywords, int status, int start, int end) throws SystemException { try { SearchContext searchContext = new SearchContext(); Facet assetEntriesFacet = new AssetEntriesFacet(searchContext); assetEntriesFacet.setStatic(true); searchContext.addFacet(assetEntriesFacet); Facet scopeFacet = new ScopeFacet(searchContext); scopeFacet.setStatic(true); searchContext.addFacet(scopeFacet); searchContext.setAttribute("paginationType", "regular"); searchContext.setAttribute("status", status); searchContext.setCompanyId(companyId); searchContext.setEnd(end); searchContext.setEntryClassNames(getClassNames(className)); searchContext.setGroupIds(groupIds); searchContext.setKeywords(keywords); QueryConfig queryConfig = new QueryConfig(); queryConfig.setHighlightEnabled(false); queryConfig.setScoreEnabled(false); searchContext.setQueryConfig(queryConfig); searchContext.setStart(start); searchContext.setUserId(userId); Indexer indexer = FacetedSearcher.getInstance(); return indexer.search(searchContext); } catch (Exception e) { throw new SystemException(e); } }
protected void search(boolean rootFolder, String keywords) throws Exception { SearchContext searchContext = new SearchContext(); searchContext.setCompanyId(_fileEntry.getCompanyId()); searchContext.setFolderIds(new long[] {_fileEntry.getFolderId()}); searchContext.setGroupIds(new long[] {_fileEntry.getRepositoryId()}); searchContext.setKeywords(keywords); QueryConfig queryConfig = new QueryConfig(); queryConfig.setHighlightEnabled(false); queryConfig.setScoreEnabled(false); searchContext.setQueryConfig(queryConfig); Indexer indexer = IndexerRegistryUtil.getIndexer(DLFileEntry.class); List<Document> documents = indexer.search(searchContext).toList(); boolean found = false; for (Document document : documents) { long fileEntryId = GetterUtil.getLong(document.get(Field.ENTRY_CLASS_PK)); if (fileEntryId == _fileEntry.getFileEntryId()) { found = true; break; } } String message = "Search engine could not find "; if (rootFolder) { message += "root file entry by " + keywords; } else { message += "file entry by " + keywords; } assertTrue(message, found); }
public Hits search( long companyId, long[] groupIds, long userId, String className, String userName, String title, String description, String assetCategoryIds, String assetTagNames, int status, boolean andSearch, int start, int end) throws SystemException { try { SearchContext searchContext = new SearchContext(); Facet assetEntriesFacet = new AssetEntriesFacet(searchContext); assetEntriesFacet.setStatic(true); searchContext.addFacet(assetEntriesFacet); Facet scopeFacet = new ScopeFacet(searchContext); scopeFacet.setStatic(true); searchContext.addFacet(scopeFacet); searchContext.setAndSearch(andSearch); searchContext.setAssetCategoryIds(StringUtil.split(assetCategoryIds, 0L)); searchContext.setAssetTagNames(StringUtil.split(assetTagNames)); searchContext.setAttribute(Field.DESCRIPTION, description); searchContext.setAttribute(Field.TITLE, title); searchContext.setAttribute(Field.USER_NAME, userName); searchContext.setAttribute("paginationType", "regular"); searchContext.setAttribute("status", status); searchContext.setCompanyId(companyId); searchContext.setEnd(end); searchContext.setEntryClassNames(getClassNames(className)); searchContext.setGroupIds(groupIds); QueryConfig queryConfig = new QueryConfig(); queryConfig.setHighlightEnabled(false); queryConfig.setScoreEnabled(false); searchContext.setQueryConfig(queryConfig); searchContext.setStart(start); searchContext.setUserId(userId); Indexer indexer = FacetedSearcher.getInstance(); return indexer.search(searchContext); } catch (Exception e) { throw new SystemException(e); } }