多值多类型场的solr指数 [英] solr index for multi-valued multi-type field
问题描述
我正在使用下一个结构索引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
到目前为止,我最好的想法是将分隔年份||类型放入multiValued字符串字段,搜索所有类型为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屋!