How to concatenate 2 fields into one during query time in solr

南楼画角 提交于 2019-12-24 07:39:09

问题


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",
          ]
}

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"
}

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.


回答1:


concat function is available in solr7:

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

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




回答2:


To concat you can use concat(field1, field2).

There are many other functions to manipulate data while retrieving. You can see that here.



来源:https://stackoverflow.com/questions/49361522/how-to-concatenate-2-fields-into-one-during-query-time-in-solr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!