solr的multivalued使用说明

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

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

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

[html] view plaincopy

  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. lt;/fields>

其中:

[html] view plaincopy

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

最后看下查询效果:

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

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

[java] view plaincopy

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

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

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

时间: 2024-08-28 11:40:29

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

solr的简单使用说明

0.solr简介 Apache Solr 是一个开源.高性能.跨平台.基于Lucene的全文搜索引擎,目标文档可以通过Http方式以xml.json.csv等不同数据格式上传并加载一个搜索集合中(collection),这个过程中solr会对上传的数据(文档)进行分词和建立索引操作,然后通过http接口查询结果,其中结果可以以xml.json.python等多种方式返回.Solr 中存储的资源是以 Document 为对象进行存储的.每个文档由一系列的 Field 构成,每个 Field 表示资

Solr学习总结(三)Solr web 管理后台

前面讲到了Solr的安装,按道理,这次应该讲讲.net与数据库的内容,C#如何操作Solr索引等.不过我还是想先讲一些基础的内容,比如solr查询参数使用说明和solr 自带的web 管理系统的使用等.只有先明白了solr的基本内容,后续学习solr 的C#和数据库操作,才不会费劲.本人刚开始也是配置完solr 之后,直接找solr客户端,写相应的测试代码,但是由于不知道一个Update请求具体都需要哪些参数,各个参数都是什么意思,以至于碰到各种solr 的基础问题,都不知道问题在哪? 前车之鉴

Solr使用入门指南

本文转自http://chuanliang2007.spaces.live.com/blog/cns!E5B7AB2851A4C9D2!499.entry?wa=wsignin1.0 由于搜索引擎功能在门户社区中对提高用户体验有着重在门户社区中涉及大量需要搜索引擎的功能需求,目前在实现搜索引擎的方案上有集中方案可供选择: 1. 基于Lucene自己进行封装实现站内搜索.工作量及扩展性都较大,不采用. 2. 调用Google.Baidu的API实现站内搜索.同第三方搜索引擎绑定太死,无法满足后期业

[转载] Solr使用入门指南

转载自http://blog.csdn.net/liuzhenwen/article/details/4060922 由于搜索引擎功能在门户社区中对提高用户体验有着重要的作用,在门户社区中涉及大量需要搜索引擎的功能需求,目前在实现搜索引擎的方案上有几种方案可供选择: 1. 基于Lucene自己进行封装实现站内搜索.工作量及扩展性都较大,不采用. 2. 调用Google.Baidu的API实现站内搜索.同第三方搜索引擎绑定太死,无法满足后期业务扩展需要,暂时不采用. 3. 基于Compass+Lu

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

由于搜索引擎功能在门户社区中对提高用户体验有着重在门户社区中涉及大量需要搜索引擎的功能需求,目前在实现搜索引擎的方案上有集中方案可供选择: 基于Lucene自己进行封装实现站内搜索. 工作量及扩展性都较大,不采用. 调用Google.Baidu的API实现站内搜索 同第三方搜索引擎绑定太死,无法满足后期业务扩展需要,暂时不采用. 基于Compass+Lucene实现站内搜索 适合于对数据库驱动的应用数据进行索引,尤其是替代传统的like ‘%expression%’来实现对varchar或clo

Solr入门指南

本文转自http://chuanliang2007.spaces.live.com/blog/cns!E5B7AB2851A4C9D2!499.entry?wa=wsignin1.0 因为搜索引擎功能在门户社区中对提高用户体验有着重在门户社区中涉及大量须要搜索引擎的功能需求.眼下在实现搜索引擎的方案上有集中方案可供选择: 1. 基于Lucene自己进行封装实现站内搜索.工作量及扩展性都较大,不採用. 2. 调用Google.Baidu的API实现站内搜索.同第三方搜索引擎绑定太死.无法满足后期业

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

问题描述如标题. 异常信息如下: Result Caused by: org.apache.solr.common.SolrException: Invalid Date String:'Mon Sep 14 01:48:38 CEST 2015' at org.apache.solr.util.DateFormatUtil.parseMath(DateFormatUtil.java:87) 对应开源问题单: https://issues.apache.org/jira/browse/SOLR-

Solr UI Admin管理界面使用说明

Notice:本说明基于Solr6.4.2. 本文讨论的是如何使用Solr Admin UI. 图1.SolrCloud模式 图2.单机Solr模式 Logging:展示Solr的日志,不用去后台查日志,并且还可以用来配置打印日志级别.Cloud:仅在SolrCloud模式下显示,本文中的例子使用的是单机模式,故暂不作介绍. CoreAdmin:支持SolrCore的基本操作.(点此查看什么是SolrCore)Java Properties:Java相关属性和配置.Thread Dump:查看每

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

copyField 与multiValued用途 在我们的应用中经常会有这种情形:当用户输入某个字符串查找时,需要如果在标题及内容中存在这个字会串时均要把记录加载出来,通过引入copyField及multiValue这两个标签便可解决这种问题.如: <!--这里无需定义id,因为managed_schema文件已经在前面开头位置定义了,id是必须,并且唯一的--> <field name="S_user" type="string" indexed