简体   繁体   English

Apache Solr:多值字段上的分面搜索

[英]Apache Solr: Faceted Search on multivalued fields

Im currently working on a solr based search application. 我目前正在研究基于solr的搜索应用程序。

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>

In my current solr configuration there is no relationship between these two multivalued fields. 在我目前的solr配置中,这两个多值字段之间没有关系。 So that i can say "Marke = Volkswagen". 所以我可以说“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. 因此,我必须从两个多值字段和多值字段本身中的值构建分类。

I tried to build a typeAhead. 我试图构建一个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. 在我目前的配置中,当我搜索大众汽车时 - 可能的建议包含奥迪和引擎2,而不是大众汽车的型号。 solr url: solr url:

http://xyz:8983/solr/suggest?&wt=json&facet=true&q= *&facet.field=value&facet.prefix=Volkswagen 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. 我认为Solr Faceting on Multiple Concatenated Fields与它有关,但我无法根据我的问题进行调整。

Thanks in reply 谢谢你的回复


Maybe I can use the TemplateTransformer to combine value and type? 也许我可以使用TemplateTransformer来组合值和类型?


With TemplateTransformer I get a result: Marke | 使用TemplateTransformer,我得到一个结果:Marke | Volkswagen 大众汽车

In my data-import.xml (DIH) 在我的data-import.xml(DIH)中

<entity> name="tablename" transformer="TemplateTransformer">
<field column="test"  template="${tablename.TYPE} | tablename.VALUE}"/>
...
</entity>

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. 注意 - 此脚本基于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>

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

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