Java:JPQL 搜索相似字符串

发布于 2024-09-04 15:01:07 字数 183 浏览 5 评论 0原文

有哪些方法可以让JPQL匹配相似的字符串?

类似我的意思是:

  • 包含:在匹配实体的字符串中找到搜索字符串
  • 不区分大小写
  • 小拼写错误:例如“arow”匹配“arrow”

我怀疑前两个会很容易,但是,我希望对最后一个有帮助一个

谢谢

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 mispellings: e.g. "arow" matches "arrow"

I suspect the first two will be easy, however, I would appreciate help with the last one

Thank you

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

箜明 2024-09-11 15:01:07

前两个确实很容易使用 完成LIKELOWERUPPER 关键字。最后一项很难做到,因为它要求您定义两个字符串的相似程度。在 JPQL 中没有基本关键字可以轻松做到这一点(据我所知)。您可以使用诸如 Levenshtein distance 之类的算法来确定是否存在小拼写错误(距离为 1或 2)。但这在 JPQL 中并没有完成......

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文