简体   繁体   English

Solr长多值字段不起作用

[英]Solr long multivalued field is not working

I have a solr entity with a filed defind as: 我有一个solr实体,其归档值为:

<field name="rel_ids" type="long" indexed="true" stored="true" multivalue="true" />

and i fill it vie data import handler: with like this 我用视觉数据导入处理程序填充它:

<field column="rel_ids" sourceColName="rel_idsc" splitBy=","/>

but i can not search on this field for instance the following queries are not working: 但我无法在此字段上搜索,例如以下查询不起作用:

rel_ids:1 --> no result rel_ids:1->没有结果

rel_ids:* --> no result rel_ids:*->没有结果

here is my full schema: 这是我的完整架构:

<schema name="example" version="1.5">
<fields>
    <field name="id" type="long" indexed="true" stored="true" required="true" />
    <field name="id_S100" type="long" indexed="true" stored="true" required="false" />
    <field name="id_S95" type="long" indexed="true" stored="true" required="false" />
    <field name="id_S90" type="long" indexed="true" stored="true" required="false" />
    <field name="id_None" type="long" indexed="true" stored="true" required="false" />
    <field name="text" type="text_ar" indexed="true" stored="true" />
    <field name="text_noStem" type="text_ar_noStem" indexed="true" stored="true" />
    <field name="text_noStem_withHarekat" type="text_ar_noStem_withHarekat" indexed="true" stored="true" />

    <field name="source_book" type="string" indexed="true" stored="true" />
    <field name="source_volume" type="string" indexed="true" stored="true" />
    <field name="source_page" type="int" indexed="true" stored="true" />
    <field name="rel_ids" type="long" indexed="true" stored="true" multiValued="true" />
    <field name="_version_" type="long" indexed="true" stored="true"/>
</fields>
<uniqueKey>id</uniqueKey>
<copyField source="text" dest="text_noStem" />
<copyField source="text" dest="text_noStem_withHarekat" />

 <types>
<!-- field type definitions. The "name" attribute is
   just a label to be used by field definitions.  The "class"
   attribute and any other attributes determine the real
   behavior of the fieldType.
     Class names starting with "solr" refer to java classes in a
   standard package such as org.apache.solr.analysis
-->

<!-- The StrField type is not analyzed, but indexed/stored verbatim. -->
<fieldType name="string" class="solr.StrField" sortMissingLast="true" />

<!-- boolean type: "true" or "false" -->
<fieldType name="boolean" class="solr.BoolField" sortMissingLast="true"/>

<!-- sortMissingLast and sortMissingFirst attributes are optional attributes are
     currently supported on types that are sorted internally as strings
     and on numeric types.
     This includes "string","boolean", and, as of 3.5 (and 4.x),
     int, float, long, date, double, including the "Trie" variants.
   - If sortMissingLast="true", then a sort on this field will cause documents
     without the field to come after documents with the field,
     regardless of the requested sort order (asc or desc).
   - If sortMissingFirst="true", then a sort on this field will cause documents
     without the field to come before documents with the field,
     regardless of the requested sort order.
   - If sortMissingLast="false" and sortMissingFirst="false" (the default),
     then default lucene sorting will be used which places docs without the
     field first in an ascending sort and last in a descending sort.
-->    

<!--
  Default numeric field types. For faster range queries, consider the tint/tfloat/tlong/tdouble types.
-->
<fieldType name="int" class="solr.TrieIntField" precisionStep="0" positionIncrementGap="0"/>
<fieldType name="float" class="solr.TrieFloatField" precisionStep="0" positionIncrementGap="0"/>
<fieldType name="long" class="solr.TrieLongField" precisionStep="0" positionIncrementGap="0"/>
<fieldType name="double" class="solr.TrieDoubleField" precisionStep="0" positionIncrementGap="0"/>
...

and

my data import handler field matching: 我的数据导入处理程序字段匹配:

   <dataConfig>
<dataSource type="JdbcDataSource" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost/hadithtest" user="root" password="root"/>
<document name="Hadiths" >
<entity name="hadith" transformer="RegexTransformer"  query="SELECT ..." >
    <field name="id" column="id" />
    <field name="text" column="basetext" />
    <field name="source_book" column="source_bookglossary" />
    <field name="source_volume" column="source_volumestring" />
    <field name="source_page" column="source_pagestring" />
    <field name="id_None" column="id_None" />
    <field name="id_S100" column="id_S100" />
    <field name="id_S95" column="id_S95" />
    <field name="id_S90" column="id_S90" />
    <field column="aye_ids" sourceColName="aye_idsc" splitBy="\s+"/>
    <field name="aye_ids_text" column="aye_idsc" />
   <!--
    <field name="TextID" column="text_id" />
    <entity name="RText" query="select * from richtext where richtext.id='${hadith.TextID}'" >
        <field name="Text" column="text" />
    </entry>
    -->
</entity>

can anyone help about this problem? 有人可以帮助解决这个问题吗? (i cant query on rel_ids (我无法查询rel_ids

I fount my mistake! 我发现我的错误!

the problem is that I did not specified the transformer in dataImport entity tag. 问题是我没有在dataImport entity标签中指定transformer

so data import should be like this: 因此数据导入应如下所示:

<dataConfig>
<dataSource type="JdbcDataSource" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost/hadithtest" user="root" password="root"/>
<document name="Hadiths" >
<entity name="hadith" transformer="RegexTransformer"  query="SELECT ..." >
    <field name="id" column="id" />
    <field name="text" column="basetext" />
    <field name="source_book" column="source_bookglossary" />
    <field name="source_volume" column="source_volumestring" />
    <field name="source_page" column="source_pagestring" />
    <field name="id_None" column="id_None" />
    <field name="id_S100" column="id_S100" />
    <field name="id_S95" column="id_S95" />
    <field name="id_S90" column="id_S90" />
    <field column="aye_ids" sourceColName="aye_idsc" splitBy="\s+"/>
    <field name="aye_ids_text" column="aye_idsc" />
   <!--
    <field name="TextID" column="text_id" />
    <entity name="RText" query="select * from richtext where richtext.id='${hadith.TextID}'" >
        <field name="Text" column="text" />
    </entry>
    -->
</entity>
</document>
</dataConfig>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM