# Cannot configure Multiple analyzers on the same field

**URL:** <https://discuss.elastic.co/t/cannot-configure-multiple-analyzers-on-the-same-field/191295>\
**Category:** Elasticsearch\
**Created:** [July 19, 2019, 1:11am UTC](https://discuss.elastic.co/t/cannot-configure-multiple-analyzers-on-the-same-field/191295 "2019-07-19T01:11:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![germax](https://avatars.discourse-cdn.com/v4/letter/g/a4c791/32.png) [@germax](https://discuss.elastic.co/u/germax)\
**Post date:** [July 19, 2019, 1:11am UTC](https://discuss.elastic.co/t/cannot-configure-multiple-analyzers-on-the-same-field/191295/1 "2019-07-19T01:11:41Z")

</div>

I have a text field indexed with four different analyzers. So there is raw text, keyword, token count and text without stopwords.

```auto
PUT test 
{
    "settings": {
        "analysis": {
            "analyzer": {
               "myAnalyzer": { 
                  "type": "standard",
                  "stopwords": "_english_"
               }
             }
         }
  },
  "mappings": {
    "properties": {
        "my_text": {
          "type": "text",
          "analyzer": "standard",
          "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
            },
            "length": {
                "type": "token_count",
                "analyzer": "myAnalyzer",
                "store": true
            },
            "stop": {
                "type": "text",
                "analyzer": "myAnalyzer",
                "store": true
            }
        }
      }
    }
  }
}

```

However, when I retrieve these subfields, the stopwords are not removed and token count corresponds to the original text. Example:

```auto
PUT test/_doc/1
{
  "my_text": "Raymond and Ruth Perelman School of Medicine at the University of Pennsylvania"`
}

```

```auto
GET test/_search
{
  "stored_fields": ["my_text.stop","my_text.length"],
  "_source": ["my_text"], 
    "query":{
      "match": {
        "my_text" : {
          "query" : "Raymond and Ruth Perelman School of Medicine at the University of Pennsylvania"
          
        }
      }
  }
}
// OUTPUT
{
  "_index" : "test",
  "_type" : "_doc",
  "_id" : "1",
  "_score" : 3.6679466,
  "_source" : {
      "my_text" : "Raymond and Ruth Perelman School of Medicine at the University of Pennsylvania"
  },
  "fields" : {
    "my_text.length" : [12],
    "my_text.stop" : ["Raymond and Ruth Perelman School of Medicine at the University of Pennsylvania"]
   }
}

```

Notice that stopwords such as "of", "the" are not removed. Interestingly, when I use Analyze API, it applies my analyzers correctly. Example:

```auto
GET test/_analyze
{
  "analyzer": "myAnalyzer",
  "text": "Raymond and Ruth Perelman School of Medicine at the University of Pennsylvania"
}
//outputs 7 tokens [Raymond, Ruth, Perelman, School, Medicine, University, Pennsylvania]

```

Does anyone knows why my subfields with custom analyzers are not handled correctly during indexing?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [July 19, 2019, 6:43am UTC](https://discuss.elastic.co/t/cannot-configure-multiple-analyzers-on-the-same-field/191295/2 "2019-07-19T06:43:35Z")

</div>

They're not removed from what has been sent to elasticsearch. What you is what you sent whatever analyze happened later.

The only way to see the effect is to use `_analyze` API.

---

<div class="post-metadata">

**Author:** ![germax](https://avatars.discourse-cdn.com/v4/letter/g/a4c791/32.png) [@germax](https://discuss.elastic.co/u/germax)\
**Post date:** [July 19, 2019, 1:37pm UTC](https://discuss.elastic.co/t/cannot-configure-multiple-analyzers-on-the-same-field/191295/3 "2019-07-19T13:37:59Z")

</div>

Got it, thank you. Is it possible to return Token count with Analyze API? I can't figure out where to specify `type: "token_count"`. It does not seem to be a part of analyzer object, but mapping instead. However Analyze API has no mappings.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [July 19, 2019, 2:07pm UTC](https://discuss.elastic.co/t/cannot-configure-multiple-analyzers-on-the-same-field/191295/4 "2019-07-19T14:07:44Z")

</div>

No. It's not possible I think.

---

<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:** [August 16, 2019, 2:07pm UTC](https://discuss.elastic.co/t/cannot-configure-multiple-analyzers-on-the-same-field/191295/5 "2019-08-16T14:07:48Z")

</div>

Closed on August 16, 2019, 2:07pm UTC

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