# How to test analyzer properly to debug mapping issues?

**URL:** https://discuss.elastic.co/t/how-to-test-analyzer-properly-to-debug-mapping-issues/43800
**Category:** Elasticsearch
**Created:** [March 8, 2016, 3:57pm UTC](https://discuss.elastic.co/t/how-to-test-analyzer-properly-to-debug-mapping-issues/43800 "2016-03-08T15:57:12Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![cpattonj](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cpattonj/32/4365_2.png) [@cpattonj](https://discuss.elastic.co/u/cpattonj)
#### Post date: [March 8, 2016, 3:57pm UTC](https://discuss.elastic.co/t/how-to-test-analyzer-properly-to-debug-mapping-issues/43800/1 "2016-03-08T15:57:12Z")

</div>

I have some very simple settings for an index that I'm trying to use to test my analyzer with:

```auto
{
	"settings": {
		"number_of_shards": 1,
		"number_of_replicas": 0
	},
	"mappings": {
		"applog": {
			"properties": {
				"user_id": {
					"type": "string",
					"index": "not_analyzed"
				}
			}
		}
	}
}

```

I simply want to confirm that my user\_id property for my applog document type will not get tokenized.

However, after confirming that the mappings are indeed in place:

```auto
curl localhost:9200/applog-test/_mapping?pretty
{
  "applog-test" : {
    "mappings" : {
      "applog" : {
        "properties" : {
          "user_id" : {
            "type" : "string",
            "index" : "not_analyzed"
          }
        }
      }
    }
  }
}

```

My analyzer appears to still be tokenizing the user\_id... hopefully this is user-error?

```auto
curl -XGET "localhost:9200/applog-test/_analyze?user_id&pretty" -d "this is a test"
{
  "tokens" : [ {
    "token" : "this",
    "start_offset" : 0,
    "end_offset" : 4,
    "type" : "<ALPHANUM>",
    "position" : 0
  }, {
    "token" : "is",
    "start_offset" : 5,
    "end_offset" : 7,
    "type" : "<ALPHANUM>",
    "position" : 1
  }, {
    "token" : "a",
    "start_offset" : 8,
    "end_offset" : 9,
    "type" : "<ALPHANUM>",
    "position" : 2
  }, {
    "token" : "test",
    "start_offset" : 10,
    "end_offset" : 14,
    "type" : "<ALPHANUM>",
    "position" : 3
  } ]
}

```

My expectation was that this would all be in a single token?

Bonus points: how do I create the desired behavior in a dynamic\_mapping? I ran into the same issue with the dynamic mapping and/or default mappings.

---

<div class="post-metadata">

### Author: ![cpattonj](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cpattonj/32/4365_2.png) [@cpattonj](https://discuss.elastic.co/u/cpattonj)
#### Post date: [March 8, 2016, 4:07pm UTC](https://discuss.elastic.co/t/how-to-test-analyzer-properly-to-debug-mapping-issues/43800/2 "2016-03-08T16:07:37Z")

</div>

I see in kibana after I indexed a single record of just the user\_id field, that it is in fact not being analyzed (my desired behavior). So I guess my follow up question would be how do I test the analyzer (indexer?) before I go inserting records since testing it in this fashion resulted in me getting multiple tokens?

---

<div class="post-metadata">

### Author: ![thn](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thn/32/8061_2.png) [@thn](https://discuss.elastic.co/u/thn)
#### Post date: [March 8, 2016, 5:11pm UTC](https://discuss.elastic.co/t/how-to-test-analyzer-properly-to-debug-mapping-issues/43800/3 "2016-03-08T17:11:03Z")

</div>

When you do **"index" : "not\_analyzed"** in the mapping, it's equivalent to index the field with "keyword" analyzer (see the link below for more info)

[https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-keyword-analyzer.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-keyword-analyzer.html)

To test different analyzer, you can do the following  
[http://localhost:9200/applog-test/\_analyze?analyzer=analyzer-name&text=this+is+a+test](http://localhost:9200/applog-test/_analyze?analyzer=analyzer-name&text=this+is+a+test)

---

<div class="post-metadata">

### Author: ![cpattonj](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cpattonj/32/4365_2.png) [@cpattonj](https://discuss.elastic.co/u/cpattonj)
#### Post date: [March 11, 2016, 3:48pm UTC](https://discuss.elastic.co/t/how-to-test-analyzer-properly-to-debug-mapping-issues/43800/4 "2016-03-11T15:48:14Z")

</div>

Thank you so much! Could you please point me in the direction of how you found out that the "index": "not\_analyzed" was _equivalent_ to the keyword analyzer? I feel I might need that resource in the future... unless it's expected to just happen upon the analyzer page you referenced. 😉

---

<div class="post-metadata">

### Author: ![thn](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thn/32/8061_2.png) [@thn](https://discuss.elastic.co/u/thn)
#### Post date: [March 11, 2016, 4:24pm UTC](https://discuss.elastic.co/t/how-to-test-analyzer-properly-to-debug-mapping-issues/43800/5 "2016-03-11T16:24:13Z")

</div>

The information is in the first link

---

<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: [July 5, 2017, 11:09pm UTC](https://discuss.elastic.co/t/how-to-test-analyzer-properly-to-debug-mapping-issues/43800/6 "2017-07-05T23:09:06Z")

</div>


