O'Reilly logo

Apache Solr 3.1 Cookbook by Rafał Kuć

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Indexing data in JSON format

Assume that we want to use Solr with a JavaScript-based application. XML file format is not an option, it's usually big and it demands parsing. We want our data format to be as light as possible. JSON (JavaScript Object Notation) comes to the rescue. Although it is completely language independent, it is a good choice when dealing with JavaScript. This recipe will show you how to use this newest update file format available in Solr.

How to do it...

Let's assume that we have an index with three fields: id, name, and author, which is multivalued. So the field definition part of schema.xml would look like this:

<field name="id" type="string" stored="true" indexed="true"/> <field name="name" type="string" stored="true" indexed="true" ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required