Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-72589

Add support for query parsing syntax (e.g Lucene) to Search Portlet

    Details

      Description

      Background
      With 6.2 and Lucene/Solr, it was possible to do some searching using the Lucene syntax with boolean operators and wildcards:
      https://dev.liferay.com/discover/portal/-/knowledge_base/6-2/searching-for-content-in-liferay#advanced-searching
      Lucene's QueryParser was used to parse the input "keywords" into a Lucene query supporting the standard syntax so it could interpreted the operators and other special characters.

      Current situation
      With Liferay 7, switched to a new approach: it uses specific queries using the Query APIs to construct the expected query for a given field such as Match, Phrase, Keyword, Range, TermRange etc. It creates a Query StringQuery (which is for to support parsing in Elasticsearch and Solr) only as a fallback when none of the built-in query-translators can be applied to the input.
      End result, advanced searching is not implemented with this new approach.

      Request
      Add support for Lucene-based syntax so that it can be used with Elasticsearch as well as Solr.


      QA Test Plan
      NOTE: This will not be testable with Solr until LPS-74053 is resolved. While LPS-74053 is still unresolved, it can be tested by disabling the "Did you mean:" spell check feature.

      1. Create wiki pages with the following data:
        Wiki1: title: liferay content: wiki1
        Wiki2: title: portal content: wiki2
        Wiki3: title: java content: wiki3
        Wiki4: title: wiki4 content: liferay portal java lucene
        Wiki5: title: wiki5 content: liferay portal java
        
      1. Configure Search Portlet -> Other Settings > Enable "Use Advanced Search Syntax"

      Syntax Cheat Sheet
      https://lucene.apache.org/core/5_5_0/queryparser/org/apache/lucene/queryparser/classic/package-summary.html#Overview
      https://www.elastic.co/guide/en/elasticsearch/reference/2.4/query-dsl-query-string-query.html

      Test 1

      1. Search for title:(liferay OR java)
        Expected: Search returns 2 results - (Wiki1, Wiki3) 

      Test 2

      1. Search for title: liferay OR content: liferay
        Expected Search should return 3 results - (Wiki1, Wiki4, Wiki5)

      Test 3

      1. Search for content: (liferay AND !lucene)
        Expected Search should return 1 result - (Wiki5)

      Test 4
      TBA (Please add more.)

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                3 Vote for this issue
                Watchers:
                13 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Packages

                  Version Package
                  7.0.0 DXP FP42
                  7.0.6 CE GA7
                  7.0.0 DXP SP8
                  7.0.X
                  7.1.X
                  Master