com.liferay.journal.web.internal.util.JournalSearcherUtil Maven / Gradle / Ivy
/**
* SPDX-FileCopyrightText: (c) 2000 Liferay, Inc. https://liferay.com
* SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06
*/
package com.liferay.journal.web.internal.util;
import com.liferay.journal.model.JournalArticle;
import com.liferay.journal.model.JournalFolder;
import com.liferay.journal.service.JournalArticleLocalService;
import com.liferay.journal.service.JournalFolderLocalService;
import com.liferay.petra.function.transform.TransformUtil;
import com.liferay.portal.kernel.module.service.Snapshot;
import com.liferay.portal.kernel.search.Document;
import com.liferay.portal.kernel.search.Field;
import com.liferay.portal.kernel.search.SearchContext;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.search.searcher.SearchRequestBuilderFactory;
import com.liferay.portal.search.searcher.SearchResponse;
import com.liferay.portal.search.searcher.Searcher;
import java.util.List;
import java.util.function.Consumer;
/**
* @author Lourdes Fernández Besada
*/
public class JournalSearcherUtil {
public static SearchResponse searchJournalArticleAndFolders(
Consumer searchContextConsumer) {
Searcher searcher = _searcherSnapshot.get();
SearchRequestBuilderFactory searchRequestBuilderFactory =
_searchRequestBuilderFactorySnapshot.get();
return searcher.search(
searchRequestBuilderFactory.builder(
).emptySearchEnabled(
true
).modelIndexerClasses(
JournalArticle.class, JournalFolder.class
).withSearchContext(
searchContextConsumer
).build());
}
public static SearchResponse searchJournalArticles(
Consumer searchContextConsumer) {
Searcher searcher = _searcherSnapshot.get();
SearchRequestBuilderFactory searchRequestBuilderFactory =
_searchRequestBuilderFactorySnapshot.get();
return searcher.search(
searchRequestBuilderFactory.builder(
).emptySearchEnabled(
true
).modelIndexerClasses(
JournalArticle.class
).withSearchContext(
searchContextConsumer
).build());
}
public static List
© 2015 - 2024 Weber Informatics LLC | Privacy Policy