solr copyfield字段使用实践

  1、使用场景

    比如我们现在有一个文档,有title、author、area、keyword、link等字段。现在要把这个文档索引到 solr中,为了方便对author、area、keyword进行搜索,我们定义一个author_area_keyword的字段,

    把author、area、keyword的内容都拷贝到author_area_keyword字段中,这样copyfield就派上了用场,这样在创建文档的同事,三个字段的内容自动就复制到author_area_keyword中了。

    

 

  2、修改配置文件managed-schema

    语法:<copyField source=”” dest=””>

    source:原来的域。也就是你想要复制的域

    dest(destination):目标域。也就是要复制到那个字段。

    需要注意的是author_area_keyword字段要设置multiValued="true"

<field name="title" type="text_mmseg4j_simple" indexed="true" stored="true"/>
  <field name="author" type="string" indexed="true" stored="true"/>
  <field name="area" type="string" indexed="true" stored="true"/>
  <field name="keyword" type="string" indexed="true" stored="true"/>
  <field name="link" type="string" indexed="true" stored="true"/>
  <field name="author_area_keyword" type="string" multiValued="true" indexed="true" stored="false"/>
  <copyField source="area" dest="author_area_keyword"/>
  <copyField source="author" dest="author_area_keyword"/>
  <copyField source="keyword" dest="author_area_keyword"/>

  3、导入文件

    java -jar -Dc=data -Dauto post.jar ..\Import\*

 

  4、查询

    

    

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值