Message Boards
Indexing Entity without storing to DB
Indexing Entity without storing to DB
New Member Posts: 4 Join Date: 7/5/21 Recent PostsRE: Indexing Entity without storing to DB
Liferay Legend Posts: 6403 Join Date: 9/23/08 Recent PostsYes, of course you can. The framework does not care where you get the data (that you display) from.
RE: RE: Indexing Entity without storing to DB
New Member Posts: 4 Join Date: 7/5/21 Recent PostsI am looking for solution for DXP 7.0
I have used liferay
sample guestbook entry entity for POC.
I want to save entity to
search index but not store in database.
So in the
EntrylocalServiceImpl ,I have removed the line
entryPersistence.update(entry);
I have replace it with following code:
Indexer<Entry> indexer =
IndexerRegistryUtil.nullSafeGetIndexer(Entry.class);
indexer.reindex(entry);
but it doesnt trigger index and the doReindex method of the
EntryIndexer class is not getting invoked.
Any alternative to
achieve this?
RE: RE: Indexing Entity without storing to DB
Expert Posts: 291 Join Date: 2/13/13 Recent PostsNishith, did you test the sample? Is search and indexing working before you change anything?
RE: RE: Indexing Entity without storing to DB
New Member Posts: 4 Join Date: 7/5/21 Recent Posts@Russel
Yes. If I add the
entryPersistence.update(entry);
The entry gets indexed. Once I remove that line. It does not index.
RE: RE: Indexing Entity without storing to DB
Expert Posts: 291 Join Date: 2/13/13 Recent PostsOkay, your indexing code looks fine to me, and search and indexing is working as expected using the usual mechanism. I think one easy thing you should try is removing the @Indexable annotation from the method. I don't know all that this does, but it's probably kicking off an indexing action (delete or reindex) whenever a persistence call is made. I don't know why it would get in the way of your manual indexing code, but it might be a feature of the annotation (sanitize any other indexing calls that might interfere, or something). I'm on a limb with these guesses, but removing teh annotation is probably worth a shot, if you haven't already.
RE: RE: Indexing Entity without storing to DB
New Member Posts: 4 Join Date: 7/5/21 Recent Posts@Russel
I have already tried removing the annotation. It
DOES NOT help.
RE: Indexing Entity without storing to DB
Expert Posts: 291 Join Date: 2/13/13 Recent PostsNow that I come back to this Nishith, I'm going to conclude that you cannot do this on Liferay 7.0. I believe it was Liferay 7.2 that introduced the idea of applications using their own index as their primary storage. But you would not be doing this in a SB app.
Some of the DXP apps that use it are Synonym Sets and Result Rankings.
This ticket for documentation has some code snipopets (they look like they're for 7.2).