Im using Sunspot Solr in Rails. My code looks as below :
searchable do
text :title, :stored => true
string :id, :stored => true
integer :status, :stored => true
end
and In my controller, after performing the search when I go to store it in a hash:
one_result= {:title => hit.stored(:title), :id => hit.stored(:id)}
now when I do puts one_result.inspect
, I get:
{"title": ["THIS IS TITLE"]
"id":12345
}
The problem is that all the text field become array [..]
. I want to include the results in a json response. I want it to be :
{"title": "THIS IS TITLE"
"id":12345
}
Any help ?
I guess the fieldType for the field "Title" is defined as multivalued="true" in schema.xml.
Please make it as false so that you get it as a string.