Hello !
I would like to use an edge-ngram analyzer to aggregation my results and get a completion.
here is my configurer
@Component("myAnalysisConfigurer")
public class MyAnalysisConfigurer implements ElasticsearchAnalysisConfigurer {
@Override
public void configure(ElasticsearchAnalysisConfigurationContext context) {
context.analyzer("edge_ngram").custom()
.tokenizer("keyword")
.tokenFilters("lowercase", "edge_ngram_filter");
context.tokenFilter("edge_ngram_filter")
.type("edgeNGram")
.param("side", "front")
.param("max_gram", 15)
.param("min_gram", 1);
}
}
here the annotation on my string field.
@FullTextField(name = "field_suggest", analyzer = "edge_ngram", searchable = Searchable.YES, aggregable = Aggregable.YES, projectable = Projectable.YES)
Here the mapping of my field seen throught Kibana :
"field_suggest": {
"type": "text",
"store": true,
"analyzer": "edge_ngram"
}
and the generated analysis
"analysis": {
"filter": {
"edge_ngram_filter": {
"min_gram": "1",
"side": "front",
"type": "edgeNGram",
"max_gram": "15"
}
},
"analyzer": {
"edge_ngram": {
"filter": [
"lowercase",
"edge_ngram_filter"
],
"type": "custom",
"tokenizer": "keyword"
}
}
}
Here the request
GET /acme-000001/_search
{
"size": 0,
"from": 0,
"track_total_hits": true,
"aggregations": {
"suggestions": {
"terms": {
"field": "field_suggest",
"size": 20
}
}
},
"query": {
"match": {
"field_suggest": "xxx"
}
}
}
But when i execute the search i get this response :
"root_cause" : [
{
"type" : "illegal_argument_exception",
"reason" : "Fielddata is disabled on text fields by default. Set fielddata=true on [field_suggest] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead."
}
]
do you have any ideas ? Analyzer are not avalaible on @KeywordField annotation