This documentation page talks about the many aspects you can tune for improving the search experience for your users when it comes to full-text search. This page is limited to full-text searches querying the Elasticsearch index, which is the recommended index for performing full-text searches.
Here are some examples of common changes of the Elasticsearch mapping.
All examples below should be done in a custom template that redefines the Elasticsearch mapping.
Customizing the Language
The Nuxeo code uses a full-text analyzer named fulltext
. This is an alias that points to the en_fulltext
analyzer by default.
To change it to the French analyzer for instance, move the following line into the fr_fulltext
:
"alias" : "fulltext"
If you dump the mapping from the Elasticsearch HTTP API (or using an Elasticsearch plug-in like head or kopf), you will see that alias are replaced by the target.
Making ILIKE Works (Case Insensitive Search)
If you want to do case insensitive search using an ILIKE
operation:
- Make sure that the
lowercase_analyzer
is defined in your settings (available since 6.0-HF01). Declare your field as a
multi_field
with alowercase
index:"my:field" : { "type" : "multi_field", "fields" : { "my:field" : { "include_in_all" : "true", "type" : "string" }, "lowercase" : { "type": "string", "analyzer" : "lowercase_analyzer" } } }
Adding a New Full-Text Field
To use the full-text search syntax on a custom field you need to create a multi_field
with a fulltext
index like this:
"my:text" : {
"type" : "multi_field",
"fields" : {
"my:text" : {
"include_in_all" : "true",
"type" : "string"
},
"fulltext" : {
"type": "string",
"analyzer" : "fulltext"
}
}
}
Note that if you:
- don't perform non fulltext search on this field
- don't use this field with a
IS NULL
orIS NOT NULL
operation - don't sort on this field
Then you can disable the default index on the field by adding after the second "[my:text](http://mytext)" : {
"index" : "no",
Excluding a Field from the Full-Text Search
Suppose you want to exclude my:secret
field from the ecm:fulltext
search:
"my:secret" : {
"type" : "string",
"include_in_all" : false
}
Elasticsearch Indexing Logic Elasticsearch Setup How to Make a Page Provider or Content View Query Elasticsearch Index
Full-Text Queries Indexing and Query Indexing and Querying How-To Index