Details
-
Story
-
Status: Closed
-
Trivial
-
Resolution: Completed
-
None
-
7.0.x
-
Committed
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.
- 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
- 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
- Search for title:(liferay OR java)
Expected: Search returns 2 results - (Wiki1, Wiki3)
Test 2
- Search for title: liferay OR content: liferay
Expected Search should return 3 results - (Wiki1, Wiki4, Wiki5)
Test 3
- Search for content: (liferay AND !lucene)
Expected Search should return 1 result - (Wiki5)
Test 4
TBA (Please add more.)
Attachments
Issue Links
- causes
-
LPS-81205 Remove "Use Advanced Search Syntax" option from Search Portlet in 7.0.x. It was accidentally backported
- Closed
- depends on
-
LPS-72098 StringQuery does not support query visitor
- Closed
-
LPS-74053 Search portlet crashes with an Advanced Search Syntax query and Solr
- Closed
-
LRDOCS-3837 Re-Document Advanced Search Syntax (Lucene)
-
- Closed
-
- relates
-
LPS-80814 New search bar doesn't have an option to configure advanced search syntax
- Closed
-
LRDOCS-3800 Create a breaking change for the new search syntax
-
- Closed
-