# Define analyzer in a percolator query\_string

**URL:** https://discuss.elastic.co/t/define-analyzer-in-a-percolator-query-string/15756
**Category:** Elasticsearch
**Created:** [February 12, 2014, 2:10pm UTC](https://discuss.elastic.co/t/define-analyzer-in-a-percolator-query-string/15756 "2014-02-12T14:10:16Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![dunaeth](https://avatars.discourse-cdn.com/v4/letter/d/898d66/32.png) [@dunaeth](https://discuss.elastic.co/u/dunaeth)
#### Post date: [February 12, 2014, 2:10pm UTC](https://discuss.elastic.co/t/define-analyzer-in-a-percolator-query-string/15756/1 "2014-02-12T14:10:16Z")

</div>

Hi,

I am trying to register a percolator query that would analyze an URI field  
to check whether or not it contains a given expression, defining at the  
same time the analyzer used :

curl -XPUT '[http://127.0.0.1:9200/\_percolator/tester/test1](http://127.0.0.1:9200/_percolator/tester/test1)' -d '{

"query":{

"simple\_query\_string":{

"fields":[

"uri\_field"

],

"query":"test",

"analyzer":"simple"

}

}

}'

but it seems the analyzer used stays the default one, so that this doc is  
not matched by the percolator query :

curl -XPOST '[http://127.0.0.1:9200/tester/test/\_percolate](http://127.0.0.1:9200/tester/test/_percolate)' -d '{

"doc": {

"uri\_field": "[http://www.test.foo](http://www.test.foo)"

}

}'

Am I doing something wrong or is it just impossible ?

--  
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/5c690590-628c-40dc-bac0-07a996b79e4b%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/5c690590-628c-40dc-bac0-07a996b79e4b%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: ![dunaeth](https://avatars.discourse-cdn.com/v4/letter/d/898d66/32.png) [@dunaeth](https://discuss.elastic.co/u/dunaeth)
#### Post date: [February 12, 2014, 2:20pm UTC](https://discuss.elastic.co/t/define-analyzer-in-a-percolator-query-string/15756/2 "2014-02-12T14:20:55Z")

</div>

Btw, I found a different way to achieve my primary goal using a different  
percolate query :

curl -XPUT '[http://127.0.0.1:9200/\_percolator/tester/test1](http://127.0.0.1:9200/_percolator/tester/test1)' -d '{

"query":{

"query\_string":{

"fields":[

"uri\_field"

],

"query":"_test_"

}

}

}'

But it would be better if I could use simple query strings with analyzers  
since they best fit my main goal.

Le mercredi 12 février 2014 15:10:16 UTC+1, Dunaeth a écrit :

> Hi,
> 
> I am trying to register a percolator query that would analyze an URI field  
> to check whether or not it contains a given expression, defining at the  
> same time the analyzer used :
> 
> curl -XPUT '[http://127.0.0.1:9200/\_percolator/tester/test1](http://127.0.0.1:9200/_percolator/tester/test1)' -d '{
> 
> "query":{
> 
> "simple\_query\_string":{
> 
> "fields":[
> 
> "uri\_field"
> 
> ],
> 
> "query":"test",
> 
> "analyzer":"simple"
> 
> }
> 
> }
> 
> }'
> 
> but it seems the analyzer used stays the default one, so that this doc is  
> not matched by the percolator query :
> 
> curl -XPOST '[http://127.0.0.1:9200/tester/test/\_percolate](http://127.0.0.1:9200/tester/test/_percolate)' -d '{
> 
> "doc": {
> 
> "uri\_field": "[http://www.test.foo](http://www.test.foo)"
> 
> }
> 
> }'
> 
> Am I doing something wrong or is it just impossible ?

--  
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/a33bc94e-a164-4912-9e1f-3fd2907417b4%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/a33bc94e-a164-4912-9e1f-3fd2907417b4%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: [February 12, 2014, 9:24pm UTC](https://discuss.elastic.co/t/define-analyzer-in-a-percolator-query-string/15756/3 "2014-02-12T21:24:19Z")

</div>

To explain what's happening in your scenario, when you make this call:

curl -XPOST '[http://127.0.0.1:9200/tester/test/\_percolate](http://127.0.0.1:9200/tester/test/_percolate)' -d '{  
{

"doc": {

"uri\_field": "[http://www.test.foo](http://www.test.foo)"

}

}'

The value "[http://www.test.foo](http://www.test.foo)" is indexed using the standard analyzer (or  
whatever is defined in your mapping for the uri\_field, if you have one). So  
in the case of the standard analyzer, this is broken down to ("http",  
"www.test.foo").

When you define this query:

curl -XPUT '[http://127.0.0.1:9200/\_percolator/tester/test1](http://127.0.0.1:9200/_percolator/tester/test1)' -d '{

"query":{

"simple\_query\_string":{

"fields":[

"uri\_field"

],

"query":"test",

"analyzer":"simple"

}

}

}'

The _search_ value "test" is analyzed using the simple analyzer, then it is  
executed against the _indexed_ value "[http://www.test.foo](http://www.test.foo)" which was  
analyzed using the standard analyzer. Note that the simple analyzer is not  
applied to the indexed value "[http://www.test.foo](http://www.test.foo)". It is only applied to  
the query value "test". You cannot influence the _index_ analyzer at query  
time. You can only influence the _search_ analyzer.

--  
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/98ba4603-c80a-4ef8-a9c3-866c7684468a%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/98ba4603-c80a-4ef8-a9c3-866c7684468a%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:50am UTC](https://discuss.elastic.co/t/define-analyzer-in-a-percolator-query-string/15756/4 "2017-07-06T01:50:39Z")

</div>


