11.05.2016 Views

Apache Solr Reference Guide Covering Apache Solr 6.0

21SiXmO

21SiXmO

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

curl 'http://localhost:8983/solr/my_collection/update/json/docs'\<br />

'?split=/exams'\<br />

'&f=/**'\<br />

-H 'Content-type:application/json' -d '<br />

{<br />

"first": "John",<br />

"last": "Doe",<br />

"grade": 8,<br />

"exams": [<br />

{<br />

"subject": "Maths",<br />

"test" : "term1",<br />

"marks" : 90},<br />

{<br />

"subject": "Biology",<br />

"test" : "term1",<br />

"marks" : 86}<br />

]<br />

}'<br />

Because we want the fields to be indexed with the field names as they are found in the JSON input, the double<br />

wildcard in f=/** will map all fields and their descendants to the same fields in <strong>Solr</strong>.<br />

It is also possible to send all the values to a single field and do a full text search on that. This is a good option to<br />

blindly index and query JSON documents without worrying about fields and schema.<br />

curl 'http://localhost:8983/solr/my_collection/update/json/docs'\<br />

'?split=/'\<br />

'&f=txt:/**'\<br />

-H 'Content-type:application/json' -d '<br />

{<br />

"first": "John",<br />

"last": "Doe",<br />

"grade": 8,<br />

"exams": [<br />

{<br />

"subject": "Maths",<br />

"test" : "term1",<br />

"marks" : 90},<br />

{<br />

"subject": "Biology",<br />

"test" : "term1",<br />

"marks" : 86}<br />

]<br />

}'<br />

In the above example, we've said all of the fields should be added to a field in <strong>Solr</strong> named 'txt'. This will add<br />

multiple fields to a single field, so whatever field you choose should be multi-valued.<br />

The default behavior is to use the fully qualified name (FQN) of the node. So, if we don't define any field<br />

mappings, like this:<br />

<strong>Apache</strong> <strong>Solr</strong> <strong>Reference</strong> <strong>Guide</strong> <strong>6.0</strong><br />

193

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!