zoukankan      html  css  js  c++  java
  • solr的multivalued使用说明

    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.  <!--~K[1m~]~W段-->  
    15.  <field name="keywords" type="text" indexed="true" stored="false" multiValued="true"/>  
    16. lt;/fields>  

         其中:

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

        最后看下查询效果:

        

          从上图看书,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搜索出来。

  • 相关阅读:
    [学]寻找mysql高并发解决方案(事务,行锁,事务隔离级别)
    [学]MYSQL中replace into的用法
    Dynamics CRM OData方式进行增删改查时报错的问题
    Get Form type using javascript in CRM 2011
    Dynamics CRM 同一实体多个Form显示不同的Ribbon按钮
    java中throw与throws
    Dynamics CRM 通过OData查询数据URI中包含中文的情况
    我是怎样阅读技术论文的
    Dynamics CRM2013/2015 禁止欢迎界面(Disable the Welcome Screen)
    社会化网络分析
  • 原文地址:https://www.cnblogs.com/lvfeilong/p/werewrw132432.html
Copyright © 2011-2022 走看看