Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the Solr field type for storing JSON object?

Tags:

json

solr

I want to store Json data as a value to an field, currently I have tried keeping that field type as string or text, which is fine but the Json is stored in string and hence the double quotes(") are escaped inside that, so what field type need to be kept for Json Object ?

Eg, suppose my field is Thumbnail and it should be stored and display as json object instead of string like below

"Thumbnail": {
              "Url":    "http://www.example.com/image/481989943",
              "Height": 125,
              "Width":  "100"
          }
like image 351
Anumoy Sutradhar Avatar asked Feb 07 '23 04:02

Anumoy Sutradhar


1 Answers

You can store it as String. The issue you are facing - I assume - is when you want to return that JSON as structure within the Solr JSON response. By default Solr does not know that you want to embed the content rather than present it.

To tell it otherwise, try using a [json] document transformer in your fl parameter.

like image 131
Alexandre Rafalovitch Avatar answered Feb 19 '23 15:02

Alexandre Rafalovitch