如何在Solr的查询期间将2个字段串联为一个 [英] How to concatenate 2 fields into one during query time in solr

查看:89
本文介绍了如何在Solr的查询期间将2个字段串联为一个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在solr中有一个文档,该文档已被索引并存储为

I have a document in solr which is already indexed and stored like

{
"title":"Harry potter",
"url":"http://harrypotter.com",
"series":[
           "sorcer's stone",
           "Goblin of fire",
          ]
}

我的要求是,在尝试检索文档的查询期间 它应该将2个字段串联在一起,并给出类似的输出

My requirement is,during query time when I try to retrieve the document it should concatenate 2 fields in to and give the output like

{
  "title":"Harry potter",
"url":"http://harrypotter.com",
"series":[
           "sorcer's stone",
           "Goblin of fire",
          ],
"title_url":"Harry potter,http://harrypotter.com"
}

我知道如何在索引时间内使用URP做到这一点,但是我无法理解如何在查询时间内实现这一点.任何人都可以帮我解决这个问题.任何示例代码都将对我有很大帮助我.谢谢您的时间.

I know how to do it during index time by using URP but I'm not able to understand how to achieve this during query time.Could anyone please help me with this.Any sample code for reference would be a great help to me.Thanks for your time.

推荐答案

concat函数在solr7中可用:

concat function is available in solr7:

http://localhost:8983/solr/col/query?...&fl=title,url,concat(title,url)

如果您使用的是较旧的solr,那么在客户端执行此操作有多困难?

if you are in an older solr, how difficult is to do this on the client side?

这篇关于如何在Solr的查询期间将2个字段串联为一个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆