如何使用“like"查询 lucene操作员?

2022-01-15 00:00:00 sql-like lucene java

通配符*只能用在词尾,如user*.

The wildcard * can only be used at the end of a word, like user*.

我想用 %user% 之类的查询,怎么做?

I want to query with a like %user%, how to do that?

推荐答案

Lucene提供了ReverseStringFilter 允许像 *user 一样进行前导通配符搜索.它通过以相反的顺序索引所有术语来工作.

Lucene provides the ReverseStringFilter that allows to do leading wildcard search like *user. It works by indexing all terms in reverse order.

但我认为没有办法做类似于 'LIKE %user%' 的事情.

But I think there is no way to do something similar to 'LIKE %user%'.

相关文章