Basic setup and tools to debug Elasticsearch queries

This article is a basic guide on how to view the queries Liferay produces and provide ways that developers can understand the results retrieved from Elasticsearch. These recommendations assume you are working in a development environment.

Three basic ways to track what is happening during a search are:

Environment

  • DXP 7.0 - 7.2
  • Elastic Stack 6.x and 7.x
  • Kibana 6.x and 7.x

Kibana

Kibana is Elasticsearch's tool for visualizing and analyzing Elasticsearch data. First, you need to set up Kibana. A quick description of this process can be found here: Installing Liferay Enterprise Search Monitoring.

If you are using embedded Elasticsearch for development purposes, you'll need to use the Kibana OSS matching the embedded version. (The embedded Elasticsearch is the Open Source version which must be matched with the Open Source version of Kibana otherwise Kibana may not be able to connect.) The version can be found by going to Control Panel > Configuration > Search; it is the Client Version (on DXP 7.1 and DXP 7.2). 

Elasticsearch_version.png

In this example, kibana-oss-6.5.0 is needed. Find it on elastic's site, be sure it's the OSS version: https://www.elastic.co/downloads/past-releases#kibana-oss

Kibana_OSS_on_ES_site.png

Once Kibana is running and connected to Elasticsearch, you want to go to the Dev Tools tab where queries can be executed. Seeing how documents are indexed into Elasticsearch is one of the easiest ways to understand how they can be looked up, but if you're just getting used to Elasticsearch queries getting the syntax just right can be frustrating. An easy starting point if you're using a mostly empty Elasticsearch is thematch_all query:

GET _search
{
 "query": {
    "match_all": {}
  }
}

but by default, this only returns 10 results. A new Liferay instance will already have over 300 entries indexed. Try using:

GET _search
{
  "size": 500,
  "query": {
    "match_all": {}
  }
}

And then simply Ctrl + F the Results side after running the query using the green play button to find any uniquely named assets.

Let's do a quick example and add a Web Content:

  1. Go to [site name] > Content & Data > Web Content
  2. Click the blue plus
  3. Title it "Testing Article" and add content "The content of my web content."
  4. On the right side under Properties under METADATA type "MyTag" and enter
  5. Publish the article

Now go to Kibana and run the 500 size match query. Go to the results area and search for "Testing". This takes you straight to the document indexed for the Web Content created in Liferay. You can see the title is indexed into several different fields: title_en_US, localized_title_zh_CN and the other localized_title fields.

Kibana_Testing_search.png

If you want more details on the field mappings, in Liferay go to Control Panel > Configuration > Search and select the Field Mappings tab.

Search Insights Widget

(Available as of DXP 7.1.)

The simplest approach to analyzing queries related to Search Bar searches is to add the Search Insights widget.

As an administrator go to your search page and click the +. Under Widgets, search for "Search Insights", it is located under the Search category, then place it on the page.

Now when searching, the portlet will show a Request String and Response String.

Note: The JSON you will get as a request string is pruned from several Elasticsearch query defaults for clarity. If you want to see the full request JSON that Elasticsearch processed you will need to adjust the log levels for your Elasticsearch server.

You can use the Request String, which conveniently has explain set to true so when used in Kibana you'll be able to see why the documents returned are ranked the way they are. You can copy this Request String over to Kibana and run it to see exactly what Elasticsearch is returning and/or format it to parse through the query manually. To do this, in Kibana's developer tab, enter:

GET _search
[Request String]

You can then select the [Request String] portion, click on the Wrench icon in the upper left-hand corner, then select Auto Indent. You are also able to run the query to see the results returned from Elasticsearch.

Note: There is a post-permission filtering mechanism applied on documents returned by Elasticsearch in DXP. Therefore running the Request String in Kibana may return more documents than what will be displayed to the user.

Search Insights will work for many types of query debugging, but it only works where you can deploy the portlet, so for example, searches from any of the administrator portlets can't be accessed in this way.

Logging

In order to see every query sent to Elasticsearch you can add logging to the ElasticsearchIndexSearcher class. To do so navigate to the Control Panel > Configuration > Server Administration. Select the Log Levels tab.

When using the Elasticsearch 6 connector, add com.liferay.portal.search.elasticsearch6.internal.ElasticsearchIndexSearcher set to INFO.

Using the Elasticsearch 7 connector, add com.liferay.portal.search.elasticsearch7.internal.ElasticsearchIndexSearcher set to INFO.

Note: The JSON you will get as a request string is pruned from several Elasticsearch query defaults for clarity. If you want to see the full request JSON that Elasticsearch processed you will need to adjust the log levels for your Elasticsearch server.

Using the Solr 7 connector, add:

com.liferay.portal.search.solr7.internal.SolrIndexSearcher set to INFO.

Now when a query is searched the logs will record twice in this pattern:

2020-04-22 17:27:58.269 INFO  [http-nio-8080-exec-8][ElasticsearchIndexSearcher:134] The search engine processed [SEARCH_QUERY] in 836 ms
2020-04-22 17:27:58.276 INFO  [http-nio-8080-exec-8][ElasticsearchIndexSearcher:182] Searching [QUERY_OBJECT] took 922 ms

The QUERY_OBJECT is mostly useless for our purposes, it includes what was queried but has additional information which Elasticsearch doesn't recognize. We want to focus on the SEARCH_QUERY.

As a quick example, I'll add a Web Content which contains "Search_term" in it's content. I'm going to search from the default site's search bar for "Search_term". The query is as follows:

{"from":0,"size":20,"query":{"bool":{"must":[{"bool":{"must":[{"bool":{"should":[{"bool":{"must":[{"match":{"comments":{"query":"Search_term"}}}],"should":[{"match_phrase":{"comments":{"query":"Search_term","slop":50}}},{"match_phrase":{"comments":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"match":{"content":{"query":"Search_term"}}}],"should":[{"match_phrase":{"content":{"query":"Search_term","slop":50}}},{"match_phrase":{"content":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"match":{"description":{"query":"Search_term"}}}],"should":[{"match_phrase":{"description":{"query":"Search_term","slop":50}}},{"match_phrase":{"description":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"should":[{"wildcard":{"properties":{"wildcard":"*search_term*"}}}]}},{"bool":{"must":[{"bool":{"should":[{"match":{"title":{"query":"Search_term"}}},{"match_phrase_prefix":{"title":{"query":"Search_term"}}}]}}],"should":[{"match_phrase":{"title":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"match":{"url":{"query":"Search_term"}}}],"should":[{"match_phrase":{"url":{"query":"Search_term","slop":50}}},{"match_phrase":{"url":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"should":[{"wildcard":{"userName":{"wildcard":"*search_term*"}}}]}},{"bool":{"must":[{"match":{"assetCategoryTitles_en_US":{"query":"Search_term"}}}],"should":[{"match_phrase":{"assetCategoryTitles_en_US":{"query":"Search_term","slop":50}}},{"match_phrase":{"assetCategoryTitles_en_US":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"bool":{"should":[{"match":{"assetTagNames_en_US":{"query":"Search_term"}}},{"match_phrase_prefix":{"assetTagNames_en_US":{"query":"Search_term"}}}]}}],"should":[{"match_phrase":{"assetTagNames_en_US":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"match":{"content":{"query":"Search_term"}}}],"should":[{"match_phrase":{"content":{"query":"Search_term","slop":50}}},{"match_phrase":{"content":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"match":{"content_en_US":{"query":"Search_term"}}}],"should":[{"match_phrase":{"content_en_US":{"query":"Search_term","slop":50}}},{"match_phrase":{"content_en_US":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"bool":{"should":[{"match":{"title":{"query":"Search_term"}}},{"match_phrase_prefix":{"title":{"query":"Search_term"}}}]}}],"should":[{"match_phrase":{"title":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"bool":{"should":[{"match":{"title_en_US":{"query":"Search_term"}}},{"match_phrase_prefix":{"title_en_US":{"query":"Search_term"}}}]}}],"should":[{"match_phrase":{"title_en_US":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"match":{"ddmContent":{"query":"Search_term"}}}],"should":[{"match_phrase":{"ddmContent":{"query":"Search_term","slop":50}}},{"match_phrase":{"ddmContent":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"match":{"extension":{"query":"Search_term"}}}],"should":[{"match_phrase":{"extension":{"query":"Search_term","slop":50}}},{"match_phrase":{"extension":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"match":{"fileEntryTypeId":{"query":"Search_term"}}}],"should":[{"match_phrase":{"fileEntryTypeId":{"query":"Search_term","slop":50}}},{"match_phrase":{"fileEntryTypeId":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"should":[{"wildcard":{"path":{"wildcard":"*search_term*"}}}]}},{"bool":{"must":[{"match":{"content_en_US":{"query":"Search_term"}}}],"should":[{"match_phrase":{"content_en_US":{"query":"Search_term","slop":50}}},{"match_phrase":{"content_en_US":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"match":{"city":{"query":"Search_term"}}}],"should":[{"match_phrase":{"city":{"query":"Search_term","slop":50}}},{"match_phrase":{"city":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"match":{"country":{"query":"Search_term"}}}],"should":[{"match_phrase":{"country":{"query":"Search_term","slop":50}}},{"match_phrase":{"country":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"should":[{"wildcard":{"emailAddress":{"wildcard":"*search_term*"}}}]}},{"bool":{"must":[{"match":{"firstName":{"query":"Search_term"}}}],"should":[{"match_phrase":{"firstName":{"query":"Search_term","slop":50}}},{"match_phrase":{"firstName":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"match":{"fullName":{"query":"Search_term"}}}],"should":[{"match_phrase":{"fullName":{"query":"Search_term","slop":50}}},{"match_phrase":{"fullName":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"match":{"jobTitle":{"query":"Search_term"}}}],"should":[{"match_phrase":{"jobTitle":{"query":"Search_term","slop":50}}},{"match_phrase":{"jobTitle":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"match":{"lastName":{"query":"Search_term"}}}],"should":[{"match_phrase":{"lastName":{"query":"Search_term","slop":50}}},{"match_phrase":{"lastName":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"match":{"middleName":{"query":"Search_term"}}}],"should":[{"match_phrase":{"middleName":{"query":"Search_term","slop":50}}},{"match_phrase":{"middleName":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"match":{"region":{"query":"Search_term"}}}],"should":[{"match_phrase":{"region":{"query":"Search_term","slop":50}}},{"match_phrase":{"region":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"should":[{"wildcard":{"screenName":{"wildcard":"*search_term*"}}}]}},{"bool":{"must":[{"match":{"street":{"query":"Search_term"}}}],"should":[{"match_phrase":{"street":{"query":"Search_term","slop":50}}},{"match_phrase":{"street":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"match":{"zip":{"query":"Search_term"}}}],"should":[{"match_phrase":{"zip":{"query":"Search_term","slop":50}}},{"match_phrase":{"zip":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"match":{"content_en_US":{"query":"Search_term"}}}],"should":[{"match_phrase":{"content_en_US":{"query":"Search_term","slop":50}}},{"match_phrase":{"content_en_US":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"match":{"subtitle":{"query":"Search_term"}}}],"should":[{"match_phrase":{"subtitle":{"query":"Search_term","slop":50}}},{"match_phrase":{"subtitle":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"bool":{"should":[{"match":{"title_en_US":{"query":"Search_term"}}},{"match_phrase_prefix":{"title_en_US":{"query":"Search_term"}}}]}}],"should":[{"match_phrase":{"title_en_US":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"should":[{"wildcard":{"userName":{"wildcard":"*search_term*"}}}]}},{"bool":{"must":[{"match":{"ddmContent_en_US":{"query":"Search_term"}}}],"should":[{"match_phrase":{"ddmContent_en_US":{"query":"Search_term","slop":50}}},{"match_phrase":{"ddmContent_en_US":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"match":{"content_en_US":{"query":"Search_term"}}}],"should":[{"match_phrase":{"content_en_US":{"query":"Search_term","slop":50}}},{"match_phrase":{"content_en_US":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"bool":{"should":[{"match":{"title_en_US":{"query":"Search_term"}}},{"match_phrase_prefix":{"title_en_US":{"query":"Search_term"}}}]}}],"should":[{"match_phrase":{"title_en_US":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"should":[{"wildcard":{"userName":{"wildcard":"*search_term*"}}}]}},{"bool":{"must":[{"match":{"ddmContent_nl_NL":{"query":"Search_term"}}}],"should":[{"match_phrase":{"ddmContent_nl_NL":{"query":"Search_term","slop":50}}},{"match_phrase":{"ddmContent_nl_NL":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"match":{"ddmContent_sv_SE":{"query":"Search_term"}}}],"should":[{"match_phrase":{"ddmContent_sv_SE":{"query":"Search_term","slop":50}}},{"match_phrase":{"ddmContent_sv_SE":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"match":{"ddmContent_ja_JP":{"query":"Search_term"}}}],"should":[{"match_phrase":{"ddmContent_ja_JP":{"query":"Search_term","slop":50}}},{"match_phrase":{"ddmContent_ja_JP":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"match":{"ddmContent_en_US":{"query":"Search_term"}}}],"should":[{"match_phrase":{"ddmContent_en_US":{"query":"Search_term","slop":50}}},{"match_phrase":{"ddmContent_en_US":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"match":{"ddmContent_hu_HU":{"query":"Search_term"}}}],"should":[{"match_phrase":{"ddmContent_hu_HU":{"query":"Search_term","slop":50}}},{"match_phrase":{"ddmContent_hu_HU":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"match":{"ddmContent_ar_SA":{"query":"Search_term"}}}],"should":[{"match_phrase":{"ddmContent_ar_SA":{"query":"Search_term","slop":50}}},{"match_phrase":{"ddmContent_ar_SA":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"match":{"ddmContent_ca_ES":{"query":"Search_term"}}}],"should":[{"match_phrase":{"ddmContent_ca_ES":{"query":"Search_term","slop":50}}},{"match_phrase":{"ddmContent_ca_ES":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"match":{"ddmContent_de_DE":{"query":"Search_term"}}}],"should":[{"match_phrase":{"ddmContent_de_DE":{"query":"Search_term","slop":50}}},{"match_phrase":{"ddmContent_de_DE":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"match":{"ddmContent_fr_FR":{"query":"Search_term"}}}],"should":[{"match_phrase":{"ddmContent_fr_FR":{"query":"Search_term","slop":50}}},{"match_phrase":{"ddmContent_fr_FR":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"match":{"ddmContent_pt_BR":{"query":"Search_term"}}}],"should":[{"match_phrase":{"ddmContent_pt_BR":{"query":"Search_term","slop":50}}},{"match_phrase":{"ddmContent_pt_BR":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"match":{"ddmContent_fi_FI":{"query":"Search_term"}}}],"should":[{"match_phrase":{"ddmContent_fi_FI":{"query":"Search_term","slop":50}}},{"match_phrase":{"ddmContent_fi_FI":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"match":{"ddmContent_zh_CN":{"query":"Search_term"}}}],"should":[{"match_phrase":{"ddmContent_zh_CN":{"query":"Search_term","slop":50}}},{"match_phrase":{"ddmContent_zh_CN":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"match":{"ddmContent_es_ES":{"query":"Search_term"}}}],"should":[{"match_phrase":{"ddmContent_es_ES":{"query":"Search_term","slop":50}}},{"match_phrase":{"ddmContent_es_ES":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"match":{"articleId":{"query":"Search_term"}}}],"should":[{"match_phrase":{"articleId":{"query":"Search_term","slop":50}}},{"match_phrase":{"articleId":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"match":{"classPK":{"query":"Search_term"}}}],"should":[{"match_phrase":{"classPK":{"query":"Search_term","slop":50}}},{"match_phrase":{"classPK":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"match":{"content_zh_CN":{"query":"Search_term"}}}],"should":[{"match_phrase":{"content_zh_CN":{"query":"Search_term","slop":50}}},{"match_phrase":{"content_zh_CN":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"match":{"content_fi_FI":{"query":"Search_term"}}}],"should":[{"match_phrase":{"content_fi_FI":{"query":"Search_term","slop":50}}},{"match_phrase":{"content_fi_FI":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"match":{"content_ca_ES":{"query":"Search_term"}}}],"should":[{"match_phrase":{"content_ca_ES":{"query":"Search_term","slop":50}}},{"match_phrase":{"content_ca_ES":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"match":{"content_de_DE":{"query":"Search_term"}}}],"should":[{"match_phrase":{"content_de_DE":{"query":"Search_term","slop":50}}},{"match_phrase":{"content_de_DE":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"match":{"content_hu_HU":{"query":"Search_term"}}}],"should":[{"match_phrase":{"content_hu_HU":{"query":"Search_term","slop":50}}},{"match_phrase":{"content_hu_HU":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"match":{"content_pt_BR":{"query":"Search_term"}}}],"should":[{"match_phrase":{"content_pt_BR":{"query":"Search_term","slop":50}}},{"match_phrase":{"content_pt_BR":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"match":{"content_es_ES":{"query":"Search_term"}}}],"should":[{"match_phrase":{"content_es_ES":{"query":"Search_term","slop":50}}},{"match_phrase":{"content_es_ES":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"match":{"content_ar_SA":{"query":"Search_term"}}}],"should":[{"match_phrase":{"content_ar_SA":{"query":"Search_term","slop":50}}},{"match_phrase":{"content_ar_SA":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"match":{"content_sv_SE":{"query":"Search_term"}}}],"should":[{"match_phrase":{"content_sv_SE":{"query":"Search_term","slop":50}}},{"match_phrase":{"content_sv_SE":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"match":{"content_nl_NL":{"query":"Search_term"}}}],"should":[{"match_phrase":{"content_nl_NL":{"query":"Search_term","slop":50}}},{"match_phrase":{"content_nl_NL":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"match":{"content_fr_FR":{"query":"Search_term"}}}],"should":[{"match_phrase":{"content_fr_FR":{"query":"Search_term","slop":50}}},{"match_phrase":{"content_fr_FR":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"match":{"content_ja_JP":{"query":"Search_term"}}}],"should":[{"match_phrase":{"content_ja_JP":{"query":"Search_term","slop":50}}},{"match_phrase":{"content_ja_JP":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"match":{"content_en_US":{"query":"Search_term"}}}],"should":[{"match_phrase":{"content_en_US":{"query":"Search_term","slop":50}}},{"match_phrase":{"content_en_US":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"match":{"description_ja_JP":{"query":"Search_term"}}}],"should":[{"match_phrase":{"description_ja_JP":{"query":"Search_term","slop":50}}},{"match_phrase":{"description_ja_JP":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"match":{"description_fr_FR":{"query":"Search_term"}}}],"should":[{"match_phrase":{"description_fr_FR":{"query":"Search_term","slop":50}}},{"match_phrase":{"description_fr_FR":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"match":{"description_fi_FI":{"query":"Search_term"}}}],"should":[{"match_phrase":{"description_fi_FI":{"query":"Search_term","slop":50}}},{"match_phrase":{"description_fi_FI":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"match":{"description_ca_ES":{"query":"Search_term"}}}],"should":[{"match_phrase":{"description_ca_ES":{"query":"Search_term","slop":50}}},{"match_phrase":{"description_ca_ES":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"match":{"description_de_DE":{"query":"Search_term"}}}],"should":[{"match_phrase":{"description_de_DE":{"query":"Search_term","slop":50}}},{"match_phrase":{"description_de_DE":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"match":{"description_hu_HU":{"query":"Search_term"}}}],"should":[{"match_phrase":{"description_hu_HU":{"query":"Search_term","slop":50}}},{"match_phrase":{"description_hu_HU":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"match":{"description_ar_SA":{"query":"Search_term"}}}],"should":[{"match_phrase":{"description_ar_SA":{"query":"Search_term","slop":50}}},{"match_phrase":{"description_ar_SA":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"match":{"description_pt_BR":{"query":"Search_term"}}}],"should":[{"match_phrase":{"description_pt_BR":{"query":"Search_term","slop":50}}},{"match_phrase":{"description_pt_BR":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"match":{"description_zh_CN":{"query":"Search_term"}}}],"should":[{"match_phrase":{"description_zh_CN":{"query":"Search_term","slop":50}}},{"match_phrase":{"description_zh_CN":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"match":{"description_es_ES":{"query":"Search_term"}}}],"should":[{"match_phrase":{"description_es_ES":{"query":"Search_term","slop":50}}},{"match_phrase":{"description_es_ES":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"match":{"description_en_US":{"query":"Search_term"}}}],"should":[{"match_phrase":{"description_en_US":{"query":"Search_term","slop":50}}},{"match_phrase":{"description_en_US":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"match":{"description_nl_NL":{"query":"Search_term"}}}],"should":[{"match_phrase":{"description_nl_NL":{"query":"Search_term","slop":50}}},{"match_phrase":{"description_nl_NL":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"match":{"description_sv_SE":{"query":"Search_term"}}}],"should":[{"match_phrase":{"description_sv_SE":{"query":"Search_term","slop":50}}},{"match_phrase":{"description_sv_SE":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"match":{"entryClassPK":{"query":"Search_term"}}}],"should":[{"match_phrase":{"entryClassPK":{"query":"Search_term","slop":50}}},{"match_phrase":{"entryClassPK":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"bool":{"should":[{"match":{"title_es_ES":{"query":"Search_term"}}},{"match_phrase_prefix":{"title_es_ES":{"query":"Search_term"}}}]}}],"should":[{"match_phrase":{"title_es_ES":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"bool":{"should":[{"match":{"title_ar_SA":{"query":"Search_term"}}},{"match_phrase_prefix":{"title_ar_SA":{"query":"Search_term"}}}]}}],"should":[{"match_phrase":{"title_ar_SA":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"bool":{"should":[{"match":{"title_nl_NL":{"query":"Search_term"}}},{"match_phrase_prefix":{"title_nl_NL":{"query":"Search_term"}}}]}}],"should":[{"match_phrase":{"title_nl_NL":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"bool":{"should":[{"match":{"title_zh_CN":{"query":"Search_term"}}},{"match_phrase_prefix":{"title_zh_CN":{"query":"Search_term"}}}]}}],"should":[{"match_phrase":{"title_zh_CN":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"bool":{"should":[{"match":{"title_ja_JP":{"query":"Search_term"}}},{"match_phrase_prefix":{"title_ja_JP":{"query":"Search_term"}}}]}}],"should":[{"match_phrase":{"title_ja_JP":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"bool":{"should":[{"match":{"title_pt_BR":{"query":"Search_term"}}},{"match_phrase_prefix":{"title_pt_BR":{"query":"Search_term"}}}]}}],"should":[{"match_phrase":{"title_pt_BR":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"bool":{"should":[{"match":{"title_sv_SE":{"query":"Search_term"}}},{"match_phrase_prefix":{"title_sv_SE":{"query":"Search_term"}}}]}}],"should":[{"match_phrase":{"title_sv_SE":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"bool":{"should":[{"match":{"title_fi_FI":{"query":"Search_term"}}},{"match_phrase_prefix":{"title_fi_FI":{"query":"Search_term"}}}]}}],"should":[{"match_phrase":{"title_fi_FI":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"bool":{"should":[{"match":{"title_en_US":{"query":"Search_term"}}},{"match_phrase_prefix":{"title_en_US":{"query":"Search_term"}}}]}}],"should":[{"match_phrase":{"title_en_US":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"bool":{"should":[{"match":{"title_ca_ES":{"query":"Search_term"}}},{"match_phrase_prefix":{"title_ca_ES":{"query":"Search_term"}}}]}}],"should":[{"match_phrase":{"title_ca_ES":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"bool":{"should":[{"match":{"title_de_DE":{"query":"Search_term"}}},{"match_phrase_prefix":{"title_de_DE":{"query":"Search_term"}}}]}}],"should":[{"match_phrase":{"title_de_DE":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"bool":{"should":[{"match":{"title_hu_HU":{"query":"Search_term"}}},{"match_phrase_prefix":{"title_hu_HU":{"query":"Search_term"}}}]}}],"should":[{"match_phrase":{"title_hu_HU":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"bool":{"should":[{"match":{"title_fr_FR":{"query":"Search_term"}}},{"match_phrase_prefix":{"title_fr_FR":{"query":"Search_term"}}}]}}],"should":[{"match_phrase":{"title_fr_FR":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"should":[{"wildcard":{"userName":{"wildcard":"*search_term*"}}}]}},{"bool":{"must":[{"match":{"description":{"query":"Search_term"}}}],"should":[{"match_phrase":{"description":{"query":"Search_term","slop":50}}},{"match_phrase":{"description":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"match":{"description_en_US":{"query":"Search_term"}}}],"should":[{"match_phrase":{"description_en_US":{"query":"Search_term","slop":50}}},{"match_phrase":{"description_en_US":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"bool":{"should":[{"match":{"title":{"query":"Search_term"}}},{"match_phrase_prefix":{"title":{"query":"Search_term"}}}]}}],"should":[{"match_phrase":{"title":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"bool":{"should":[{"match":{"title_en_US":{"query":"Search_term"}}},{"match_phrase_prefix":{"title_en_US":{"query":"Search_term"}}}]}}],"should":[{"match_phrase":{"title_en_US":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"match":{"content_en_US":{"query":"Search_term"}}}],"should":[{"match_phrase":{"content_en_US":{"query":"Search_term","slop":50}}},{"match_phrase":{"content_en_US":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"bool":{"should":[{"match":{"title_en_US":{"query":"Search_term"}}},{"match_phrase_prefix":{"title_en_US":{"query":"Search_term"}}}]}}],"should":[{"match_phrase":{"title_en_US":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"match":{"description_en_US":{"query":"Search_term"}}}],"should":[{"match_phrase":{"description_en_US":{"query":"Search_term","slop":50}}},{"match_phrase":{"description_en_US":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"bool":{"should":[{"match":{"title_en_US":{"query":"Search_term"}}},{"match_phrase_prefix":{"title_en_US":{"query":"Search_term"}}}]}}],"should":[{"match_phrase":{"title_en_US":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"match":{"content":{"query":"Search_term"}}}],"should":[{"match_phrase":{"content":{"query":"Search_term","slop":50}}},{"match_phrase":{"content":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"match":{"description":{"query":"Search_term"}}}],"should":[{"match_phrase":{"description":{"query":"Search_term","slop":50}}},{"match_phrase":{"description":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"must":[{"bool":{"should":[{"match":{"title":{"query":"Search_term"}}},{"match_phrase_prefix":{"title":{"query":"Search_term"}}}]}}],"should":[{"match_phrase":{"title":{"query":"Search_term","boost":2.0}}}]}},{"bool":{"should":[{"wildcard":{"userName":{"wildcard":"*search_term*"}}}]}}]}}]}}],"filter":[{"bool":{"must":[{"term":{"companyId":{"value":"20097"}}},{"bool":{"must":[{"terms":{"groupId":["20121"]}},{"terms":{"scopeGroupId":["20121"]}}]}},{"bool":{"should":[{"bool":{"must":[{"term":{"entryClassName":{"value":"com.liferay.wiki.model.WikiPage"}}},{"terms":{"status":["0"]}}]}},{"bool":{"must":[{"term":{"entryClassName":{"value":"com.liferay.document.library.kernel.model.DLFileEntry"}}},{"term":{"hidden":{"value":"false"}}},{"term":{"hidden":{"value":"false"}}},{"terms":{"status":["0"]}},{"terms":{"status":["0"]}}]}},{"bool":{"must":[{"term":{"entryClassName":{"value":"com.liferay.portal.kernel.model.User"}}},{"term":{"status":{"value":"0"}}},{"term":{"status":{"value":"0"}}}],"must_not":[{"term":{"defaultUser":{"value":"true"}}},{"term":{"defaultUser":{"value":"true"}}}]}},{"bool":{"must":[{"term":{"entryClassName":{"value":"com.liferay.blogs.model.BlogsEntry"}}},{"terms":{"status":["0"]}},{"terms":{"status":["0"]}}]}},{"bool":{"must":[{"term":{"entryClassName":{"value":"com.liferay.dynamic.data.mapping.model.DDMFormInstanceRecord"}}},{"term":{"status":{"value":"0"}}},{"term":{"status":{"value":"0"}}}]}},{"bool":{"must":[{"term":{"entryClassName":{"value":"com.liferay.portal.kernel.model.Layout"}}},{"terms":{"type":["content"]}},{"terms":{"type":["content"]}}]}},{"bool":{"must":[{"term":{"entryClassName":{"value":"com.liferay.document.library.kernel.model.DLFolder"}}},{"term":{"hidden":{"value":"false"}}},{"term":{"hidden":{"value":"false"}}},{"terms":{"status":["0"]}},{"terms":{"status":["0"]}}]}},{"bool":{"must":[{"term":{"entryClassName":{"value":"com.liferay.dynamic.data.lists.model.DDLRecord"}}},{"term":{"status":{"value":"0"}}},{"term":{"recordSetScope":{"value":"0"}}},{"term":{"status":{"value":"0"}}},{"term":{"recordSetScope":{"value":"0"}}}]}},{"bool":{"must":[{"term":{"entryClassName":{"value":"com.liferay.journal.model.JournalArticle"}}},{"term":{"head":{"value":"true"}}},{"terms":{"status":["0"]}}],"should":[{"range":{"expirationDate":{"from":"20200423000623","to":null,"include_lower":false,"include_upper":false,"format":"yyyyMMddHHmmss"}}}]}},{"bool":{"must":[{"term":{"entryClassName":{"value":"com.liferay.journal.model.JournalFolder"}}},{"terms":{"status":["0"]}}]}},{"bool":{"must":[{"term":{"entryClassName":{"value":"com.liferay.message.boards.model.MBMessage"}}},{"term":{"discussion":{"value":"false"}}},{"term":{"discussion":{"value":"false"}}},{"terms":{"status":["0"]}},{"terms":{"status":["0"]}}]}},{"bool":{"must":[{"term":{"entryClassName":{"value":"com.liferay.calendar.model.CalendarBooking"}}},{"terms":{"status":["0"]}},{"terms":{"status":["0"]}}]}},{"bool":{"must":[{"term":{"entryClassName":{"value":"com.liferay.knowledge.base.model.KBArticle"}}}]}}]}}]}}]}},"explain":false,"stored_fields":"*","track_scores":true,"aggregations":{"com_liferay_portal_search_web_category_facet_portlet_CategoryFacetPortlet":{"terms":{"field":"assetCategoryIds","size":10,"min_doc_count":1,"shard_min_doc_count":0,"show_term_doc_count_error":false,"order":[{"_count":"desc"},{"_key":"asc"}]}},"com_liferay_portal_search_web_folder_facet_portlet_FolderFacetPortlet":{"terms":{"field":"folderId","size":10,"min_doc_count":1,"shard_min_doc_count":0,"show_term_doc_count_error":false,"order":[{"_count":"desc"},{"_key":"asc"}]}},"com_liferay_portal_search_web_type_facet_portlet_TypeFacetPortlet":{"terms":{"field":"entryClassName","size":10,"min_doc_count":1,"shard_min_doc_count":0,"show_term_doc_count_error":false,"order":[{"_count":"desc"},{"_key":"asc"}]}},"com_liferay_portal_search_web_tag_facet_portlet_TagFacetPortlet":{"terms":{"field":"assetTagNames.raw","size":10,"min_doc_count":1,"shard_min_doc_count":0,"show_term_doc_count_error":false,"order":[{"_count":"desc"},{"_key":"asc"}]}},"modified":{"range":{"field":"modified","ranges":[{"key":"[20200422230623 TO 20200423000623]","from":"20200422230623","to":"20200423000623"},{"key":"[20200422000623 TO 20200423000623]","from":"20200422000623","to":"20200423000623"},{"key":"[20200416000623 TO 20200423000623]","from":"20200416000623","to":"20200423000623"},{"key":"[20200323000623 TO 20200423000623]","from":"20200323000623","to":"20200423000623"},{"key":"[20190423000623 TO 20200423000623]","from":"20190423000623","to":"20200423000623"}],"keyed":false}},"com_liferay_portal_search_web_user_facet_portlet_UserFacetPortlet":{"terms":{"field":"userName","size":10,"min_doc_count":1,"shard_min_doc_count":0,"show_term_doc_count_error":false,"order":[{"_count":"desc"},{"_key":"asc"}]}},"com_liferay_portal_search_web_site_facet_portlet_SiteFacetPortlet":{"terms":{"field":"groupId","size":10,"min_doc_count":1,"shard_min_doc_count":0,"show_term_doc_count_error":false,"order":[{"_count":"desc"},{"_key":"asc"}]}}},"highlight":{"pre_tags":["<liferay-hl>"],"post_tags":["</liferay-hl>"],"require_field_match":true,"fields":{"content_zh_CN":{"fragment_size":80,"number_of_fragments":3},"title_es_ES":{"fragment_size":80,"number_of_fragments":3},"description_ja_JP":{"fragment_size":80,"number_of_fragments":3},"content_fi_FI":{"fragment_size":80,"number_of_fragments":3},"description_fr_FR":{"fragment_size":80,"number_of_fragments":3},"description":{"fragment_size":80,"number_of_fragments":3},"description_ca_ES":{"fragment_size":80,"number_of_fragments":3},"description_de_DE":{"fragment_size":80,"number_of_fragments":3},"description_hu_HU":{"fragment_size":80,"number_of_fragments":3},"title_ar_SA":{"fragment_size":80,"number_of_fragments":3},"description_ar_SA":{"fragment_size":80,"number_of_fragments":3},"title":{"fragment_size":80,"number_of_fragments":3},"title_nl_NL":{"fragment_size":80,"number_of_fragments":3},"content":{"fragment_size":80,"number_of_fragments":3},"description_pt_BR":{"fragment_size":80,"number_of_fragments":3},"title_ja_JP":{"fragment_size":80,"number_of_fragments":3},"content_sv_SE":{"fragment_size":80,"number_of_fragments":3},"description_es_ES":{"fragment_size":80,"number_of_fragments":3},"title_pt_BR":{"fragment_size":80,"number_of_fragments":3},"content_fr_FR":{"fragment_size":80,"number_of_fragments":3},"title_fi_FI":{"fragment_size":80,"number_of_fragments":3},"description_nl_NL":{"fragment_size":80,"number_of_fragments":3},"title_ca_ES":{"fragment_size":80,"number_of_fragments":3},"content_en_US":{"fragment_size":80,"number_of_fragments":3},"assetCategoryTitles":{"fragment_size":80,"number_of_fragments":3},"content_ca_ES":{"fragment_size":80,"number_of_fragments":3},"content_de_DE":{"fragment_size":80,"number_of_fragments":3},"content_hu_HU":{"fragment_size":80,"number_of_fragments":3},"description_fi_FI":{"fragment_size":80,"number_of_fragments":3},"fullName":{"fragment_size":80,"number_of_fragments":3},"content_pt_BR":{"fragment_size":80,"number_of_fragments":3},"content_es_ES":{"fragment_size":80,"number_of_fragments":3},"content_ar_SA":{"fragment_size":80,"number_of_fragments":3},"title_zh_CN":{"fragment_size":80,"number_of_fragments":3},"description_zh_CN":{"fragment_size":80,"number_of_fragments":3},"content_nl_NL":{"fragment_size":80,"number_of_fragments":3},"title_sv_SE":{"fragment_size":80,"number_of_fragments":3},"content_ja_JP":{"fragment_size":80,"number_of_fragments":3},"description_en_US":{"fragment_size":80,"number_of_fragments":3},"description_sv_SE":{"fragment_size":80,"number_of_fragments":3},"title_en_US":{"fragment_size":80,"number_of_fragments":3},"title_de_DE":{"fragment_size":80,"number_of_fragments":3},"title_hu_HU":{"fragment_size":80,"number_of_fragments":3},"title_fr_FR":{"fragment_size":80,"number_of_fragments":3}}}}

As with the Search Insights portlet, you can use Kibana to format or run the query. Copy the SEARCH_QUERY including it's outer parenthesis and add it to kibana's console in this form:

GET _search
[SEARCH_QUERY]

Kibana_unformated_Query.png

Select the SEARCH_QUERY and click on the Wrench icon in the upper left-hand corner, then select Auto Indent.

The query is now readable and can be executed.

Kibana_formatted_Query.png

We hope this short guide will give you the tools to start exploring Liferay's way of indexing documents and building queries.

Was this article helpful?
1 out of 1 found this helpful