Created
November 11, 2016 22:56
-
-
Save geraldhumphries/53762ce4822f22984060bf1d5cc99505 to your computer and use it in GitHub Desktop.
Elasticsearch autocomplete impementation in JHipster
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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" | |
] | |
} | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@field and @NestedField annotations does not work with me