将通配符查询设置为 QueryParser 的默认值
当我的用户输入“word”这样的术语时,我希望将其视为通配符查询“word*”,以便找到以“word”开头的所有术语。有没有办法告诉 QueryParser 自动创建通配符查询,或者我必须自己解析查询?对于简单的查询来说这应该不是问题,但对于更复杂的查询来说可能会变得很棘手。
When my users enter a term like "word" I would like it be treated as a wildcard query "word*" so all terms beginning "word" are found. Is there a way to tell the QueryParser to automatically create wildcard queries or do I have to parse the query myself? This shouldn't be a problem for simple queries but it may become tricky for more complex queries.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
除非我遗漏了一些东西 - 每个查询都使用通配符查询通常是不可取的 - 它非常昂贵并且可能会导致很多问题。如果您尝试查找包含词干变体的结果(例如 win -> Winner、wining 等),您应该考虑使用 n-gram 方法。
Unless I am missing something - a wildcard query for every query is usually inadvisable - it is very expensive and could cause a lot of problems. If you are trying find results including variants of a stem (e.g. win -> winner, winning, etc.) You should consider a n-gram approach.