11.05.2016 Views

Apache Solr Reference Guide Covering Apache Solr 6.0

21SiXmO

21SiXmO

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

{<br />

"responseHeader":{<br />

"status":0,<br />

"QTime":1},<br />

"fields":[{<br />

"name":"Album",<br />

"type":"strings"}, // Field value guessed as String -> strings fieldType<br />

{<br />

"name":"Artist",<br />

"type":"strings"}, // Field value guessed as String -> strings fieldType<br />

{<br />

"name":"FromDistributor",<br />

"type":"tlongs"}, // Field value guessed as Long -> tlongs fieldType<br />

{<br />

"name":"Rating",<br />

"type":"tdoubles"}, // Field value guessed as Double -> tdoubles fieldType<br />

{<br />

"name":"Released",<br />

"type":"tdates"}, // Field value guessed as Date -> tdates fieldType<br />

{<br />

"name":"Sold",<br />

"type":"tlongs"}, // Field value guessed as Long -> tlongs fieldType<br />

{<br />

"name":"_text_",<br />

...<br />

},<br />

{<br />

"name":"_version_",<br />

...<br />

},<br />

{<br />

"name":"id",<br />

...<br />

}]}<br />

You Can Still Be Explicit<br />

Even if you want to use schemaless mode for most fields, you can still use the Schema API to<br />

pre-emptively create some fields, with explicit types, before you index documents that use them.<br />

Internally, the Schema API and the Schemaless Update Processors both use the same Managed<br />

Schema functionality.<br />

Once a field has been added to the schema, its field type is fixed. As a consequence, adding documents with<br />

field value(s) that conflict with the previously guessed field type will fail. For example, after adding the above<br />

document, the " Sold" field has the fieldType tlongs, but the document below has a non-integral decimal<br />

value in this field:<br />

curl "http://localhost:8983/solr/gettingstarted/update?commit=true" -H<br />

"Content-type:application/csv" -d '<br />

id,Description,Sold<br />

19F,Cassettes by the pound,4.93'<br />

This document will fail, as shown in this output:<br />

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

102

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

Saved successfully!

Ooh no, something went wrong!