0
votes

I am a newbie of Solr using version 6.5.0. How can i change name of function query field like alias name in mysql. In below response hsin field showing data in a field name as "hsin(6371, true, latitude, longitude, 0, 0)" i want to change that field name into a "distance". How can i do that?

http://localhost:8983/solr/tellWorld/select?indent=on&q=car&fl=hsin(6371,%20true,%20latitude,%20longitude,%200,%200)%20&wt=json&sort=hsin(6371,%20true,%20latitude,%20longitude,%200,%200)%20desc

Response:

{
  "responseHeader":{
    "status":0,
    "QTime":0,
    "params":{
      "q":"car",
      "indent":"on",
      "fl":"hsin(6371, true, latitude, longitude, 0, 0) ",
      "sort":"hsin(6371, true, latitude, longitude, 0, 0) desc",
      "wt":"json"}},
  "response":{"numFound":2,"start":0,"docs":[
      {
        "hsin(6371, true, latitude, longitude, 0, 0) ":8679.458682079623},
      {
        "hsin(6371, true, latitude, longitude, 0, 0) ":7560.780673825484}]
  }}
1

1 Answers

4
votes

The only thing that you need to change is the fl parameter, since Solr 4.0 (if I don't remember incorrectly) you can rename fields that you request using the fl parameter, so you just need something like:

fl=distance:hsin(6371, true, latitude, longitude, 0, 0)

This would return then the result of the calculation in the distance field.