Help with Java Clint and Alias

Today I use this code to execute one select

QueryBuilder query = QueryBuilders.matchQuery(where,what);
		QueryBuilder filter = QueryBuilders.filteredQuery(query, filterBuilder);
		client.admin().indices().prepareAliases().addAlias("binhoca",this.getIndex()).execute();
		SearchResponse response = client.prepareSearch(this.getIndex())
				.setTypes(this.getType())
				.setQuery(filter)
				.addSort(campoOrder, tipoSorter)
				.setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
				.setSize(5000).execute()
				.actionGet();
		SearchHit[] hits = response.getHits().getHits();
		List<Map<String, Object>> retorno = new ArrayList<Map<String, Object>>();

So now I create one alias to my indice what I need to change to use alias instead indice name?

tks

You would simply use in your call to prepareSearch()

client.prepareSearch("binhoca")...

Sorry. the line
client.admin().indices().prepareAliases().addAlias("binhoca",this.getIndex()).execute();
are from tests but don`t work

I already try to only change the
SearchResponse response = client.prepareSearch(this.getIndex())

to

SearchResponse response = client.prepareSearch("binhoca").
.setTypes(this.getType())
				.setQuery(filter)
				.addSort(campoOrder, tipoSorter)
				.setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
				.setSize(5000).execute()
				.actionGet();

and don`t work.. if I go to browser and call http://localhost:9200/binhoca/_search?pretty works fine.. but not with client

Sorry man.. my Bad..

I forgot to change the type :smiley: now works..

tks