跳转到内容
View in the app

A better way to browse. Learn more.

彼岸论坛

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.
欢迎抵达彼岸 彼岸花开 此处谁在 -彼岸论坛

[Elasticsearch] 大量短记录字段的模糊查询如何实现? es 的分词器如何实现多语种记录的转换和分词呢?

发表于

针对按月分片每月近 1ooow 的记录,其中有一个字段是 姓名 (中文居多,存在一部分繁日英,长度在[2, 50]左右,大部分都是 3 个字符)

现在业务侧要求尽量实现:

  • 1 、针对原纪录的全模糊查询,即只要输入的字符串是某个姓名的子序列,就将其捞出来; 例如,对于输入的 "张 aた" 是要匹配到 "张三 abきたない",因为不涉及到原字符的转换,这里直接使用了 1gram+match_phrase_prefix 来实现了

  • 2 、(目前遇到的问题) ,现在想要针对中简繁、日文、汉语等汉字系支持对应拼音、罗马音的模糊搜索, 例如,对于输入的 "张 san a ki t" 是要能够 匹配到 "张三 abきたない" 的; 即实际上要做到分词结果是 "张三 abきたない: 张 三 z h a n g s a n a b き た な い k i t a n a i" 的实现(当然这个我不是很确定是否是唯一解,只是认为如果能够达到这样的分词结果那就能满足我现在的搜索要求了)

我的问题是,如何实现这样的分词器呢?

  • 如果使用 pinyin+1gram 分词器(即不考虑日语等),好像分词结果是 " 张 三 zhang san a b き た な い" ,而我输入的字符串因为无法确定是否中英文,所以默认是打散的,"张 san a ki t" 分词结果是 "张 s a n a k i t" ,从而无法匹配到
  • 如果使用 icu_transform 等,貌似没法保留原字符串(或者这种场景下的自定义分词器该如何实现呢)

先感谢 dalao 们回复

Featured Replies

No posts to show

创建帐户或登录来提出意见

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.