# Hyphenated aliases do not work

**URL:** <https://discuss.elastic.co/t/hyphenated-aliases-do-not-work/2797>\
**Category:** Elasticsearch\
**Created:** [June 16, 2015, 12:43pm UTC](https://discuss.elastic.co/t/hyphenated-aliases-do-not-work/2797 "2015-06-16T12:43:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![andimak](https://avatars.discourse-cdn.com/v4/letter/a/f6c823/32.png) [@andimak](https://discuss.elastic.co/u/andimak)\
**Post date:** [June 16, 2015, 12:43pm UTC](https://discuss.elastic.co/t/hyphenated-aliases-do-not-work/2797/1 "2015-06-16T12:43:29Z")

</div>

I have an setup with aliases like that:

> Index: 2009\_12  
> aliases:  
> 2009  
> test-index\_de\_2009 (filter)  
> test\_de\_2009 (filter)

If I use 2009/\_search or 2009\_12/\_search i get all documents.  
if I use test\_de\_2009/\_search i get only the documents on a filtered field "name". I have the same filtered function with test-index\_de\_2009 and the "name" field, but i get no results when i search with test-index\_de\_2009/\_search.

Whats the reason? I think its the hyphen, but i dont know why this happen and how to fix it.

regards  
andi

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [June 17, 2015, 12:25am UTC](https://discuss.elastic.co/t/hyphenated-aliases-do-not-work/2797/2 "2015-06-17T00:25:33Z")

</div>

Can you share the alias creation commands you used?

---

<div class="post-metadata">

**Author:** ![andimak](https://avatars.discourse-cdn.com/v4/letter/a/f6c823/32.png) [@andimak](https://discuss.elastic.co/u/andimak)\
**Post date:** [June 17, 2015, 6:36am UTC](https://discuss.elastic.co/t/hyphenated-aliases-do-not-work/2797/3 "2015-06-17T06:36:14Z")

</div>

> String year = yearMonth.split("_")[0];  
> if (!checkIndexExist(yearMonth))  
> {  
> try{  
> CreateIndexResponse indexResp;  
> indexResp = client.admin().indices().prepareCreate(yearMonth)  
> // .setSettings(ImmutableSettings.settingsBuilder().put("number\_of\_shards",shardNumber).put("number\_of\_replicas", replicaNumber))  
> .setSource(DEFAULT\_MAPPING.toJSONString())  
> .execute().actionGet();  
> client.admin().indices().prepareAliases().  
> addAlias(yearMonth, year).execute().actionGet();  
> }catch(IndexAlreadyExistsException e)  
> {  
> // just ignore  
> }  
> }  
> //make filtered alias  
> try{  
> FilterBuilder filter = FilterBuilders.termFilter("db",index);  
> client.admin().indices().prepareAliases().addAlias(yearMonth,index+"_"+year,filter).execute().actionGet();

"db" is the filtered alias field and has default mapping (string, standard analyzer).

---

<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, 12:07am UTC](https://discuss.elastic.co/t/hyphenated-aliases-do-not-work/2797/4 "2017-07-06T00:07:05Z")

</div>


