# Query Time Analysis: Are field value also analyzed?

**URL:** <https://discuss.elastic.co/t/query-time-analysis-are-field-value-also-analyzed/15465>\
**Category:** Elasticsearch\
**Created:** [January 29, 2014, 4:21am UTC](https://discuss.elastic.co/t/query-time-analysis-are-field-value-also-analyzed/15465 "2014-01-29T04:21:08Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Karan\_Verma](https://avatars.discourse-cdn.com/v4/letter/k/858c86/32.png) [@Karan\_Verma](https://discuss.elastic.co/u/Karan_Verma)\
**Post date:** [January 29, 2014, 4:21am UTC](https://discuss.elastic.co/t/query-time-analysis-are-field-value-also-analyzed/15465/1 "2014-01-29T04:21:08Z")

</div>

Hi

Lets say I have indexed a field person\_name as a string, with a custom  
analyzer. person\_name is stored int the index in one of the documents as:  
"Harry Greenberg"

I make a _match query_ on the field : "harry g"

I have a custom edgengram tokenizer which breaks the query down as follows:

{  
"tokens": [  
{  
"token": "h",  
"start\_offset": 0,  
"end\_offset": 1,  
"type": "word",  
"position": 1  
},  
{  
"token": "ha",  
"start\_offset": 0,  
"end\_offset": 2,  
"type": "word",  
"position": 2  
},  
{  
"token": "har",  
"start\_offset": 0,  
"end\_offset": 3,  
"type": "word",  
"position": 3  
},  
{  
"token": "harr",  
"start\_offset": 0,  
"end\_offset": 4,  
"type": "word",  
"position": 4  
},  
{  
"token": "harry",  
"start\_offset": 0,  
"end\_offset": 5,  
"type": "word",  
"position": 5  
},  
{  
"token": "g",  
"start\_offset": 6,  
"end\_offset": 7,  
"type": "word",  
"position": 6  
}  
]  
}

Will all of these tokens be matched agains "Harry Greenberg" or person\_name  
will also be broken down as defined by my custom analyzer?

If not, how can I make it so that it will also be broken down? Will it make  
the search significantly slower?

--  
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/af5354e7-5f7b-4b6e-96e6-f5e81df825db%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/af5354e7-5f7b-4b6e-96e6-f5e81df825db%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![jsbonline2006](https://avatars.discourse-cdn.com/v4/letter/j/85f322/32.png) [@jsbonline2006](https://discuss.elastic.co/u/jsbonline2006)\
**Post date:** [January 29, 2014, 6:51am UTC](https://discuss.elastic.co/t/query-time-analysis-are-field-value-also-analyzed/15465/2 "2014-01-29T06:51:22Z")

</div>

Hi Karan,

Can you please tell us what mapping you have applied?

If you are applying EdgeNGram in Query time Analyzer then your search query  
"harry g" will get tokenized as per your custom analyser.

Regards,  
Jayesh Bhoyar

On Wednesday, January 29, 2014 9:51:08 AM UTC+5:30, Karan Verma wrote:

> Hi
> 
> Lets say I have indexed a field person\_name as a string, with a custom  
> analyzer. person\_name is stored int the index in one of the documents as:  
> "Harry Greenberg"
> 
> I make a _match query_ on the field : "harry g"
> 
> I have a custom edgengram tokenizer which breaks the query down as  
> follows:
> 
> {  
> "tokens": [  
> {  
> "token": "h",  
> "start\_offset": 0,  
> "end\_offset": 1,  
> "type": "word",  
> "position": 1  
> },  
> {  
> "token": "ha",  
> "start\_offset": 0,  
> "end\_offset": 2,  
> "type": "word",  
> "position": 2  
> },  
> {  
> "token": "har",  
> "start\_offset": 0,  
> "end\_offset": 3,  
> "type": "word",  
> "position": 3  
> },  
> {  
> "token": "harr",  
> "start\_offset": 0,  
> "end\_offset": 4,  
> "type": "word",  
> "position": 4  
> },  
> {  
> "token": "harry",  
> "start\_offset": 0,  
> "end\_offset": 5,  
> "type": "word",  
> "position": 5  
> },  
> {  
> "token": "g",  
> "start\_offset": 6,  
> "end\_offset": 7,  
> "type": "word",  
> "position": 6  
> }  
> ]  
> }
> 
> Will all of these tokens be matched agains "Harry Greenberg" or  
> person\_name will also be broken down as defined by my custom analyzer?
> 
> If not, how can I make it so that it will also be broken down? Will it  
> make the search significantly slower?

--  
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/7301bfe9-ae7c-48ca-af38-ed369e7cc78d%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/7301bfe9-ae7c-48ca-af38-ed369e7cc78d%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Binh\_Ly](https://avatars.discourse-cdn.com/v4/letter/b/ce7236/32.png) [@Binh\_Ly](https://discuss.elastic.co/u/Binh_Ly)\
**Post date:** [January 29, 2014, 12:55pm UTC](https://discuss.elastic.co/t/query-time-analysis-are-field-value-also-analyzed/15465/3 "2014-01-29T12:55:53Z")

</div>

Karan,

If you set person\_name's analyzer to your custom one, analysis will  
generally be done at both query and index time. You also have the ability  
to set a different analyzer between index time and search time in which  
case they will behave differently when you search and when you index. See  
this for more details:

[http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-root-object-type.html#\_index\_search\_analyzers](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-root-object-type.html#_index_search_analyzers)

--  
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/be6a73e0-ee20-4a43-83bc-0be074c09fb7%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/be6a73e0-ee20-4a43-83bc-0be074c09fb7%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Karan\_Verma](https://avatars.discourse-cdn.com/v4/letter/k/858c86/32.png) [@Karan\_Verma](https://discuss.elastic.co/u/Karan_Verma)\
**Post date:** [January 29, 2014, 10:22pm UTC](https://discuss.elastic.co/t/query-time-analysis-are-field-value-also-analyzed/15465/4 "2014-01-29T22:22:54Z")

</div>

Thanks your your answer Binh

My mapping is:

```
    "person_name" : {
      "type" : "string",
      "analyzer" : "person_name_analyzer"
    }

```

From your explanation looks like ES will analyze both the query string and  
the stored value in the document. That is exactly what I want. Is there a  
way to test this? I was having problems for a much complex query where I  
thought that the tokens were matched against the full string value of the  
person\_name stored in the document.

On Wed, Jan 29, 2014 at 4:55 AM, Binh Ly [binh@hibalo.com](mailto:binh@hibalo.com) wrote:

> Karan,
> 
> If you set person\_name's analyzer to your custom one, analysis will  
> generally be done at both query and index time. You also have the ability  
> to set a different analyzer between index time and search time in which  
> case they will behave differently when you search and when you index. See  
> this for more details:
> 
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-root-object-type.html#_index_search_analyzers)
> 
> --  
> You received this message because you are subscribed to a topic in the  
> Google Groups "elasticsearch" group.  
> To unsubscribe from this topic, visit  
> [https://groups.google.com/d/topic/elasticsearch/uJPXFNRwlJk/unsubscribe](https://groups.google.com/d/topic/elasticsearch/uJPXFNRwlJk/unsubscribe).  
> To unsubscribe from this group and all its topics, 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/be6a73e0-ee20-4a43-83bc-0be074c09fb7%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/be6a73e0-ee20-4a43-83bc-0be074c09fb7%40googlegroups.com)  
> .
> 
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
Best,  
Karan

Life saving Ninja & Software Engineer

Karan pronounced Ka ([http://tiny.cc/0lu61w](http://tiny.cc/0lu61w)) + Run

--  
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/CAGX3c4GSk79XhcUy0G%2BAA1eSFW\_OjSTV4n%3DXRmWjZz8%2BQ8\_8OA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAGX3c4GSk79XhcUy0G%2BAA1eSFW_OjSTV4n%3DXRmWjZz8%2BQ8_8OA%40mail.gmail.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Binh\_Ly](https://avatars.discourse-cdn.com/v4/letter/b/ce7236/32.png) [@Binh\_Ly](https://discuss.elastic.co/u/Binh_Ly)\
**Post date:** [January 29, 2014, 10:45pm UTC](https://discuss.elastic.co/t/query-time-analysis-are-field-value-also-analyzed/15465/5 "2014-01-29T22:45:38Z")

</div>

Karan,

It should work no problem, if you do a query like this, it should match  
"Harry Greenberg":

{  
"query": {  
"match": {  
"person\_name": {  
"query": "harry g",  
"operator": "AND"  
}  
}  
}  
}

--  
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/f3d9836f-d1d5-4fcc-9852-74a29f27aca4%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/f3d9836f-d1d5-4fcc-9852-74a29f27aca4%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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:54am UTC](https://discuss.elastic.co/t/query-time-analysis-are-field-value-also-analyzed/15465/6 "2017-07-06T01:54:06Z")

</div>


