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. netscope-支持caffe的在线可视化工具-转载

    Netscope是个支持prototxt格式描述的神经网络结构的在线可视工具,地址是here,可以用来可视化Caffe结构里prototxt格式的网络结构. Netscope使用起来也非常简单,打开这 ...

  2. gcc -o test test.c编译报错

    报错内容 /tmp/cc7eQyD4.o: In function `main':test.c:(.text+0x51): undefined reference to `sqrt'collect2: ...

  3. About DOM

    文档对象模型,简称DOM.是HTML页面结构给javascript提供的一个入口,它就像一个桥梁,连接两者的关系.通过DOM,JavaScript拥有访问并修改HTML的权限. 一.DOM模型: 首先 ...

  4. HDU 4666 最远曼哈顿距离

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=4666 关于最远曼哈顿距离的介绍: http://blog.csdn.net/taozifish/ar ...

  5. HTML标签 select 里 动态添加option

    HTML标签 select 里 动态添加option: ☆ var today = new Date(); var yearNow = today.getFullYear(); var optiong ...

  6. sql server CLR

    1. 配置sql server 启用CLR 在SQL Server2005/2008里面,CLR默认是关闭的.可以使用如下SQL语句开启CLR. sp_configure 'show advanced ...

  7. c2java Greedy 之任务调度

    近期调试一个javaproject的时候,我遇到不是期望的输出结果时.是这么干的: A1凝视掉抛出的异常: A2加打印对照异常输入和正常输入. A3进一步加打印缩小范围. 事实上仅仅需:B1静下心来细 ...

  8. TensorFlow笔记-01-开篇概述

    人工智能实践:TensorFlow笔记-01-开篇概述 从今天开始,从零开始学习TensorFlow,有相同兴趣的同志,可以互相学习笔记,本篇是开篇介绍 Tensorflow,已经人工智能领域的一些名 ...

  9. 【转】每天一个linux命令(21):find命令之xargs

    原文网址:http://www.cnblogs.com/peida/archive/2012/11/15/2770888.html 在使用 find命令的-exec选项处理匹配到的文件时, find命 ...

  10. java 设计模式:单例模式

    Java中单例模式是一种常见的设计模式,单例模式的写法有好几种,这里主要介绍三种:懒汉式单例.饿汉式单例.登记式单例. 单例模式有以下特点: 1.单例类只能有一个实例. 2.单例类必须自己创建自己的唯 ...