多值多类型字段的solr索引 [英] solr index for multi-valued multi-type field

查看:28
本文介绍了多值多类型字段的solr索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在索引具有下一个结构的 xml 文档集合:

I am indexing a collection of xml document with the next structure:

<mydoc>
  <id>1234</id>
  <name>Some Name</name>
  <experiences>
    <experience years="10" type="Java"/>
    <experience years="4" type="Hadoop"/>
    <experience years="1" type="Hbase"/>
  </experiences>
</mydoc>

有什么方法可以创建solr索引以便支持下一个查询:

Is there any way to create solr index so that it would support the next query:

find all docs with experience type "Hadoop" and years>=3

到目前为止,我最好的想法是将分隔的年份||类型放入多值字符串字段中,搜索所有类型为Hadoop"的文档,然后遍历结果以选择年份>=3.显然,这对于大量文档来说是非常低效的.

So far my best idea is to put delimited years||type into multiValued string field, search for all docs with type "Hadoop" and after that iterate through the results to select years>=3. Obviously this is very inefficient for a large set of docs.

推荐答案

我认为对来自多对多关系的数据进行索引没有明显的解决方案.在这种情况下,我会使用动态字段:http://wiki.apache.org/solr/SchemaXml#Dynamic_fields

I think there is no obvious solution for indexing data coming from the many-to-many relationship. In this case I would go with dynamic fields: http://wiki.apache.org/solr/SchemaXml#Dynamic_fields

schema.xml 中的字段定义:

<dynamicField name="experience_*" type="integer"  indexed="true"  stored="true"/>

因此,使用您的示例,您最终会得到如下结果:

So, using your example you would end up with something like this:

<mydoc>
  <id>1234</id>
  <name>Some Name</name>
  <experience_Java>10</experience_Java>
  <experience_Hadoop>4</experience_Hadoop>
  <experience_Hbase>1</experience_Hbase>
</mydoc>

然后可以使用如下查询:fq=experience_Java:[3 to *]

Then you can use the following query: fq=experience_Java:[3 to *]

这篇关于多值多类型字段的solr索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆