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. C# 历史曲线控件 基于时间的曲线控件 可交互的高级曲线控件 HslControls曲线控件使用教程

    本篇博客主要对 HslControls 中的曲线控件做一个详细的教程说明,大家可以根据下面的教程开发出高质量的曲线控件 Prepare 先从nuget下载到组件,然后就可以使用组件里的各种组件信息了. ...

  2. Linux shell —— 数组与关联数组

    使用 declare -A(declare 的用法请使用 help 进行查看,help declare) 进行声明关联数组变量: $ declare -A fruits_price $ fruits_ ...

  3. 【linux】wifi不能使用的问题

    Worked solution (Requirements: kernel >=4.11) : Download driver directory from this repo:https:// ...

  4. linux下sprintf_s函数的替代

    error code: ]; sprintf_s(buf, , "predicted position:(%3d, %3d)", predict_pt.x, predict_pt. ...

  5. js 获取客户端mac地址

    js 获取客户端mac地址 javascript获取客户端网卡MAC地址和IP地址和计算机名 nodesj如何获得客户端的mac地址呢? 浏览器获取MAC地址 不限浏览器的mac地址取得的几种办法 I ...

  6. 正则表达式matcher.group()用法

    本帖转自http://winter8.iteye.com/blog/1463244 group是针对()来说的,group(0)就是指的整个串,group(1) 指的是第一个括号里的东西,group( ...

  7. CTF之当铺密码

    当铺密码即:汉字的笔画有几笔出头,则代表数字几 例如:由=1 王=6 大=5

  8. LeetCode Factorial Trailing Zeroes Python

    Factorial Trailing Zeroes Given an integer n, return the number of trailing zeroes in n!. 题目意思: n求阶乘 ...

  9. 使用OASGraph 暴露rest 接口为graphql api

    OASGraph 是loopback 团队开发的方便将rest api 暴露为graphql 的工具, 这个也是loopback 4 的一个新特性类似的有些团队提出了binding 以及stitch ...

  10. 应用解决告诉你什么时候该用ajax

    第一.请求的提交是为了页面数据的显示,这时候用户一般不希望看到页面的刷新,是使用AJAX的一个最佳时候. 第二.如果请求提交后,用户能从页面感觉到提交结果,这时候,也最好不要有页面刷新,推荐使用AJA ...