# The analyser in mapping is not getting applied to field

**URL:** <https://discuss.elastic.co/t/the-analyser-in-mapping-is-not-getting-applied-to-field/334286>\
**Category:** Elasticsearch\
**Created:** [May 25, 2023, 7:26am UTC](https://discuss.elastic.co/t/the-analyser-in-mapping-is-not-getting-applied-to-field/334286 "2023-05-25T07:26:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sheereen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sheereen/32/122005_2.png) [@Sheereen](https://discuss.elastic.co/u/Sheereen)\
**Post date:** [May 25, 2023, 7:26am UTC](https://discuss.elastic.co/t/the-analyser-in-mapping-is-not-getting-applied-to-field/334286/1 "2023-05-25T07:26:13Z")

</div>

This is the mapping and settings

```auto

{
  "blogs_fixed2": {
    "aliases": {},
    "mappings": {
      "_meta": {
        "created_by": "Sheereen Hamza KV"
      },
      "properties": {
        "@timestamp": {
          "type": "date"
        },
        "authors": {
          "properties": {
            "company": {
              "type": "text",
              "fields": {
                "keyword": {
                  "type": "keyword",
                  "ignore_above": 256
                }
              }
            },
            "first_name": {
              "type": "keyword"
            },
            "full_name": {
              "type": "text"
            },
            "job_title": {
              "type": "text",
              "fields": {
                "keyword": {
                  "type": "keyword",
                  "ignore_above": 256
                }
              }
            },
            "last_name": {
              "type": "keyword"
            },
            "uid": {
              "type": "object",
              "enabled": false
            }
          }
        },
        "category": {
          "type": "keyword"
        },
        "category_title": {
          "properties": {
            "title": {
              "type": "keyword"
            },
            "uid": {
              "type": "keyword"
            }
          }
        },
        "content": {
          "type": "text",
          "analyzer": "content_analyzer"
        },
        "locale": {
          "type": "keyword"
        },
        "publish_date": {
          "type": "date",
          "format": "iso8601"
        },
        "search_tags": {
          "type": "keyword",
          "doc_values": false
        },
        "tags": {
          "properties": {
            "elastic_stack": {
              "type": "keyword",
              "copy_to": [
                "search_tags"
              ]
            },
            "industry": {
              "type": "keyword",
              "copy_to": [
                "search_tags"
              ]
            },
            "level": {
              "type": "keyword",
              "copy_to": [
                "search_tags"
              ]
            },
            "product": {
              "type": "keyword",
              "copy_to": [
                "search_tags"
              ]
            },
            "tags": {
              "type": "keyword",
              "copy_to": [
                "search_tags"
              ]
            },
            "topic": {
              "type": "keyword",
              "copy_to": [
                "search_tags"
              ]
            },
            "use_case": {
              "type": "keyword",
              "copy_to": [
                "search_tags"
              ]
            },
            "use_cases": {
              "type": "keyword",
              "copy_to": [
                "search_tags"
              ]
            }
          }
        },
        "title": {
          "type": "text"
        },
        "url": {
          "type": "keyword"
        }
      }
    },
    "settings": {
      "index": {
        "routing": {
          "allocation": {
            "include": {
              "_tier_preference": "data_content"
            }
          }
        },
        "number_of_shards": "1",
        "provided_name": "blogs_fixed2",
        "creation_date": "1684088852379",
        "analysis": {
          "analyzer": {
            "content_analyzer": {
              "filter": [
                "lowercase"
              ],
              "char_filter": [
                "html_strip"
              ],
              "tokenizer": "standard"
            }
          }
        },
        "number_of_replicas": "1",
        "uuid": "hnN5EsyaRR6TLa0oUJHQYg",
        "version": {
          "created": "8070099"
        }
      }
    }
  }
}

```

When I do a search on the same,

```auto
GET blogs_fixed2/_search
{
  "size": 1,
  "_source": false,
  "fields": [
    "content"
  ]
}

```

I get the below result, which doesn't have the analyser applied to it

```auto
{
  "took": 1,
  "timed_out": false,
  "_shards": {
    "total": 1,
    "successful": 1,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": {
      "value": 4666,
      "relation": "eq"
    },
    "max_score": 1,
    "hits": [
      {
        "_index": "blogs_fixed2",
        "_id": "aieZmIcBbskhfV7CHLs1",
        "_score": 1,
        "fields": {
          "content": [
            """<p>Pour capitalisfaudra probablement veiller à ce qu'Elasticsearch reste synchronisé avec les données porte quel SGBDR.
</p>
<h2>Configuration système</h2>
<p>Pour les besoins de cet articlents&nbsp;:
</p>
<ul>
	<li><a href="https://dev.mysql.com/">MySQL</a>&nbsp;: 8.0.16.</li>
	<li><a href="/guide/en/elasticsearch/reference/7.1/index.html">Elasticsearch</a>&nbsp;: 7.1.1</li>
	<li><a href="/guide/en/logstash/7.1/introduction.html">Logstash</a>&nbsp;: 7.1.1</li>
	<li><a href="https://www.java.com/en/">Java</a>&nbsp;: 1.8.0_162-b12</li>
	<li><a href="/guide/en/logstash/7.1/plugins-inputs-jdbc.html">Plug-in d'entrée JDBC</a>&nbsp;: v4.3.13</li>
	<li><a href="https://dev.mysql.com/downloads/connector/j/">Connecteur JDBC</a>&nbsp;: Connector/J 8.0.16</li>
</ul>"""
          ]
        }
      }
    ]
  }
}

```

I believe the analyser should be applied by default r8. And also, if I do a terms aggregation on **content** field, then it should bucket the different tokens in the field.

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [May 25, 2023, 7:38am UTC](https://discuss.elastic.co/t/the-analyser-in-mapping-is-not-getting-applied-to-field/334286/2 "2023-05-25T07:38:09Z")

</div>

Analyzers do not change the source document, just how this content is parsed and indexed.

You can see this if you use the [analyze API](https://www.elastic.co/guide/en/elasticsearch/reference/8.7/indices-analyze.html).

---

<div class="post-metadata">

**Author:** ![Sheereen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sheereen/32/122005_2.png) [@Sheereen](https://discuss.elastic.co/u/Sheereen)\
**Post date:** [May 25, 2023, 9:38am UTC](https://discuss.elastic.co/t/the-analyser-in-mapping-is-not-getting-applied-to-field/334286/3 "2023-05-25T09:38:44Z")

</div>

```auto
GET blogs_fixed2/_search
{
  "size": 1,
  "_source": false,
  "fields": [
    "content"
  ]
}

```

Using the above, I am trying to display the indexed value of content.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 22, 2023, 9:39am UTC](https://discuss.elastic.co/t/the-analyser-in-mapping-is-not-getting-applied-to-field/334286/4 "2023-06-22T09:39:28Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
