Dear Wiki user, You have subscribed to a wiki page or wiki category on "Solr Wiki" for change notification.
The following page has been changed by YonikSeeley: http://wiki.apache.org/solr/SolAjax The comment on the change is: JSON example ------------------------------------------------------------------------------ + = JSON Query Response Format = + Solr can return the result of a query in [http://www.json.org/ JSON] rather than the default XML format. This is enabled via the request parameter {{{wt=json}}} + + Variations of the JSON format are supported for [wiki:SolPython Python] and [wiki:SolRuby Ruby]. + + Example JSON output: + http://localhost:8983/solr/select/?q=video&indent=on&highlight=true&highlightFields=name,features&wt=json + {{{ + { + "header":{"qtime":0}, + "response":{"numFound":3,"start":0,"docs":[ + { + "id":"MA147LL/A", + "sku":"MA147LL/A", + "name":"Apple 60 GB iPod with Video Playback Black", + "manu":"Apple Computer Inc.", + "includes":"earbud headphones, USB cable", + "weight":5.5, + "price":399.0, + "popularity":10, + "inStock":true, + "cat":[ + "electronics", + "music"], + "features":[ + "iTunes, Podcasts, Audiobooks", + "Stores up to 15,000 songs, 25,000 photos, or 150 hours of video", + "2.5-inch, 320x240 color TFT LCD display with LED backlight", + "Up to 20 hours of battery life", + "Plays AAC, MP3, WAV, AIFF, Audible, Apple Lossless, H.264 video", + "Notes, Calendar, Phone book, Hold button, Date display, Photo wallet, Built-in games, JPEG photo playback, Upgradeable firmware, USB 2.0 compatibility, Playback speed control, Rechargeable capability, Battery level indication"]}, + { + "id":"EN7800GTX/2DHTV/256M", + "sku":"EN7800GTX/2DHTV/256M", + "name":"ASUS Extreme N7800GTX/2DHTV (256 MB)", + "manu":"ASUS Computer Inc.", + "weight":16.0, + "price":479.95, + "popularity":7, + "inStock":false, + "cat":[ + "electronics", + "graphics card"], + "features":[ + "NVIDIA GeForce 7800 GTX GPU/VPU clocked at 486MHz", + "256MB GDDR3 Memory clocked at 1.35GHz", + "PCI Express x16", + "Dual DVI connectors, HDTV out, video input", + "OpenGL 2.0, DirectX 9.0"]}, + { + "id":"100-435805", + "sku":"100-435805", + "name":"ATI Radeon X1900 XTX 512 MB PCIE Video Card", + "manu":"ATI Technologies", + "weight":48.0, + "price":649.99, + "popularity":7, + "inStock":false, + "cat":[ + "electronics", + "graphics card"], + "features":[ + "ATI RADEON X1900 GPU/VPU clocked at 650MHz", + "512MB GDDR3 SDRAM clocked at 1.55GHz", + "PCI Express x16", + "dual DVI, HDTV, svideo, composite out", + "OpenGL 2.0, DirectX 9.0"]}] + }, + "highlighting":{ + "MA147LL/A":{ + "features":["Stores up to 15,000 songs, 25,000 photos, or 150 hours of <em>video</em>"], + "name":["Apple 60 GB iPod with <em>Video</em> Playback Black"]}, + "EN7800GTX/2DHTV/256M":{ + "features":["Dual DVI connectors, HDTV out, <em>video</em> input"]}, + "100-435805":{ + "name":["ATI Radeon X1900 XTX 512 MB PCIE <em>Video</em> Card"]}} + } + }}} + + == JSON specific parameters == + * wt=json - enable JSON output + * json.nl=map - the default... !NamedList is represented as a JSON object. Although this is the simplest mapping, a !NamedList can have optional keys, repeated keys, and preserves order. Using a JSON object (essentially a map or hash) for a !NamedList results in the loss of some information. + * json.nl=arrarr - represent a !NamedList as an array of two element arrays {{{[[name1,val1], [name2, val2], [name3,val3]]}}} + == Using Solr's JSON output for AJAX == Solr's JSON output makes parsing the response in !JavaScript simple. Since JSON is a subset of !JavaScript, one can use the built-in !JavaScript parser to parse a JSON message.
