Java: JPQL search -similar- strings
What methods are there to get JPQL to match similar strings?
By similar I mean:
- Contains: search string is found within the string of the matches entity
- Case-insensitive
- Small mispe开发者_开发问答llings: e.g. "arow" matches "arrow"
I suspect the first two will be easy, however, I would appreciate help with the last one
Thank you
The first two are indeed easy to do using the LIKE
and LOWER
or UPPER
keywords. The last one is very hard to do, since it requires you to define how similar two strings need to be. There is no basic keyword to do this easily in JPQL (as far as I know). You could use an algorithm like Levenshtein distance to determine if there is a small mispelling (distance of 1 or 2). This is not done in JPQL though...
精彩评论