Hybris:使用相同的字段进行搜索和构面

San*_*era 2 search solr facet faceted-search sap-commerce-cloud

我必须在 Hybris 中对 solr 搜索和 solr 方面使用字段“manufacturerName”。虽然 solr 自由文本搜索要求字段类型为文本,但构面仅在字符串类型下正常工作。

有没有办法将同一字段用于搜索和构面。我认为有一种方法可以使用“copyField”,但我搜索了很多,但仍然不知道如何使用它?

任何帮助将不胜感激!

PS:在保留字段类型字符串时,自由文本搜索无法获取正确的结果。在保留字段类型文本时,facet 显示截断的值。

Mat*_*ndh 5

Using a copyField instruction is the way to go, but that require you to define an alternative field - meaning you have one field with the type text and the associated tokenization, and one field of the type string which isn't processed in any way. There is no way in Solr to combine these in a single field that I know of.

You'll then use the name of the string field to generate the facets, while you use the other field when you're querying.

<copyField source="text_search_field" dest="string_facet_field" />
Run Code Online (Sandbox Code Playgroud)

string_facet_field然后,当您在字段上进行过滤或分面时,您必须引用该名称。在用户选择一个构面后,您需要根据构面字段进行过滤,否则您最终会得到来自其他构面的文档,这些文档可能会泄漏到您的文档结果集中(例如,如果构面是“Foo Bar”,您将突然得到以“Baz Foo Bar Spam”为方面的文档,因为这两个词都出现在搜索字符串中。