Indexing and Query

Configuring the Elasticsearch Mapping

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.

If you want to do case insensitive search using an ILIKE operation:

  1. Make sure that the lowercase_analyzer is defined in your settings (available since 6.0-HF01).
  2. Declare your field as a multi_field with a lowercase 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 or IS NOT NULLoperation
  • 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",

Suppose you want to exclude my:secret field from the ecm:fulltext search:

 "my:secret" : {
    "type" : "string",
    "include_in_all" : false
 }

 


2 months ago Andrew Goodricke Syntax error fixed
5 years ago Benoit Delbosc 16
5 years ago Solen Guitter 15 | fix brocken link
5 years ago Solen Guitter 14
5 years ago Benoit Delbosc 13
5 years ago Benoit Delbosc 12
5 years ago Benoit Delbosc 11
5 years ago Michaël Vachette 10
5 years ago Michaël Vachette 9
5 years ago Michaël Vachette 8
5 years ago Michaël Vachette 7
5 years ago Solen Guitter 6 | Formatting
5 years ago Manon Lumeau 5
5 years ago Alain Escaffre 4
5 years ago Solen Guitter 3
5 years ago Alain Escaffre 2
5 years ago Alain Escaffre 1
History: Created by Alain Escaffre

We'd love to hear your thoughts!

All fields required