update_atomic_json: Atomic updates with JSON data

Description Usage Arguments References Examples

View source: R/update_atomic_json.R

Description

Atomic updates to parts of Solr documents

Usage

1
update_atomic_json(conn, body, name, wt = "json", raw = FALSE, ...)

Arguments

conn

A solrium connection object, see SolrClient

body

(character) JSON as a character string

name

(character) Name of the core or collection

wt

(character) One of json (default) or xml. If json, uses jsonlite::fromJSON() to parse. If xml, uses xml2::read_xml() to parse

raw

(logical) If TRUE, returns raw data in format specified by wt param

...

curl options passed on to crul::HttpClient

References

https://lucene.apache.org/solr/guide/7_0/updating-parts-of-documents.html

Examples

 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
## 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", "books2.json", package = "solrium")
cat(readLines(file), sep = "\n")
conn$update_json(file, "books")

# get a document
conn$get(ids = 343334534545, "books")

# atomic update
body <- '[{
 "id": "343334534545",
 "genre_s": {"set": "mystery" },
 "pages_i": {"inc": 1 }
}]'
conn$update_atomic_json(body, "books")

# get the document again
conn$get(ids = 343334534545, "books")

# another atomic update
body <- '[{
 "id": "343334534545",
 "price": {"remove": "12.5" }
}]'
conn$update_atomic_json(body, "books")

# get the document again
conn$get(ids = 343334534545, "books")

## End(Not run)

solrium documentation built on May 19, 2021, 9:06 a.m.