-
Type: New Feature
-
Status: Resolved
-
Priority: Minor
-
Resolution: Fixed
-
Affects Version/s: 7.3
-
Component/s: Elasticsearch, Query & PageProvider
-
Tags:
Sometime we need a different mapping between Nuxeo field and Elasticsearch index. For instance if we want to use an ngram index on dc:title instead of a fulltext search.
A solution is to add an Elasticsearch hints syntax similar to Oracle,
using 3 keywords INDEX, ANALYZER and OPERATOR:
-- Use an explicit ES field SELECT * FROM Document WHERE /*+ES: INDEX(dc:title.ngram) */ dc:title = 'foo' -- Use fulltext search on explicit list of ES fields, here boosting dc;title SELECT * FROM Document WHERE /*+ES: INDEX(dc:title.fulltext^3,dc:description.fulltext) */ ecm:fulltext = 'foo' -- Use ES operators not present in NXQL SELECT * FROM Document WHERE /*+ES: OPERATOR(regex) */ dc:title = 's.*y' SELECT * FROM Document WHERE /*+ES: OPERATOR(fuzzy) */ dc:title = 'zorkspaces' SELECT * FROM Document WHERE /*+ES: OPERATOR(common) */ dc:title = 'this is bonsai cool' -- Use ES query_string on multiple fields using a fulltext analyzer SELECT * FROM Document WHERE /*+ES: INDEX(dc:title.fulltext,dc:description.fulltext) ANALYZER(fulltext) OPERATOR(query_string) */ dc:title = 'this AND that OR thus'
See documentation
http://doc.nuxeo.com/x/uItH#NXQL-ElasticsearchNXQLHints