# Phonetic analysis of an attachment

**URL:** <https://discuss.elastic.co/t/phonetic-analysis-of-an-attachment/8171>\
**Category:** Elasticsearch\
**Created:** [June 20, 2012, 3:36pm UTC](https://discuss.elastic.co/t/phonetic-analysis-of-an-attachment/8171 "2012-06-20T15:36:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![chris123](https://avatars.discourse-cdn.com/v4/letter/c/5fc32e/32.png) [@chris123](https://discuss.elastic.co/u/chris123)\
**Post date:** [June 20, 2012, 3:36pm UTC](https://discuss.elastic.co/t/phonetic-analysis-of-an-attachment/8171/1 "2012-06-20T15:36:06Z")

</div>

I need to provide a phonetic analysis for an attachment.  
I have the elasticsearch-analysis-phonetic plugin and  
elasticsearch-mapper-attachments plugin installed.  
They work fine.

However, I need to find similar sounding words in the attachment.  
Is there an easy way to do it or it will require changing the attachments  
mapper?  
If it requires the plugin change, are you (i.e. ElasticSearch team)  
planning to do it?

Chris

---

<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:** [June 21, 2012, 7:27am UTC](https://discuss.elastic.co/t/phonetic-analysis-of-an-attachment/8171/2 "2012-06-21T07:27:18Z")

</div>

In the mapper plugin you can control the specific fields that end up being  
indexed using the mappings. See in the README section here:  
[GitHub - elastic/elasticsearch-mapper-attachments: Mapper Attachments Type plugin for Elasticsearch](https://github.com/elasticsearch/elasticsearch-mapper-attachments). So, you  
can configure your custom analyzer with the phonetic configurations, and  
then set the mappings for it using that analyzer.

On Wed, Jun 20, 2012 at 5:36 PM, Chris123 [kjezak@reflexion.net](mailto:kjezak@reflexion.net) wrote:

> I need to provide a phonetic analysis for an attachment.  
> I have the elasticsearch-analysis-phonetic plugin and  
> elasticsearch-mapper-attachments plugin installed.  
> They work fine.
> 
> However, I need to find similar sounding words in the attachment.  
> Is there an easy way to do it or it will require changing the attachments  
> mapper?  
> If it requires the plugin change, are you (i.e. Elasticsearch team)  
> planning to do it?
> 
> Chris

---

<div class="post-metadata">

**Author:** ![chris123](https://avatars.discourse-cdn.com/v4/letter/c/5fc32e/32.png) [@chris123](https://discuss.elastic.co/u/chris123)\
**Post date:** [June 21, 2012, 9:48pm UTC](https://discuss.elastic.co/t/phonetic-analysis-of-an-attachment/8171/3 "2012-06-21T21:48:27Z")

</div>

Thank you and it works great! I love it!

Here is my test (trying to contribute a little):

# delete index

curl -X DELETE "192.168.2.128:9200/test"

# create index

curl -XPUT '[http://192.168.2.128:9200/test/](http://192.168.2.128:9200/test/)' -d '{  
"settings" : {  
"index": {  
"analysis" : {  
"analyzer" : {  
"soundex\_analyzer" : {  
"tokenizer" : "standard",  
"filter" : ["standard", "lowercase",  
"soundex\_filter"]  
}  
},  
"filter" : {  
"soundex\_filter" : {  
"type" : "phonetic",  
"encoder" : "soundex",  
"replace" : true  
}  
}  
}  
}  
},  
"mappings" : {  
"email" : {  
"\_source" : { "enabled" : false },  
"properties" : {  
"emailbody" : { "type" : "attachment" },  
"emailbodysoundex" : { "type" : "attachment",  
"fields" : {  
"emailbodysoundex" : {  
"analyzer" : "soundex\_analyzer" }  
}  
}  
}  
}  
}  
}'

# add to index the following message: Email body index all the words

curl -XPOST '[http://192.168.2.128:9200/test/email/?pretty=true](http://192.168.2.128:9200/test/email/?pretty=true)' -d '{  
"emailbody": "RW1haWwgYm9keSBpbmRleCBhbGwgdGhlIHdvcmRzCg==",  
"emailbodysoundex": "RW1haWwgYm9keSBpbmRleCBhbGwgdGhlIHdvcmRzCg=="  
}  
'

# check if the soundex is stored

curl -XGET '192.168.2.128:9200/test/\_search?pretty=true' -d '{  
"query" : {  
"matchAll" : {}  
},  
"facets" : {  
"tag" : {  
"terms" : {  
"field" : "emailbodysoundex"  
}  
}  
}  
}'

# search body soundex i.e. bady

curl -XGET '192.168.2.128:9200/test/\_search?pretty=true' -d '{  
"query" : {  
"text" : { "emailbodysoundex" :  
{ "query" : "bady" }  
}  
}  
}'

---

<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:23am UTC](https://discuss.elastic.co/t/phonetic-analysis-of-an-attachment/8171/4 "2017-07-06T03:23:01Z")

</div>


