Before beginning, you must have a remote Elasticsearch 6 or 7 cluster communicating with Liferay DXP 7.2. See the compatibility matrix for more information
Step 1: Install the Learning to Rank Plugin on Elasticsearch
See the Elasticsearch Learning to Rank plugin documentation to learn about installing the Learning to Rank plugin.
You’ll be running a command like this one, depending on the plugin version you’re installing:
./bin/elasticsearch-plugin install http://es-learn-to-rank.labs.o19s.com/ltr-1.1.0-es6.5.4.zip
If using X-Pack security in your Elasticsearch cluster, there may be additional steps.
Step 2: Training and Uploading a Model
Detailed instructions on training models is outside the scope of this guide. This requires the intervention of data scientists, who can recommend appropriate tools and models. Use what works for you. In doing so, you’ll almost certainly be compiling Judgment lists and feature sets that can be used by the training tool you select to generate a model that produces good search results. This can be a long journey, but once you get to the end of it, you’ll want to upload the model to the Learning to Rank plugin.
Upload the Model to the Learning to Rank Plugin
You’ll upload the model using a POST
request, but first you need to make sure
you have a _ltr
index and a feature set uploaded to the Learning to Rank
plugin. Use Kibana (or even better, the
Monitoring widget),
to make these tasks easier.
-
If you don’t already have an
_ltr
index, create one:PUT _ltr
-
Add a feature set to the
_ltr
index. In this example the set is calledliferay
:POST _ltr/_featureset/liferay { "featureset": { "name": "liferay", "features": [ { "name": "title", "params": [ "keywords" ], "template": { "match": { "title_en_US": "{{keywords}}" } } }, { "name": "content", "params": [ "keywords" ], "template": { "match": { "content_en_US": "{{keywords}}" } } }, { "name": "asset tags", "params": [ "keywords" ], "template": { "match": { "assetTagNames": "{{keywords}}" } } } ] } }
Take note of the syntax used here, since it’s required.
-
Add the trained model to the feature set:
POST _ltr/_featureset/liferay/_createmodel { "model": { "name": "linearregression", "model": { "type": "model/ranklib", "definition": """ ## Linear Regression ## Lambda = 1.0E-10 0:-0.717621803830712 1:-0.717621803830712 2:-2.235841905601106 3:19.546816765721594 """ } } }
This is a very high level set of instructions, because there’s not much to do in Liferay DXP. To learn in more detail about what’s required, see the Learning to Rank plugin’s documentation.
Keep reworking those judgment lists!
Step 3: Enable Learning to Rank
Enable Learning to Rank from Control Panel → Configuration → System Settings → Search → Learning to Rank. There’s a simple on/off configuration and a text field where you must enter the name of the trained model to apply to search queries.
The model in the previous step was named linearregression
, so that’s what
you’d enter.
Figure 1: Enable Learning to Rank in Liferay DXP from the System Settings entry.
That’s all the configuration required to get the Elasticsearch Learning to Rank plugin ingesting a trained model, a feature set, and search queries from Liferay DXP.