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. 为什么要使用AOP

    首先,按照软件重构思想的理念,如果多个类中出现相同的代码,应该考虑定义一个共同的抽象类,将这些相同的代码提取到抽象类当中去.比如Horse.Pig.Camel这些对象都有run().eat()方法,通 ...

  2. SharePoint 2010: Change welcome page on PowerShell

    摘要: SharePoint 2010之后呢, 建立一个 Team Site会有两个 default page, 分别是 Sitepages/home.aspx and default.aspx. 这 ...

  3. Magento邮件发送完美设置

    Magento新站上线伊始,不料在邮件上遇到了问题.此时常用的邮件模板已经编辑完毕,诸如New Account, New Order, Password Forget等. CentOS下发送邮件很简单 ...

  4. magento如何在首页显示产品

    1.首先现在magento后台创建一个新的分类,记下这个分类的 ID 号码.使用这个新建的分类来管理你的首页产品,这个分类设置为前台不可见.这样就不会显示在你的分类菜单中了,但使用代码调用的时候却会显 ...

  5. ASCII编码和Unicode编码的区别

    链接: 计算机只能处理数字,如果要处理文本,就必须先把文本转换为数字才能处理.Unicode把所有语言都统一到一套编码里,这样就不会再有乱码问题了.Unicode标准也在不断发展,但最常用的是用两个字 ...

  6. Adobe Flash Player - imsoft.cnblogs

    Adobe Flash Player是一个跨平台.基于浏览器的应用程序.运行时,它可以跨屏幕和浏览器原汁原味地查看具有表现力的应用程序.内容和视频.Flash Player实现了移动屏幕上的高性能优化 ...

  7. PHPEmailer使用简介(以qq邮箱为例)

    1.从网上下载PHPEmailer: 2.确保PHP环境支持sockets扩展,还要开启openssl,如下图: 3.配置QQ邮箱 1.开启SMTP服务 2.验证密保 3.获取授权码(这个就是IMAP ...

  8. 区间DP Zoj 3537 Cake 区间DP 最优三角形剖分

    下面是别人的解题报告的链接,讲解很详细,要注意细节的处理...以及为什么可以这样做 http://blog.csdn.net/woshi250hua/article/details/7824433 我 ...

  9. Java-JDK & Android SDK下载安装及配置教程

    转自:http://blog.csdn.net/dr_neo/article/details/49870587 第一步.安装JDK: 第二步.安装Eclipse: 第三步.下载并安装AndroidSD ...

  10. StreamSets SDC RPC Pipelines说明

    主要目的是进行跨pipeline 数据的通信,而不仅仅是内部pipeline 的通信,之间不同网络进行通信 一个参考图 pipeline 类型 origin destination 部署架构 使用多个 ...