# Tokenizing my field even with index not analyzed

**URL:** <https://discuss.elastic.co/t/tokenizing-my-field-even-with-index-not-analyzed/17742>\
**Category:** Elasticsearch\
**Created:** [May 27, 2014, 7:52am UTC](https://discuss.elastic.co/t/tokenizing-my-field-even-with-index-not-analyzed/17742 "2014-05-27T07:52:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Josep\_Floriach\_Vento](https://avatars.discourse-cdn.com/v4/letter/j/96bed5/32.png) [@Josep\_Floriach\_Vento](https://discuss.elastic.co/u/Josep_Floriach_Vento)\
**Post date:** [May 27, 2014, 7:52am UTC](https://discuss.elastic.co/t/tokenizing-my-field-even-with-index-not-analyzed/17742/1 "2014-05-27T07:52:12Z")

</div>

Hi everyone,

I have an index where two of the data fields is long type, and the other  
string type. They are PID and Batch\_Name. I'm trying to do a query that  
returns me the entry with PID = 25747 and batch name = ZEJINNSP05.That's  
how I'm doing the query:

[http://myserver.com:9200/batches-\*/\_search?q=PID:25747&Batch\_Name:ZEJININSP05&pretty=true](http://myserver.com:9200/batches-*/_search?q=PID:25747&Batch_Name:ZEJININSP05&pretty=true)

The result of this query are two entries. One of both is correct. It have  
this PID and this batch name. the other one has the correct PID but the  
following batch name: ZEJINLECT32

I guess that happens because ES is tokenizing my field. But I don't  
understand why, since I'm telling in my template that this field should not  
be tokenized.

This is how looks my template:

#!/bin/sh  
curl -XPUT 'localhost:9200/\_template/batches\_online' -d '{  
"template": "batches-\*",  
"settings": {  
"number\_of\_shards": 1,  
"number\_of\_replicas": 0,  
"index.refresh\_interval": "5s"  
},

```
"mappings": {
    "logs": {
        "properties": {

```

"Batch\_name": {  
"type": "string",  
"index":"not\_analyzed"  
}  
... (more fields)

What I'm doing wrong?

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/077f7d0a-67b6-42fc-a056-f64d37ede808%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/077f7d0a-67b6-42fc-a056-f64d37ede808%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Tomislav\_Poljak](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tomislav_poljak/32/1177_2.png) [@Tomislav\_Poljak](https://discuss.elastic.co/u/Tomislav_Poljak)\
**Post date:** [May 27, 2014, 11:58am UTC](https://discuss.elastic.co/t/tokenizing-my-field-even-with-index-not-analyzed/17742/2 "2014-05-27T11:58:03Z")

</div>

Hi Josep,  
problem of matching too much entries is not related to the analysis of  
"Batch\_name" field ('tokenization' of "Batch\_name"), but actually its  
in the way how you constructed URI search params. In your URL  
.../\_search?q=PID:25747&Batch\_Name:ZEJININSP05... '&' is actually  
separating http params (like &pretty=true etc) and not used as AND in  
the Lucene query (what I think you expect). So, you actually get all  
matches for q=PID:25747 regardless of 'Batch\_Name' value.

Try this instead  
[http://myserver.com:9200/batches-\*/\_search?q=PID:25747%20AND%20Batch\_Name:ZEJININSP05&pretty=true](http://myserver.com:9200/batches-*/_search?q=PID:25747%20AND%20Batch_Name:ZEJININSP05&pretty=true)

(not sure if its "Batch\_Name" which is in the query or "Batch\_name" in mapping)

If you check [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-uri-request.html)  
for constructing URI search queries you'll see you need to use Lucene  
syntax ([Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html#query-string-syntax))  
when building a query as URI param

Hope this helps,  
Tomislav

2014-05-27 9:52 GMT+02:00 Josep Floriach Ventosinos  
[josep.floriach.ventosinos@gmail.com](mailto:josep.floriach.ventosinos@gmail.com):

> Hi everyone,
> 
> I have an index where two of the data fields is long type, and the other  
> string type. They are PID and Batch\_Name. I'm trying to do a query that  
> returns me the entry with PID = 25747 and batch name = ZEJINNSP05.That's how  
> I'm doing the query:
> 
> [http://myserver.com:9200/batches-\*/\_search?q=PID:25747&Batch\_Name:ZEJININSP05&pretty=true](http://myserver.com:9200/batches-*/_search?q=PID:25747&Batch_Name:ZEJININSP05&pretty=true)
> 
> The result of this query are two entries. One of both is correct. It have  
> this PID and this batch name. the other one has the correct PID but the  
> following batch name: ZEJINLECT32
> 
> I guess that happens because ES is tokenizing my field. But I don't  
> understand why, since I'm telling in my template that this field should not  
> be tokenized.
> 
> This is how looks my template:
> 
> #!/bin/sh  
> curl -XPUT 'localhost:9200/\_template/batches\_online' -d '{  
> "template": "batches-\*",  
> "settings": {  
> "number\_of\_shards": 1,  
> "number\_of\_replicas": 0,  
> "index.refresh\_interval": "5s"  
> },
> 
> ```
> "mappings": {
> "logs": {
> "properties": {
> 
> ```
> 
> "Batch\_name": {  
> "type": "string",  
> "index":"not\_analyzed"  
> }  
> ... (more fields)
> 
> What I'm doing wrong?
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/077f7d0a-67b6-42fc-a056-f64d37ede808%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/077f7d0a-67b6-42fc-a056-f64d37ede808%40googlegroups.com).  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CALuCJxjVXCrMy8k197fA7y%3D51fSt3Vnty5O8sP%3Dh9tckWP\_\_yA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CALuCJxjVXCrMy8k197fA7y%3D51fSt3Vnty5O8sP%3Dh9tckWP__yA%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Josep\_Floriach\_Vento](https://avatars.discourse-cdn.com/v4/letter/j/96bed5/32.png) [@Josep\_Floriach\_Vento](https://discuss.elastic.co/u/Josep_Floriach_Vento)\
**Post date:** [May 28, 2014, 7:24am UTC](https://discuss.elastic.co/t/tokenizing-my-field-even-with-index-not-analyzed/17742/3 "2014-05-28T07:24:52Z")

</div>

Oh. I'm so dumb... 😛 That helped me a lot.

Thanks!!

On Tuesday, May 27, 2014 9:52:12 AM UTC+2, Josep Floriach Ventosinos wrote:

> Hi everyone,
> 
> I have an index where two of the data fields is long type, and the other  
> string type. They are PID and Batch\_Name. I'm trying to do a query that  
> returns me the entry with PID = 25747 and batch name = ZEJINNSP05.That's  
> how I'm doing the query:
> 
> [http://myserver.com:9200/batches-\*/\_search?q=PID:25747&Batch\_Name:ZEJININSP05&pretty=true](http://myserver.com:9200/batches-*/_search?q=PID:25747&Batch_Name:ZEJININSP05&pretty=true)
> 
> The result of this query are two entries. One of both is correct. It have  
> this PID and this batch name. the other one has the correct PID but the  
> following batch name: ZEJINLECT32
> 
> I guess that happens because ES is tokenizing my field. But I don't  
> understand why, since I'm telling in my template that this field should not  
> be tokenized.
> 
> This is how looks my template:
> 
> #!/bin/sh  
> curl -XPUT 'localhost:9200/\_template/batches\_online' -d '{  
> "template": "batches-\*",  
> "settings": {  
> "number\_of\_shards": 1,  
> "number\_of\_replicas": 0,  
> "index.refresh\_interval": "5s"  
> },
> 
> ```
> "mappings": {
> "logs": {
> "properties": {
> 
> ```
> 
> "Batch\_name": {  
> "type": "string",  
> "index":"not\_analyzed"  
> }  
> ... (more fields)
> 
> What I'm doing wrong?

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/fb49b695-d02e-4e0b-a195-c9352a879073%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/fb49b695-d02e-4e0b-a195-c9352a879073%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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 6, 2017, 1:26am UTC](https://discuss.elastic.co/t/tokenizing-my-field-even-with-index-not-analyzed/17742/4 "2017-07-06T01:26:27Z")

</div>


