Adding a multivalued, commas separated String to Solr isn't working

倖福魔咒の 提交于 2019-12-13 00:38:12

问题


I am trying to add a multivalued content to Solr index. The original String contains values seperated by ",".

<fieldtype name="commas_type" class="solr.TextField" omitNorms="true">
    <analyzer type="index">
        <tokenizer class="solr.PatternTokenizerFactory" pattern=",\s*"/>
        <filter class="solr.LowerCaseFilterFactory" />
    </analyzer>
    <analyzer type="query">
        <tokenizer class="solr.PatternTokenizerFactory" pattern=",\s*"/>
        <filter class="solr.LowerCaseFilterFactory" />
    </analyzer>
</fieldtype> 


<field name="keywords" type="commas_type" stored="true" indexed="true" multiValued="true" />

But instead of getting :

 <doc>
   <arr name="keywords">
     <str>Agile</str>
     <str>Kanban</str>
     <str>Clojure</str>
     <str>Datomic</str>
   </arr>
 </doc>

I'm getting:

 <doc>
   <arr name="keywords">
     <str>Agile, Kanban</str>
     <str>Clojure, Datomic</str>
   </arr>
 </doc>

回答1:


Solr does not change the Stored values for the Original data.
The pattern tokenizer would only be applied to the index values. So if you check your index for the indexed terms you would get the values splitted by ,.
However, the values returned by Solr would always be the values fed to it.

You would need to handle it at client side.



来源:https://stackoverflow.com/questions/16278593/adding-a-multivalued-commas-separated-string-to-solr-isnt-working

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!