solr的schema.xml配置文件在配置Filed的时候,有个属性:

MutiValued:true if this field may containmutiple values per documents,这个说明有点模糊,下面结合实际应用,列举两个不同的例子。

例子一:一个field有多个值,值来自同一filed

  1.  
    <fields>
  2.  
    <!-- general -->
  3.  
    <field name="id" type="int" indexed="true" stored="true" multiValued="false" required="true"/>
  4.  
    <field name="planTime" type="tdate" indexed="true" stored="false" multiValued="false" />
  5.  
    <field name="state" type="string" indexed="true" stored="false" multiValued="false" />
  6.  
    <field name="overDate" type="string" indexed="true" stored="false" multiValued="false" />
  7.  
    <field name="type" type="int" indexed="true" stored="false" multiValued="false" />
  8.  
    <field name="contactName" type="textComplex" indexed="true" stored="false" multiValued="false" />
  9.  
    <field name="contactTel" type="string" indexed="true" stored="false" multiValued="false" />
  10.  
    <field name="customer" type="textComplex" indexed="true" stored="false" multiValued="false" />
  11.  
    <field name="alias" type="textComplex" indexed="true" stored="false" multiValued="false" />
  12.  
    <field name="englishName" type="textComplex" indexed="true" stored="false" multiValued="false" />
  13.  
    <field name="executor" type="int" indexed="true" stored="true" multiValued="true" />
  14.  
    <!--[1m~K[1m~][1m~W段-->
  15.  
    <field name="keywords" type="text" indexed="true" stored="false" multiValued="true"/>
  16.  
    </fields>

其中:

  1.  
    <field name="executor" type="int" indexed="true" stored="true" multiValued="true" /
  2.  
     

最后看下查询效果:

从上图看书,executor这个field可以多个值,任何executor:29 OR executor:40,类似查询都能查出id为3的记录。

附注:使用solrj建此索引时,定义成集合类型即可,如:

  1.  
    @Field
  2.  
    private Set<Integer> executor;
  3.  
     
  4.  
    public Set<Integer> getExecutor() {
  5.  
    return executor;
  6.  
    }
  7.  
     
  8.  
    public void setExecutor(Set<Integer> executor) {
  9.  
    this.executor = executor;
  10.  
    }

例子二:类似综合搜索,结合copyFiled使用,多个Filed拷贝到该Field上

从上图看出keywords区域,是name、introduction、industryName三个的集合,无论搜索name、introduction、industryName中任意一个,都能通过keywords搜索出来。

solr的multivalued使用说明的更多相关文章

  1. solr 从零学习开始

    2010-10 目 录 1 1.1 1.2 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.3 1.3.1 1.3.2 1.4 1.4.1 1.4.2 1.4. ...

  2. Solr使用入门指南

    本文转自http://chuanliang2007.spaces.live.com/blog/cns!E5B7AB2851A4C9D2!499.entry?wa=wsignin1.0 由于搜索引擎功能 ...

  3. 企业级搜索引擎Solr使用入门指南

    由于搜索引擎功能在门户社区中对提高用户体验有着重在门户社区中涉及大量需要搜索引擎的功能需求,目前在实现搜索引擎的方案上有集中方案可供选择: 基于Lucene自己进行封装实现站内搜索. 工作量及扩展性都 ...

  4. Solr入门指南

    本文转自http://chuanliang2007.spaces.live.com/blog/cns!E5B7AB2851A4C9D2!499.entry?wa=wsignin1.0 因为搜索引擎功能 ...

  5. [转载] Solr使用入门指南

    转载自http://blog.csdn.net/liuzhenwen/article/details/4060922 由于搜索引擎功能在门户社区中对提高用户体验有着重要的作用,在门户社区中涉及大量需要 ...

  6. Solr部分更新MultiValued的Date日期字段时报错及解决方案

    问题描述如标题. 异常信息如下: Result Caused by: org.apache.solr.common.SolrException: Invalid Date String:'Mon Se ...

  7. Importing multi-valued field into Solr from mySQL using Solr Data Import Handler

    http://stackoverflow.com/questions/20233837/importing-multi-valued-field-into-solr-from-mysql-using- ...

  8. solr联合多个字段进行检索(multivalued和copyfield的使用)

    在实际工作中不仅仅对索引中的单个字段进行搜索.需要进行综合查询. 比如book表中有id,name(标题),price,summary(摘要),content(内容),我们要找一本书的时候,查询关键字 ...

  9. Solr部分更新MultiValued的Date日期字段时报错及解决方案:Invalid Date String:'Mon Sep 14 01:48:38 CST 2015'

    问题描述如标题. 异常信息如下: Result Caused by: org.apache.solr.common.SolrException: Invalid Date String:'Mon Se ...

随机推荐

  1. opencv-python教程学习系列8-opencv图像算术运算

    前言 opencv-python教程学习系列记录学习python-opencv过程的点滴,本文主要介绍图像的算术运算,坚持学习,共同进步. 系列教程参照OpenCV-Python中文教程: 系统环境 ...

  2. TJU Problem 2520 Quicksum

    注意: for (int i = 1; i <= aaa.length(); i++) 其中是“ i <= ",注意等号. 原题: 2520.   Quicksum Time L ...

  3. Python中if __name__ == "__main__"详解

       比如你编写一个test.py文件,一个python文件就可以看作是一个python的模块,这个python模块(.py文件)有两种使用方式:直接运行使用和作为模块被其他模块调用.   解释下__ ...

  4. HDU 2111:Saving HDU(贪心)

    Saving HDU Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total ...

  5. HDU 4651 数论 partition 求自然数的拆分数

    别人的解题报告: http://blog.csdn.net/zstu_zlj/article/details/9796087 我的代码: #include <cstdio> #define ...

  6. Python需要知道的知识点

    1.所有数据类型都自带布尔值,布尔值为假的数据类型 包括( 空字符串,空列表,空字典,空集合).数字(0).None类型 2.Python实现int的时候有个小整数池.为了避免因创建相同的值而重复申请 ...

  7. @ModelAttribute的用法

  8. 常用css样式函数总结

    1:按钮样式 /*按钮*/ @mixin btn-style($btnwidth, $color, $bgcolor, $bdcolor) { width: $btnwidth; height: 30 ...

  9. BAT编程

    echo 表示显示此命令后的字符  echo off 表示在此语句后所有运行的命令都不显示命令行本身  @与echo off相象,但它是加在每个命令行的最前面,表示运行时不显示这一行的命令行(只能影响 ...

  10. Linux 安装Jdk、mysql、apache、php、tomcat、nginx

    Jdk 安装分三步:第一步,上传跟 linux 位数相同的 jdk tar 包,解压:第二步:解压 tar 包,配置环境变量,且 source 一下 /etc/profile:第三步:检查版本 第一步 ...