问题
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>
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.
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.
Thanks in reply
Maybe I can use the TemplateTransformer to combine value and type?
With TemplateTransformer I get a result: Marke | Volkswagen
In my data-import.xml (DIH)
<entity> name="tablename" transformer="TemplateTransformer">
<field column="test" template="${tablename.TYPE} | tablename.VALUE}"/>
...
</entity>
回答1:
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>
来源:https://stackoverflow.com/questions/9905667/apache-solr-faceted-search-on-multivalued-fields