zoukankan      html  css  js  c++  java
  • 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、查询

        

        

  • 相关阅读:
    重新进入学习模式
    第八章 函数
    第七章 用户输入和while语句
    第6章 字典
    第五章 if语句
    对前四章方法、函数、语句的总结
    完成四个章节的学习,我觉得有必要花一天的时间对各章节内的函数、方法、语句进行总结。明后天不再对新章节进行学习。
    第四章 操作列表
    第三章 列表简介
    C语言数据结构-折半查找
  • 原文地址:https://www.cnblogs.com/shaosks/p/8028543.html
Copyright © 2011-2022 走看看