solr mysql splitby,Solr Facet具有逗号分隔值的多个单词

I'm pulling data into solr from mysql. One of the fields is generated using a group_concat function that results in a comma separated field that lists all the bands for an event. At the time I believe this was the best way to store multiple bands for one event. However, I'm finding that I cannot facet this query against all events.

I've set the band field to string and multivalued to true.

The result is as expected where the string is faceted as one long string.

"Pearl Jam,Alice,Screaming Trees,Everclear",1,

"Primus,Gaga,Bacon Bits",1,

"Roosters,Wings,Drumsticks,Tail Feathers",1,

The biggest problem with this approach is when the field type is string it appears to not be searchable. Seems like I need to create a duplicate field that is type text_general for searching and have one for faceting. Yes?

Is there a way to declare a delimiter for the band field to facet this properly, or is my approach wrong?

解决方案

Tokenizing your field will not solve your facet problem, you will be able to search with a single band name and get results, but the facet will be even worse. The basic rule is to not use any tokenization or text enhance for field used to make facets.

It's good to use a multiValued field, but are actually putting into it a single value with a list of bands, because your query return that list as a single column that is mapped to a single value for the related field in Solr.

You can keep the group_concat output and solve your problem with a simple change to your data-config.xml, telling Solr to split those band names using a separator. Have a look at the RegexTransformer and its splitBy parameter:

splitBy : Used to split a String to obtain multiple values, returns a

list of values

If you configure the splitBy with the same separator you're using for group_concat the trick is done, you'll have multiple values and your facet will look good.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值