我正在使用liferay 7.3.5并尝试创建一个elasticSearch。我试着在数据库中索引一个实体。
我遵循了开发人员门户上关于“启用搜索和索引”的学习路径。在这个例子中,搜索是直接在JSP上完成的,它显示了这样的搜索结果...
SearchContext searchContext = SearchContextFactory .getInstance(request);
searchContext.setKeywords(keywords);
searchContext.setAttribute("paginationType", "more");
searchContext.setStart(0);
searchContext.setEnd(10);
Indexer indexer = IndexerRegistryUtil.getIndexer(Entry.class);
Hits hits = indexer.search(searchContext);
我所做的是将这段代码移到Java模式,这样JSP中就不会包含太多的Java内容
public void searchEntries(final ActionRequest request, final ActionResponse response) throws PortalException {
HttpServletRequest _request = PortalUtil.getHttpServletRequest(request);
SearchContext searchContext = SearchContextFactory.getInstance(_request);
String keywords = ParamUtil.getString(request, "keywords");
searchContext.setKeywords(keywords);
searchContext.setAttribute("paginationType", "more");
searchContext.setStart(0);
searchContext.setEnd(10);
Indexer<MyClassName> indexer = IndexerRegistryUtil.getIndexer(MyClassName.class);
Hits hits = indexer.search(searchContext);
.....
}
但是在搜索时,我总是从hits元素中得到空的搜索结果。
{docs={},长度=0,查询=null]
请注意,索引过程运行良好,没有错误,索引包含所需的文档,正如我所看到的那样,通过使用Kibana
错误在哪里?
thnx
1条答案
按热度按时间5lwkijsr1#
在Index.java更改