Fórum

Liferay 7 - How to Include suggestion dictionary files for search.

Ragunath A, modificado 7 Anos atrás.

Liferay 7 - How to Include suggestion dictionary files for search.

New Member Postagens: 5 Data de Entrada: 22/09/16 Postagens Recentes
Hi,

I'm using Liferay 7 for my project. I need to enable the below property to setup suggestion dictionaries for search.
#index.search.query.suggestion.dictionary[en_US]=com/liferay/portal/search/dependencies/querysuggestions/en_US.txt

The liferay by default doesn't provide the query suggestion file in the above mentioned path. How do I extend the search and add the file in location com/liferay/portal/search/dependencies/querysuggestions/en_US.txt so that the search suggestion dictionary will be picked up and processed during re-indexing of spell check dictionaries. Is there an OSGI way of doing that.

I tried to create a module project with jsp fragment hook, but that did not work.
thumbnail
Andrew Jardine, modificado 7 Anos atrás.

RE: Liferay 7 - How to Include suggestion dictionary files for search.

Liferay Legend Postagens: 2416 Data de Entrada: 22/12/10 Postagens Recentes
I'm not sure if perhaps there is a "more correct" way to do this in the brave new world of Liferay, but have you tried setting the value to --

index.search.query.suggestion.dictionary[en_US]=/META-INF/search_dictionary_en_US.txt


and then placing your file in the TOMCAT_HOME/webapps/ROOT/WEB-INF/classes/META-INF folder? That might work -- although I suspect the better solution is probably to create a bundle that imports the correct (exported) package from the search module so that you can have multiple dictionary files and use the OSGI scoping to control which one is loaded -- something in this branch perhaps? https://github.com/liferay/liferay-portal/tree/master/modules/apps/foundation/portal-search

Can you try the suggested location above? and share with us the code you used for your bundle that didn't work?
Ragunath A, modificado 7 Anos atrás.

RE: Liferay 7 - How to Include suggestion dictionary files for search.

New Member Postagens: 5 Data de Entrada: 22/09/16 Postagens Recentes
Hi Andrew,

Thanks for the response.

I have tried Importing the package, but it doesn't work. I have tried different options using the com.liferay.portal.search.index, com.liferay.portal.search.suggest & com.liferay.portal.kernel.search. The module is loaded fine, but the indexer is unable to find my dictionary file.

Still the error says:
Unable to read com/liferay/portal/kernel/search/content/dictionaries/en_US/dictionary.txt

This is the only file in my module project .
-------------------------------------------------------------
com/liferay/portal/kernel/search/content/dictionaries/en_US/dictionary.txt


This is the entry in bnd.bnd
-----------------------------------

Import-Package:com.liferay.portal.kernel.search;version="7.2.0", *
Bundle-Name: solrIndexWrapper
Bundle-Version: 1.0.0
-sources:true


The existing spellchecker dictionary files provided by liferay resided in portal-impl.jar. I did not try adding the file into META-INF, as this will be additional manual step when migrating to higher lifecycles.
thumbnail
Andrew Jardine, modificado 7 Anos atrás.

RE: Liferay 7 - How to Include suggestion dictionary files for search.

Liferay Legend Postagens: 2416 Data de Entrada: 22/12/10 Postagens Recentes
Hi Ragunath,

Yes, I realize that this is a manual step -- but I wanted you to validate that the setting in the portal-ext performs as expected. If you are able to change that location and have the file load then it means that we don't have to put the file in the same com/liferay/portal/kernel ... location, we just have to make sure that it is available to the Portal's classloader.

I checked the portal-imp, and the path you are referencing is not there. Remember that in 7 the portal-impl is really just the core and that almost all the features are individual modules that you can start/stop. Package paths with kernel in them used to refer to the portal-service.jar in past versions, but now refers to the portal-kernel.jar -- both of these jars (both in the past and now) are in the TOMCAT_HOME/lib/ext making them part of the global classpath. Interestingly, I checked that jar and it's not there as well (which I half expected).

I haven't done what you are trying to do, and OSGI is still a new game for me as well, so I'm shooting in the dark with you emoticon. Two things come to mind. First, and of course I can't recall how to do it (David Nebinger told me once a looooooooooooong time ago, but I can't find it in my notes), but there is a way to declare that you want the bundle to be globally available -- kinda like shoving it into the TOMCAT_HOME/lib/ext.

The second thought is that I know I have read about bundle priorities. Perhaps you need to set your bundle to a higher priority than the Liferay one to ensure that it takes precedence? But I have also read that you shouldn't use priorities for this type of activity -- so not sure if that is the correct approach.

Lastly, I noticed references in what you sent over to SOLR. Are you using SOLR over elasticsearch in your solution?
Ragunath A, modificado 7 Anos atrás.

RE: Liferay 7 - How to Include suggestion dictionary files for search.

New Member Postagens: 5 Data de Entrada: 22/09/16 Postagens Recentes
Hi Andrew,

yes, we are using SOLR for search indexing rather than elastic search. I have removed the elastic search jar from the market place and using SOLR. Now we have a requirement to add custom spell check dictionaries and suggestions for the search.

I too thought of setting up priority. But, for that we need to override the service class to work and this particular class is not a service. Let me know if you have any suggestion on this approach. I'm not getting much help from liferay reference materials over internet as well.

I will evaluate your other suggestions.

Thank you.