Skip to content

Instantly share code, notes, and snippets.

@geraldhumphries
Created November 11, 2016 22:56
Show Gist options
  • Save geraldhumphries/53762ce4822f22984060bf1d5cc99505 to your computer and use it in GitHub Desktop.
Save geraldhumphries/53762ce4822f22984060bf1d5cc99505 to your computer and use it in GitHub Desktop.
Elasticsearch autocomplete impementation in JHipster
{
"index": {
"analysis": {
"filter": {
"autocomplete_filter": {
"type": "edge_ngram",
"min_gram": 1,
"max_gram": 30
},
"truncate_filter": {
"type": "truncate",
"length": 30
}
},
"analyzer": {
"autocomplete": {
"type": "custom",
"tokenizer": "keyword",
"filter": [
"lowercase",
"asciifolding",
"autocomplete_filter"
]
},
"autocomplete_search": {
"type": "custom",
"tokenizer": "keyword",
"filter": [
"lowercase",
"asciifolding",
"truncate_filter"
]
}
}
}
}
}
@Document(indexName = "entity")
@Setting(settingPath = "/config/elasticsearch/setting/autocomplete.json")
public class Entity implements Serializable {
@Column(name = "name")
@MultiField(
mainField = @Field(type = FieldType.String),
otherFields = {
@NestedField(
dotSuffix = "raw",
type = FieldType.String,
store = true,
index = FieldIndex.not_analyzed
),
@NestedField(
dotSuffix = "autocomplete",
type = FieldType.String,
indexAnalyzer = "autocomplete",
searchAnalyzer = "autocomplete_search"
)
}
)
private String name;
}
@amirensit
Copy link

@field and @NestedField annotations does not work with me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment