Details
-
Bug
-
Status: Closed
-
Resolution: Fixed
-
7.0.2 CE GA3, 7.0.0 DXP SP2, 7.0.0 DXP FP13
-
7.0.x
-
Committed
-
1
-
3
-
Regression Bug
Description
Background
com.liferay.portal.kernel.search.generic.StringQuery is meant to support "raw" searches means the input is not transformed, but parsed as-is by the underlying search engine connector.
However it does not override the accept method so it goes to BaseQueryImpl which returns null and this is generating incorrect search results depending on the way the StringQuery is used because the related StringQueryTranslator implementation(com.liferay.portal.search.solr.internal.query.StringQueryTranslatorImpl or com.liferay.portal.search.elasticsearch.internal.query.StringQueryTranslatorImpl is not invoked.
Steps to Test
- Create 2 wikis or blogs or whatever asset which has as a title field in the search index with title "java" and "eclipse"
- Create another asset with an arbitrary title
- Execute the following Groovy-script from the Server Admin:
import com.liferay.portal.kernel.search.SearchContext; import com.liferay.portal.kernel.search.IndexSearcherHelperUtil; import com.liferay.portal.kernel.search.generic.StringQuery; import com.liferay.portal.kernel.security.auth.CompanyThreadLocal; SearchContext searchContext = new SearchContext(); searchContext.setCompanyId(CompanyThreadLocal.getCompanyId()); StringQuery stringQuery = new StringQuery("title:(java OR eclipse)"); out.println("Search Count = " + IndexSearcherHelperUtil.searchCount(searchContext, stringQuery));
Expected Result: Search Count = 2
Actual Result: Search Count = 0
Result is the same when using Solr.
Solution Notes
https://github.com/liferay/liferay-portal/blob/7.0.x/portal-kernel/src/com/liferay/portal/kernel/search/generic/StringQuery.java
/** * Provides support for parsing raw, human readable query syntax. No * transformation is made on user input. * * <p> * The actual query syntax and any further processing are dependent on your * search engine's implementation details. Consult your search provider's * documentation for more information. * </p> *