Apache Solr:多值字段上的分面搜索 [英] Apache Solr: Faceted Search on multivalued fields
问题描述
我目前正在开发基于solr的搜索应用程序.
Im currently working on a solr based search application.
例如,我有两个多值字段: 数据将从数据库中读取.
I have two multivalued fields for example: The data is read out of a database.
<int name="id">1</int>
<arr name="type">
<str>Marke</str>
<str>Modell</str>
<str>Fahrzeugtyp</str>
<str>engine</str>
</arr>
<arr name="value">
<str>Volkswagen</str>
<str>Golf</str>
<str>Golf TDI</str>
<str>V-Engine</str>
在我当前的Solr配置中,这两个多值字段之间没有任何关系.这样我就可以说"Marke = Volkswagen".
In my current solr configuration there is no relationship between these two multivalued fields. So that i can say "Marke = Volkswagen".
此外,大众汽车与高尔夫之间必须存在某种关系.因此,我必须根据两个多值字段以及多值字段本身中的值来构建分类法.
Besides there must be a relationship between Volkswagen and Golf. So I have to structure a taxonomy out of the two multivalued fields and of the values in the multivalued field itself.
我试图建立一个typeAhead.在我当前的配置中,当我搜索Volkswagen时-可能的建议包含audi和engine2,它们不引用大众汽车模型.
solr网址:
> http://xyz:8983/solr/suggest?& ; wt = json& facet = true& q = *& facet.field = value& facet.prefix =大众
我认为在多个级联字段上进行Solr Faceting 与它有关,但是我无法根据自己的问题进行调整.
I tried to build a typeAhead. In my current config when i search for Volkswagen - the possible suggestions contain audi and engine2 which does not refer to a Volkswagen model.
solr url:
http://xyz:8983/solr/suggest?&wt=json&facet=true&q=*&facet.field=value&facet.prefix=Volkswagen
I think Solr Faceting on Multiple Concatenated Fields has something to do with it, but I can't adjust it on my problem.
谢谢回复
也许我可以使用TemplateTransformer来组合值和类型?
Maybe I can use the TemplateTransformer to combine value and type?
有了TemplateTransformer,我得到一个结果:Marke |大众
With TemplateTransformer I get a result: Marke | Volkswagen
在我的data-import.xml(DIH)中
In my data-import.xml (DIH)
<entity> name="tablename" transformer="TemplateTransformer">
<field column="test" template="${tablename.TYPE} | tablename.VALUE}"/>
...
</entity>
推荐答案
距离我解决此问题已有很长时间了.尝试在数据输入处理程序中使用此脚本.注意-此脚本基于solr 3.6.
It has been a long time since I've solved this problem. Try use this script in your data input handler. Attention - this script is based on solr 3.6.
<script>
<![CDATA[ function f1(row)
{
var eldName = row.get('TYPE');
row.put(eldName, row.get('VALUE'));
return row;
}
]]>
</script>
<entity name="e" transformer="script:f1" query="select TYPE, VALUE from X"></entity>
这篇关于Apache Solr:多值字段上的分面搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!