# Word with accent and searching

**URL:** <https://discuss.elastic.co/t/word-with-accent-and-searching/5476>\
**Category:** Elasticsearch\
**Created:** [September 29, 2011, 12:38pm UTC](https://discuss.elastic.co/t/word-with-accent-and-searching/5476 "2011-09-29T12:38:39Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![erlo](https://avatars.discourse-cdn.com/v4/letter/e/f07891/32.png) [@erlo](https://discuss.elastic.co/u/erlo)\
**Post date:** [September 29, 2011, 12:38pm UTC](https://discuss.elastic.co/t/word-with-accent-and-searching/5476/1 "2011-09-29T12:38:39Z")

</div>

Hello,

I'm stuck with a problem about words which contain accent.

For example, if I index the word "année" with a custom analyzer with  
filter "asciifolding", I can match the token by searching "annee", but I  
cannot match when I search directly "année".

I've set a search\_analyzer which is a custom one with asciifolding too.

What is the best pratice to index accent word, and be able to search it  
using accent or not...?

Thanks!

--  
Erwan

---

<div class="post-metadata">

**Author:** ![erlo](https://avatars.discourse-cdn.com/v4/letter/e/f07891/32.png) [@erlo](https://discuss.elastic.co/u/erlo)\
**Post date:** [September 29, 2011, 2:27pm UTC](https://discuss.elastic.co/t/word-with-accent-and-searching/5476/2 "2011-09-29T14:27:53Z")

</div>

I can answer to myself...  
Even if I cannot explain exactly my mistake I've specified a specific  
analyzer (with asciifolding filter) in my query and it works.

But I've already define this analyzer in "search\_analyzer" at the top  
level of the mapping...

Erwan Loaëc wrote:

> Hello,
> 
> I'm stuck with a problem about words which contain accent.
> 
> For example, if I index the word "année" with a custom analyzer with  
> filter "asciifolding", I can match the token by searching "annee", but I  
> cannot match when I search directly "année".
> 
> I've set a search\_analyzer which is a custom one with asciifolding too.
> 
> What is the best pratice to index accent word, and be able to search it  
> using accent or not...?
> 
> Thanks!

---

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [September 29, 2011, 2:31pm UTC](https://discuss.elastic.co/t/word-with-accent-and-searching/5476/3 "2011-09-29T14:31:54Z")

</div>

On Thu, 2011-09-29 at 14:38 +0200, Erwan LoaÃ«c wrote:

> Hello,
> 
> I'm stuck with a problem about words which contain accent.
> 
> For example, if I index the word "annÃ©e" with a custom analyzer with  
> filter "asciifolding", I can match the token by searching "annee", but I  
> cannot match when I search directly "annÃ©e".
> 
> I've set a search\_analyzer which is a custom one with asciifolding too.

How are you searching? Are you searching against the same field for  
which you have specified the analyzer? Or are you using the query\_string  
query with no fields specified? If the latter, then you are searching  
against the \_all field, which has its own analyzer (the 'standard'  
analyzer by default).

clint

---

<div class="post-metadata">

**Author:** ![erlo](https://avatars.discourse-cdn.com/v4/letter/e/f07891/32.png) [@erlo](https://discuss.elastic.co/u/erlo)\
**Post date:** [September 29, 2011, 2:43pm UTC](https://discuss.elastic.co/t/word-with-accent-and-searching/5476/4 "2011-09-29T14:43:26Z")

</div>

Here is how I've defined the mapping:

```
 "myindex" : {
     "index_analyzer" : "myindexanalyzer",
     "search_analyzer" : "mysearchanalyzer",
     "properties" : {
         "mykeyword": { "type" : "string" }
     }
 }

```

Now, I'm searching with:

"query":{  
"query\_string":{  
"mykeyword":{  
"query":"XXX"  
}  
}  
}

Other test:

"query":{  
"query\_string":{  
"query":"XXX"  
}  
}

I does not use the right analyzer... A working solution is to specify  
the analyzer :

"query":{  
"query\_string":{  
"mykeyword":{  
"query":"XXX",  
"analyzer":"mysearchanalyzer",  
}  
}  
}

Is anyone know why my mapping does not word as excepted ...?  
(search\_analyzer property...)

Thanks!

Clinton Gormley wrote:

> On Thu, 2011-09-29 at 14:38 +0200, Erwan Loaëc wrote:
> 
> > Hello,
> > 
> > I'm stuck with a problem about words which contain accent.
> > 
> > For example, if I index the word "année" with a custom analyzer with  
> > filter "asciifolding", I can match the token by searching "annee", but I  
> > cannot match when I search directly "année".
> > 
> > I've set a search\_analyzer which is a custom one with asciifolding too.
> 
> How are you searching? Are you searching against the same field for  
> which you have specified the analyzer? Or are you using the query\_string  
> query with no fields specified? If the latter, then you are searching  
> against the \_all field, which has its own analyzer (the 'standard'  
> analyzer by default).
> 
> clint

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [October 2, 2011, 8:37am UTC](https://discuss.elastic.co/t/word-with-accent-and-searching/5476/5 "2011-10-02T08:37:52Z")

</div>

Post a recreation, currently the question is all over the place. See  
[Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/help).

On Thu, Sep 29, 2011 at 5:43 PM, Erwan Loaëc [erwan.loaec@cgin.fr](mailto:erwan.loaec@cgin.fr) wrote:

> Here is how I've defined the mapping:
> 
> "myindex" : {  
> "index\_analyzer" : "myindexanalyzer",  
> "search\_analyzer" : "mysearchanalyzer",  
> "properties" : {  
> "mykeyword": { "type" : "string" }  
> }  
> }
> 
> Now, I'm searching with:
> 
> "query":{  
> "query\_string":{  
> "mykeyword":{  
> "query":"XXX"  
> }  
> }  
> }
> 
> Other test:
> 
> "query":{  
> "query\_string":{  
> "query":"XXX"  
> }  
> }
> 
> I does not use the right analyzer... A working solution is to specify the  
> analyzer :
> 
> "query":{  
> "query\_string":{  
> "mykeyword":{  
> "query":"XXX",  
> "analyzer":"mysearchanalyzer",  
> }  
> }  
> }
> 
> Is anyone know why my mapping does not word as excepted ...?  
> (search\_analyzer property...)
> 
> Thanks!
> 
> Clinton Gormley wrote:
> 
> > On Thu, 2011-09-29 at 14:38 +0200, Erwan Loaëc wrote:
> > 
> > > Hello,
> > > 
> > > I'm stuck with a problem about words which contain accent.
> > > 
> > > For example, if I index the word "année" with a custom analyzer with  
> > > filter "asciifolding", I can match the token by searching "annee", but I  
> > > cannot match when I search directly "année".
> > > 
> > > I've set a search\_analyzer which is a custom one with asciifolding too.
> > 
> > How are you searching? Are you searching against the same field for  
> > which you have specified the analyzer? Or are you using the query\_string  
> > query with no fields specified? If the latter, then you are searching  
> > against the \_all field, which has its own analyzer (the 'standard'  
> > analyzer by default).
> > 
> > clint

---

<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, 3:53am UTC](https://discuss.elastic.co/t/word-with-accent-and-searching/5476/6 "2017-07-06T03:53:10Z")

</div>


