-
Type: Bug
-
Status: Resolved
-
Priority: Major
-
Resolution: Not A Bug
-
Affects Version/s: 10.10
-
Fix Version/s: None
-
Component/s: Elasticsearch
-
Tags:
-
Backlog priority:500
According to NXP-18228 / NXP-18955 , it is wished that ES STARTSWITH/LIKE/ILIKE with "prefix%" syntax works as with VCS. This is currently not the case for the ecm:name field.
In LTS 2021, the following error is logged:
{"error":{"root_cause":[{"type":"query_shard_exception","reason": "failed to create query: Can only use phrase prefix queries on text fields - not on [ecm:name] which is of type [keyword]" ,"index_uuid":"eRwnq68CTLC8jmo4RQ2t9Q","index":"nuxeo"}],"type":"search_phase_execution_exception","reason":"all shards failed","phase":"query","grouped":true,"failed_shards":[{"shard":0,"index":"nuxeo","node":"Acb14Q8eQzer75-JvOMiXg","reason":{"type":"query_shard_exception","reason":"failed to create query: Can only use phrase prefix queries on text fields - not on [ecm:name] which is of type [keyword]","index_uuid":"eRwnq68CTLC8jmo4RQ2t9Q","index":"nuxeo","caused_by":{"type":"illegal_argument_exception","reason":"Can only use phrase prefix queries on text fields - not on [ecm:name] which is of type [keyword]"}}}]},"status":400}
How to reproduce:
- Install Nuxeo LTS 2019 or LTS2021 with all hotfixes and nuxeo-showcase-content and nuxeo-web-ui
- include in nuxeo.conf:
elasticsearch.override.pageproviders=nxql_search
- boot Nuxeo
- invoke NXQL Search with the query: (CONTAINS type)
SELECT * FROM Document WHERE dc:title LIKE "%Lorem%"
=> returns the Lorem ipsum note
- invoke NXQL Search with the query: (STARTSWITH type)
SELECT * FROM Document WHERE dc:title LIKE "Lorem%"
=> returns the Lorem ipsum note
- invoke NXQL Search with the query: (CONTAINS type)
SELECT * FROM Document WHERE ecm:name LIKE "%Lorem%"
=> returns the Lorem ipsum note
- invoke NXQL Search with the query: (STARTSWITH type)
SELECT * FROM Document WHERE ecm:name LIKE "Lorem%"
=> DOES NOT RETURN ANYTHING => REPRODUCED
=> In LTS 2021, error HTTP 400 in server.log with "reason": "failed to create query: Can only use phrase prefix queries on text fields - not on [ecm:name] which is of type [keyword]"
Commenting in nuxeo.conf:
elasticsearch.override.pageproviders=nxql_search
makes the query
SELECT * FROM Document WHERE ecm:name LIKE "Lorem%"
returning the Lorem ipsum note
The request is to consider whether Elasticsearch should behave in the same way than the DB in the case of the ecm:name and eventually fix the current behavior