Description Usage Arguments References Examples
View source: R/update_atomic_xml.R
Atomic updates to parts of Solr documents
1 |
conn |
A solrium connection object, see SolrClient |
body |
(character) XML as a character string |
name |
(character) Name of the core or collection |
wt |
(character) One of json (default) or xml. If json, uses
|
raw |
(logical) If |
... |
curl options passed on to crul::HttpClient |
https://lucene.apache.org/solr/guide/7_0/updating-parts-of-documents.html
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | ## Not run:
# start Solr in Cloud mode: bin/solr start -e cloud -noprompt
# connect
(conn <- SolrClient$new())
# create a collection
if (!conn$collection_exists("books")) {
conn$collection_delete("books")
conn$collection_create("books")
}
# Add documents
file <- system.file("examples", "books.xml", package = "solrium")
cat(readLines(file), sep = "\n")
conn$update_xml(file, "books")
# get a document
conn$get(ids = '978-0641723445', "books", wt = "xml")
# atomic update
body <- '
<add>
<doc>
<field name="id">978-0641723445</field>
<field name="genre_s" update="set">mystery</field>
<field name="pages_i" update="inc">1</field>
</doc>
</add>'
conn$update_atomic_xml(body, name="books")
# get the document again
conn$get(ids = '978-0641723445', "books", wt = "xml")
# another atomic update
body <- '
<add>
<doc>
<field name="id">978-0641723445</field>
<field name="price" update="remove">12.5</field>
</doc>
</add>'
conn$update_atomic_xml(body, "books")
# get the document again
conn$get(ids = '978-0641723445', "books", wt = "xml")
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.