lucene Field引起的误会

今天,犯了个低级错误…做查询的时候发现lucene用queryparser只有完全等值才能匹配。

经过排查原来是在建立索引的时候使用了StringField作为字段(这个只支持全值相等)

改为TextField方可模糊查询……

baidu好多资料是没有发现的……

后来看到官方某个角落的文档发现了这个,才想起来怎么回事……感冒中……

  • public class Field
    extends Object
    implements IndexableField
    
    Expert: directly create a field for a document. Most users should use one of the sugar subclasses:

    A field is a section of a Document. Each field has three parts: name, type and value. Values may be text (String, Reader or pre-analyzed TokenStream), binary (byte[]), or numeric (a Number). Fields are optionally stored in the index, so that they may be returned with hits on the document.

    NOTE: the field type is an IndexableFieldType. Making changes to the state of the IndexableFieldType will impact any Field it is used in. It is strongly recommended that no changes be made after Field instantiation.


    评论
    添加红包

    请填写红包祝福语或标题

    红包个数最小为10个

    红包金额最低5元

    当前余额3.43前往充值 >
    需支付:10.00
    成就一亿技术人!
    领取后你会自动成为博主和红包主的粉丝 规则
    hope_wisdom
    发出的红包
    实付
    使用余额支付
    点击重新获取
    扫码支付
    钱包余额 0

    抵扣说明:

    1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
    2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

    余额充值