liferay empty search results by searching in a custom indexliferay empty search results by searching in a custom indexhttps://liferay.dev/en/c/message_boards/find_thread?p_l_id=119785333&threadId=1208178512024-03-19T10:51:20Z2024-03-19T10:51:20Zliferay empty search results by searching in a custom indexabo alsomhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1208178502021-06-03T15:53:26Z2021-06-03T13:52:07Z<p>Hi,<br />i'm using liferay 7.3.5 und try to create an elasticSearch.
I tried to index one of the entities I have in the database.</p>
<p>I followed the Learning Path on the Developer Portal about
"Enabling Search and Indexing". In this Example the Search
is done directly on the JSP which shows the Search Results like this...</p>
<p> </p>
<pre><code class="language-java">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);</code></pre>
<p>What I did is move this code to Java mode so that not much of the
Java is included with JSP</p>
<pre><code class="language-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);
.....
}</code></pre>
<p>But when searching, I always get empty search results from the hits
elements As shown:</p>
<pre><code>{docs={}, length=0, query=null]</code></pre>
<p>Note that the indexing process works well without errors and the
index contains the required documents, as I can see that by using kibana</p>
<p>Where is the error?</p>
<p>