79719983

Date: 2025-07-30 12:53:06
Score: 1
Natty:
Report link

@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.

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @AutoComplete
  • User mentioned (0): @AutoComplete
  • User mentioned (0): @AutoComplete
  • User mentioned (0): @AutoComplete
  • Low reputation (1):
Posted by: Raphael De Lio