如何索引像“aaa.bbb.ddd-fff”这样的字符串在卢塞恩?
我必须索引很多包含参考号的文档,例如“aaa.bbb.ddd-fff”。结构可以更改,但它始终是一些任意数字或字符与“/”、“-”、“_”或其他分隔符的组合。
用户希望能够搜索任何子字符串(如“aaa”或“ddd”)以及“aaa.bbb”或“ddd-fff”等组合。我能想到的最好办法是创建自己的标记过滤器,该过滤器以“Lucene in action”中的同义词过滤器为模型,为每个输入吐出多个术语。就我而言,我返回“aaa.bbb”、“bbb.ddd”、“bbb.ddd-fff”以及子字符串的所有其他组合。这工作得很好,但是当我索引包含大量此类字符串的大型文档(100MB)时,我往往会出现内存不足的异常,因为我的过滤器为每个输入字符串返回多个术语。
有没有更好的方法来索引这些字符串?
I have to index a lot documents that contain reference numbers like "aaa.bbb.ddd-fff". The structure can change but it's always some arbitrary numbers or characters combined with "/","-","_" or some other delimiter.
The users want to be able to search for any of the substrings like "aaa" or "ddd" and also for combinations like "aaa.bbb" or "ddd-fff". The best I have been able to come up with is to create my own token filter modeled after the synonym filter in "Lucene in action" which spits out multiple terms for each input. In my case I return "aaa.bbb", "bbb.ddd","bbb.ddd-fff" and all other combinations of the substrings. This works pretty well but when I index large documents (100MB) that contain lots of such strings I tend to get out of memory exceptions because my filter returns multiple terms for each input string.
Is there a better way to index these strings?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我会尝试构建一个令牌过滤器:
对于查询,我首先尝试使用 SHOULD 术语进行布尔查询。
如果这给出了太多误报,我会将其更改为“必须”。
如果这仍然太多,我会尝试 PhraseQuery。
I would try to build a token filter that:
For the query, I would first try a boolean query with SHOULD terms.
If this gives too many false positives, I would change this to MUST.
If this is still too much, I would try a PhraseQuery.