solr4.10不区分大小写查询

 solr查询string类型时,有时需要使之不区分大小写( case insensitive),这时,就需要重新定义数据类型:
如统一转化为小写进行查询:

1
2
3
4
5
6
7
8
< fieldType  name = "string_ci"  class = "solr.TextField"   sortMissingLast = "true"  omitNorms = "true" >
      < analyzer >
         < tokenizer  class = "solr.KeywordTokenizerFactory" />          
         < filter  class = "solr.LowerCaseFilterFactory"  />
      </ analyzer >
  </ fieldType >
 
< field  name = "code"  type = "string_ci"  indexed = "true"  stored = "true"  />

因string类型为值是可不变的,因此此次使用TextField
(string field type for fields that contain structured values that shouldn’t be altered in any way)

注意:上面string_ci类型的field如果做facet时,得到的值将都是小写的,可能不符合实际需求。
因此,如果需要facet,需使用copyField再定义一个string类型的字段。
如:

1
2
3
<field name= "code_cp"  type= "string"  indexed= "true"  stored= "false"  />
 
  <copyField source= "code"  dest= "code_cp" />

对code_cp进行facet则行。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值