I have this index.:
{
"aliases" : {
"imoveislogradouro" : {}
},
"mappings" : {
"imoveislogradourotype" : {
"properties" : {
"logradouro" : {
"type" : "string",
"analyzer" : "phoneticAnalyzer"
},
"logradourosNaoFoneticado" : {
"type" : "string",
"analyzer" : "naoFoneticado"
}
}
}
},
"settings" : {
"index" : {
"analysis" : {
"filter" : {
"beider_morse" : {
"languageset" : [ "portuguese", "french", "english", "german" ],
"type" : "phonetic",
"encoder" : "beider_morse"
}
},
"analyzer" : {
"phoneticAnalyzer" : {
"filter" : [ "asciifolding","standard", "lowercase", "stemmer", "beider_morse" ],
"type" : "custom",
"tokenizer" : "standard"
},
"naoFoneticado" : {
"filter" : [ "asciifolding","standard", "lowercase"],
"type" : "custom",
"tokenizer" : "standard"
}
}
}
}
}
}
so I need to find one logradouro even if input only the start of my word ( if I input "san" the elastic need to return Santos, Santana ....
But I need to look for phonetic too, because this I create 2 fields, one Phonetic and another withou Phonetic
I using this code to find but dont return anything:
private List<Map<String, Object>> search(String where, String what) throws Exception{
QueryBuilder query = QueryBuilders.multiMatchQuery(what, where, where+"NaoFoneticado");
SearchResponse response = client.prepareSearch(this.getIndex())
.setTypes(this.getType())
.setQuery(query)
.setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
.setSize(this.getSize()).execute()
.actionGet();
SearchHit[] hits = response.getHits().getHits();
List<Map<String, Object>> retorno = new ArrayList<Map<String, Object>>();
for (int i = 0; i < hits.length; i++) {
retorno.add(hits[i].getSource());
}
return retorno;
}