@AutoComplete in Redis OM Spring maps to Redis Query Engine suggestion dictionaries (backed by FT.SUGADD/FT.SUGGET).
Each @AutoComplete field = one dictionary.
So in your entity, code
and name
create two separate dictionaries.
Redis Query Engine itself can’t query two suggestion dictionaries in one call — you either:
For merging at query time:
@GetMapping("/search")
fun query(@RequestParam("q") query: String): List<Suggestion> {
val codeResults = repository.autoCompleteCode(query, AutoCompleteOptions.get().withPayload())
val nameResults = repository.autoCompleteName(query, AutoCompleteOptions.get().withPayload())
return (codeResults + nameResults).distinctBy { it.string } // removes duplicates
}
If you want only one dictionary, store the values of name and code in a single @AutoComplete field instead.