Liferay 7 unable to search for generated entity

Sean Megeath, modified 6 Years ago. New Member Posts: 14 Join Date: 3/23/15 Recent Posts
I've followed the instructions from https://dev.liferay.com/de/develop/tutorials/-/knowledge_base/7-0/enabling-search-and-indexing-for-guestbooks, with the exception that my bundle isn't a portlet. I just want the assets I create of my service's type to be search-able using the portal's main search bar. My Indexer appears properly as a component of my bundle, when I look it up in Gogo shell. It also appears on the Server Administration page. I added a log message to my Indexer's reindex function and I can see it creating Documents for all my assets. But when I try to search for one of my assets in the search bar, I get no results and none of my Indexer's functions seem to be called. Is there an extra configuration step I'm missing to make the main search bar include my assets?
thumbnail
Christoph Rabel, modified 6 Years ago. Liferay Legend Posts: 1555 Join Date: 9/24/09 Recent Posts
I think, you need your own facet. I am not 100% sure about that, but it works for us and we have created our own facets. But somebody else replies, it doesn't work for them, so maybe somebody else has a better answer.
https://community.liferay.com/forums/-/message_boards/message/105158768
thumbnail
Andrew Jardine, modified 6 Years ago. Liferay Legend Posts: 2416 Join Date: 12/22/10 Recent Posts
Hi Sean,

I am wondering if the answer is in your last question --
 Is there an extra configuration step I'm missing to make the main search bar include my assets?
I have a few questions to narrow this --

1. Are yo uusing 7/DXP? or 7.1 -- I ask because you link to the 7.0 docs, and I have seen occasions where people are looking at docs (that work pretty much the same in more than one version of Liferay) but the doc URL is not the version they are on.

2. If you are on 7.1 then are you using the new Search Bar, Search Results, etc portlets? or are you using the old school Search portlet. If you are on 7, ignore this question as you only have the old school option.

... ASSUMING you are on 7.0

I believe what you want to do (in case there are missing pieces) is

a. Manage AssetEntry records that correspond to your custom entities (add/update/delete)

b. Create an AssetRenderer for your custom entity (at the very least Liferay needs this to render search results)

c. Create your indexer -- which you have done.

d. Configure your portlet to include your entity model type in the searches

​​​​​​​Can you let us know which of those things you have done?
Sean Megeath, modified 6 Years ago. New Member Posts: 14 Join Date: 3/23/15 Recent Posts
Thanks for the suggestions. I'm afraid my original question was in error. Using the debugger, I was able to see that my Indexer was being used, but not retrieving anything. I'd assumed the indexing was being written, because of a logging message I had in my Indexer's reindexMetrics function where I printed out each created document, but once I used elasticsearch's REST interface to query it, nothing had been saved. I'll be trying to figure out what's going wrong with that. Just in case you have some suggestions on this new issue, I'll answer your questions:

I'm using 7.0.
a. I made changes to my _LocalServiceImpl for https://dev.liferay.com/de/develop/tutorials/-/knowledge_base/7-0/handling-indexing-in-the-guestbook-service-layer and https://dev.liferay.com/de/develop/tutorials/-/knowledge_base/7-0/handling-assets-at-the-guestbook-service-layer. I'm able to retrieve assets of my type using AssetEntryLocalServiceUtil.
b. I didn't create an AssetRenderer. Is that required or optional, just to see some kind of results?
c. Done, but somethings up with writing.
d. Is that the part where I put the <indexer-class> tag in a liferay-portlet.xml? My bundle isn't a portlet. I'm trying to make my data show up in the main search results.
thumbnail
Andrew Jardine, modified 6 Years ago. Liferay Legend Posts: 2416 Join Date: 12/22/10 Recent Posts
Hey Sean,

hahah -- all good, we all have those oopsies sometimes. Better you find it than one of your peers ;)

The AssetRenderer is required for a couple of reasons. First and foremost, the default behaviour for the search portlet out of the box is to use the asset renderer when trying to render a result on the search results view. If you don't have an asset renderer defined the you will likely end up with a NPE exception in the results view when tht particular item rendering is attempted. 

I believe it is also necessary to have the option to include the entity in the Asset Types when you are configuring the portlet. The configuration I am referencing is not in the portlet descriptor but rather the configuration settings for the portlet on the page. So if you go to Page X and have the search portlet there, then when you hover on the portlet, the "portlet topper" will appear. The topper should contain a three-dot mene and one of the options in that menu is configuration. In the resulting modal you can set the entities to be included in the search (see screenshot) but to have your custom entity show up here, I beleive you need to have an asset renderer defined for it.