Liferay 7搜索未返回结果-自定义实体

时间:2018-08-12 17:39:26

标签: elasticsearch search liferay-7 liferay-service-builder

我正在尝试启用对自定义实体的搜索,我已经实现了索引器,并尝试按以下方式执行搜索,但是搜索未返回任何文档/结果

    SearchContext searchContext = SearchContextFactory.getInstance(request);
    searchContext.setKeywords(keywords);
    searchContext.setAttribute("paginationType", "more");
    searchContext.setStart(0);
    searchContext.setEnd(10);


    Indexer indexer = IndexerRegistryUtil.getIndexer(Position.class);
    Hits hits = indexer.search(searchContext);
    System.out.println("Hit count: " + hits.getLength());

索引器实现似乎可以正常工作,因为我可以看到使用内置弹性搜索控制台按预期对索引进行了记录

localhost:9200/liferay-20116/_search

任何线索可能是什么问题?

仅提供其他信息,我的自定义实体不包含'groupId'的字段

1 个答案:

答案 0 :(得分:0)

出于某种原因,除非您愿意挖掘和覆盖行为,否则您必须在实体中具有groupId才能使搜索正常进行

我将groupId添加到了我的实体中(尽管我不感兴趣),并且繁荣起来了