Custom mapping some questions

Hi,

I work on certification and mapping exercises.

I defined the following index with a custom analyzer.
I wonder :

  • Since the analyzer is defined in settings part, is it used for all fields ? If yes, could some one explain me how to define a such analyzer for content field only

  • I try to define more than one custom char_filter and filter but i did not find how to achieve that, is it possible ?

  • is it possible to define a field which is stored in _source but which is not indexed, is the index attribute available ?

Here is the index definition:
PUT /an_index
{
"settings": {
"analysis": {
"char_filter": {
"mychar": {
"type": "mapping",
"mappings": [
"c++ => cpp",
"C++ => cpp",
"IT => IT"
]
}
},
"filter": {
"myFilter": {
"type": "stop",
"stopwords": [
"can",
"we",
"our",
"you",
"your",
"all"
]
}
},
"analyzer": {
"monanalyzer": {
"type": "custom",
"char_filter": [
"mychar"
],
"tokenizer": "standard",
"filter": [
"lowercase",
"stop",
"myFilter"
]
}
}
}
},
"mappings": {
"_doc": {
"properties": {
"author": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"category": {
"type": "keyword",
"ignore_above": 256
},
"content": {
"type": "text",
"fields": {
"monChamp": {
"type": "text",
"analyzer":"monanalyzer"
}
}
},
"locales": {
"type": "keyword",
"ignore_above": 256
},
"publish_date": {
"type": "date"
},
"title": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"url": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
}
}
}

Hi,
I found how to define several char_filters or filters, a json question in fact.
So still two questions :

  • Since the analyzer is defined in settings part, is it used for all fields ? If yes, could some one explain me how to define a such analyzer for content field only

  • is it possible to define a field which is stored in _source but which is not indexed, is the index attribute available ?

Ok the "index":false is a valid attribute to a field, so the last question :

  • Since the analyzer is defined in settings part, is it used for all fields ? If yes, could some one explain me how to define a such analyzer for content field only

No helps ? No answer ?

Great questions!

Since the analyzer is defined in settings part, is it used for all fields ? If yes, could some one explain me how to define a such analyzer for content field only

No, an analyzer is not automatically applied to all fields. If you do not define an analyzer for a field, Elasticsearch will apply the standard analyzer by default. If you want to apply an analyzer to for example the content field, you need to do that in the mapping by defining an analyzer for that field, like you're already doing with the monChamp multi-field.

Hi Abdon,

A great thanks for your anwser.