# Custom analyzers and mappings won't work

**URL:** <https://discuss.elastic.co/t/custom-analyzers-and-mappings-wont-work/14951>\
**Category:** Elasticsearch\
**Created:** [December 19, 2013, 12:56pm UTC](https://discuss.elastic.co/t/custom-analyzers-and-mappings-wont-work/14951 "2013-12-19T12:56:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![CarlJo](https://avatars.discourse-cdn.com/v4/letter/c/7feea3/32.png) [@CarlJo](https://discuss.elastic.co/u/CarlJo)\
**Post date:** [December 19, 2013, 12:56pm UTC](https://discuss.elastic.co/t/custom-analyzers-and-mappings-wont-work/14951/1 "2013-12-19T12:56:00Z")

</div>

I am trying to set up some common analyzers and mappings via Java, but I am having trouble.  
The precise JSON I use, you can find below.

Essentially I want to get shingles for a field called "text". I  
had this working, but I got all the traditional stop words unigrams on  
top when running a facet search: Not so useful. So I tried to throw a  
few stop word lists in the mix. Because I am dealing with English and  
German web content, I need a German and an English stop work list, plus a  
custom one with stuff like "www" and "http" on it.

First question: Can someone see whether the below JSON should work?

On the Java side, I am using the following code to pass the JSON to Elastic Search:

client.admin().indices().prepareClose(INDEX\_NAME).execute().actionGet();

Client.admin().indices().prepareUpdateSettings(INDEX\_NAME).setSettings(settingString).execute().actionGet();  
client.admin().indices().prepareOpen(INDEX\_NAME).execute().get();  
client.admin().indices().preparePutMapping(INDEX\_NAME).setType("_default_").setSource(mappingString).execute().actionGet();

Second question: Is trhis correct? Also: When should/can I run  
this code? After the index was created? Will it still work after some  
content has already been added to the index? Do I need to give ES some  
time after I issued the above commands? If so, how do I know when it is  
ready again?

Many Thanks!

Settings:  
{  
"analysis":{  
"analyzer":{  
"analyzer\_shingle":{  
"tokenizer":"standard",  
"filter":["standard", "lowercase"]  
},  
"title" : {  
"type" : "string",  
"index": "not\_analyzed"  
},  
"analyzer\_shingle\_tf":{  
"tokenizer":"standard",  
"filter":["standard", "lowercase", "filter\_english", "filter\_german", "filter\_www", "filter\_stop", "filter\_shingle"]  
}  
},  
"filter":{  
"filter\_shingle":{  
"type":"shingle",  
"max\_shingle\_size":5,  
"min\_shingle\_size":2,  
"output\_unigrams":"true"  
},  
"filter\_stop":{  
"type":"stop",  
"enable\_position\_increments":"true"  
},  
"filter\_english":{  
"type":"stop",  
"stopwords":"_english_"  
},  
"filter\_german":{  
"type":"stop",  
"stopwords":"_german_"  
},  
"filter\_www":{  
"type":"stop",  
"stopwords\_path":"stopwords\_www.txt"  
}  
}  
}  
}

Mapping:  
_default_ : {  
"properties" : {  
"coordinates" : {  
"type" : "geo\_point",  
}  
"text":{  
"search\_analyzer":"analyzer\_shingle\_tf",  
"index\_analyzer":"analyzer\_shingle\_tf",  
"type":"string"  
}  
}  
}  
}

--  
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/1387457760.574.YahooMailNeo%40web28802.mail.ir2.yahoo.com](https://groups.google.com/d/msgid/elasticsearch/1387457760.574.YahooMailNeo%40web28802.mail.ir2.yahoo.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![CarlJo](https://avatars.discourse-cdn.com/v4/letter/c/7feea3/32.png) [@CarlJo](https://discuss.elastic.co/u/CarlJo)\
**Post date:** [December 19, 2013, 12:59pm UTC](https://discuss.elastic.co/t/custom-analyzers-and-mappings-wont-work/14951/2 "2013-12-19T12:59:03Z")

</div>

I am trying to set up some common analyzers and mappings via Java, but I am having trouble.  
The precise JSON I use, you can find below.

Essentially I want to get shingles for a field called "text". I  
had this working, but I got all the traditional stop words unigrams on  
top when running a facet search: Not so useful. So I tried to throw a  
few stop word lists in the mix. Because I am dealing with English and  
German web content, I need a German and an English stop work list, plus a  
custom one with stuff like "www" and "http" on it.

First question: Can someone see whether the below JSON should work?

On the Java side, I am using the following code to pass the JSON to Elastic Search:

client.admin().indices().prepareClose(INDEX\_NAME).execute().actionGet();

Client.admin().indices().prepareUpdateSettings(INDEX\_NAME).setSettings(settingString).execute().actionGet();  
client.admin().indices().prepareOpen(INDEX\_NAME).execute().get();  
client.admin().indices().preparePutMapping(INDEX\_NAME).setType("_default_").setSource(mappingString).execute().actionGet();

Second question: Is trhis correct? Also: When should/can I run  
this code? After the index was created? Will it still work after some  
content has already been added to the index? Do I need to give ES some  
time after I issued the above commands? If so, how do I know when it is  
ready again?

Many Thanks!

Settings:  
{  
"analysis":{  
"analyzer":{  
"analyzer\_shingle":{  
"tokenizer":"standard",  
"filter":["standard", "lowercase"]  
},  
"title" : {  
"type" : "string",  
"index": "not\_analyzed"  
},  
"analyzer\_shingle\_tf":{  
"tokenizer":"standard",  
"filter":["standard", "lowercase", "filter\_english", "filter\_german", "filter\_www", "filter\_stop", "filter\_shingle"]  
}  
},  
"filter":{  
"filter\_shingle":{  
"type":"shingle",  
"max\_shingle\_size":5,  
"min\_shingle\_size":2,  
"output\_unigrams":"true"  
},  
"filter\_stop":{  
"type":"stop",  
"enable\_position\_increments":"true"  
},  
"filter\_english":{  
"type":"stop",  
"stopwords":"_english_"  
},  
"filter\_german":{  
"type":"stop",  
"stopwords":"_german_"  
},  
"filter\_www":{  
"type":"stop",  
"stopwords\_path":"stopwords\_www.txt"  
}  
}  
}  
}

Mapping:  
_default_ : {  
"properties" : {  
"coordinates" : {  
"type" : "geo\_point",  
}  
"text":{  
"search\_analyzer":"analyzer\_shingle\_tf",  
"index\_analyzer":"analyzer\_shingle\_tf",  
"type":"string"  
}  
}  
}  
}

--  
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/1387457943.76317.YahooMailNeo%40web28801.mail.ir2.yahoo.com](https://groups.google.com/d/msgid/elasticsearch/1387457943.76317.YahooMailNeo%40web28801.mail.ir2.yahoo.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, 2:00am UTC](https://discuss.elastic.co/t/custom-analyzers-and-mappings-wont-work/14951/3 "2017-07-06T02:00:15Z")

</div>


