Skip to content
This repository was archived by the owner on Sep 9, 2022. It is now read-only.

Commit 088720a

Browse files
committed
update all vignettes
1 parent 06cea25 commit 088720a

File tree

8 files changed

+697
-696
lines changed

8 files changed

+697
-696
lines changed

inst/examples/add_delete.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
<field name="sequence_i">1</field>
1010
<field name="genre_s">fantasy</field>
1111
<field name="inStock">TRUE</field>
12-
<field name="price">12.5</field>
1312
<field name="pages_i">384</field>
1413
</doc>
1514
</add>

inst/stuff/document_management.md

Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ conn$add(df, "books")
6868
#> [1] 0
6969
#>
7070
#> $responseHeader$QTime
71-
#> [1] 51
71+
#> [1] 36
7272
```
7373

7474
### list
@@ -87,7 +87,7 @@ conn$add(ss, "books")
8787
#> [1] 0
8888
#>
8989
#> $responseHeader$QTime
90-
#> [1] 26
90+
#> [1] 37
9191
```
9292

9393
## Delete documents
@@ -112,7 +112,7 @@ conn$add(docs, "gettingstarted")
112112
#> [1] 0
113113
#>
114114
#> $responseHeader$QTime
115-
#> [1] 438
115+
#> [1] 42
116116
```
117117

118118
And the documents are now in your Solr database
@@ -124,11 +124,11 @@ conn$search(name = "gettingstarted", params = list(q = "*:*", rows = 3))
124124

125125
```
126126
#> # A tibble: 3 x 4
127-
#> id title title_str `_version_`
128-
#> <chr> <chr> <chr> <dbl>
129-
#> 1 10 adfadsf adfadsf 1.582911e+18
130-
#> 2 12 though though 1.582911e+18
131-
#> 3 14 animals animals 1.582911e+18
127+
#> id title title_str `_version_`
128+
#> <chr> <chr> <chr> <dbl>
129+
#> 1 10 adfadsf adfadsf 1.62e18
130+
#> 2 12 though though 1.62e18
131+
#> 3 14 animals animals 1.62e18
132132
```
133133

134134
Now delete those documents just added
@@ -144,7 +144,7 @@ conn$delete_by_id(ids = c(1, 2, 3), "gettingstarted")
144144
#> [1] 0
145145
#>
146146
#> $responseHeader$QTime
147-
#> [1] 129
147+
#> [1] 19
148148
```
149149

150150
And now they are gone
@@ -156,11 +156,11 @@ conn$search("gettingstarted", params = list(q = "*:*", rows = 4))
156156

157157
```
158158
#> # A tibble: 3 x 4
159-
#> id title title_str `_version_`
160-
#> <chr> <chr> <chr> <dbl>
161-
#> 1 10 adfadsf adfadsf 1.582911e+18
162-
#> 2 12 though though 1.582911e+18
163-
#> 3 14 animals animals 1.582911e+18
159+
#> id title title_str `_version_`
160+
#> <chr> <chr> <chr> <dbl>
161+
#> 1 10 adfadsf adfadsf 1.62e18
162+
#> 2 12 though though 1.62e18
163+
#> 3 14 animals animals 1.62e18
164164
```
165165

166166
### By query
@@ -178,7 +178,7 @@ conn$add(docs, "gettingstarted")
178178
#> [1] 0
179179
#>
180180
#> $responseHeader$QTime
181-
#> [1] 620
181+
#> [1] 33
182182
```
183183

184184
And the documents are now in your Solr database
@@ -190,13 +190,13 @@ conn$search("gettingstarted", params = list(q = "*:*", rows = 5))
190190

191191
```
192192
#> # A tibble: 5 x 7
193-
#> id title title_str `_version_` price name name_str
194-
#> <chr> <chr> <chr> <dbl> <int> <chr> <chr>
195-
#> 1 10 adfadsf adfadsf 1.582911e+18 NA <NA> <NA>
196-
#> 2 12 though though 1.582911e+18 NA <NA> <NA>
197-
#> 3 14 animals animals 1.582911e+18 NA <NA> <NA>
198-
#> 4 1 <NA> <NA> 1.582912e+18 100 brown brown
199-
#> 5 2 <NA> <NA> 1.582912e+18 500 blue blue
193+
#> id title title_str `_version_` price name name_str
194+
#> <chr> <chr> <chr> <dbl> <int> <chr> <chr>
195+
#> 1 10 adfadsf adfadsf 1.62e18 NA <NA> <NA>
196+
#> 2 12 though though 1.62e18 NA <NA> <NA>
197+
#> 3 14 animals animals 1.62e18 NA <NA> <NA>
198+
#> 4 1 <NA> <NA> 1.62e18 100 brown brown
199+
#> 5 2 <NA> <NA> 1.62e18 500 blue blue
200200
```
201201

202202
Now delete those documents just added
@@ -212,7 +212,7 @@ conn$delete_by_query(query = "(name:blue OR name:pink)", "gettingstarted")
212212
#> [1] 0
213213
#>
214214
#> $responseHeader$QTime
215-
#> [1] 45
215+
#> [1] 26
216216
```
217217

218218
And now they are gone
@@ -224,12 +224,12 @@ conn$search("gettingstarted", params = list(q = "*:*", rows = 5))
224224

225225
```
226226
#> # A tibble: 4 x 7
227-
#> id title title_str `_version_` price name name_str
228-
#> <chr> <chr> <chr> <dbl> <int> <chr> <chr>
229-
#> 1 10 adfadsf adfadsf 1.582911e+18 NA <NA> <NA>
230-
#> 2 12 though though 1.582911e+18 NA <NA> <NA>
231-
#> 3 14 animals animals 1.582911e+18 NA <NA> <NA>
232-
#> 4 1 <NA> <NA> 1.582912e+18 100 brown brown
227+
#> id title title_str `_version_` price name name_str
228+
#> <chr> <chr> <chr> <dbl> <int> <chr> <chr>
229+
#> 1 10 adfadsf adfadsf 1.62e18 NA <NA> <NA>
230+
#> 2 12 though though 1.62e18 NA <NA> <NA>
231+
#> 3 14 animals animals 1.62e18 NA <NA> <NA>
232+
#> 4 1 <NA> <NA> 1.62e18 100 brown brown
233233
```
234234

235235
## Update documents from files
@@ -256,7 +256,7 @@ conn$update_json(file, "books")
256256
#> [1] 0
257257
#>
258258
#> $responseHeader$QTime
259-
#> [1] 58
259+
#> [1] 59
260260
```
261261

262262
### Add and delete in the same file
@@ -275,7 +275,7 @@ conn$add(ss, "books")
275275
#> [1] 0
276276
#>
277277
#> $responseHeader$QTime
278-
#> [1] 49
278+
#> [1] 57
279279
```
280280

281281
Now add a new document, and delete the one we just made
@@ -298,7 +298,6 @@ cat(readLines(file), sep = "\n")
298298
#> <field name="sequence_i">1</field>
299299
#> <field name="genre_s">fantasy</field>
300300
#> <field name="inStock">TRUE</field>
301-
#> <field name="price">12.5</field>
302301
#> <field name="pages_i">384</field>
303302
#> </doc>
304303
#> </add>
@@ -318,7 +317,7 @@ conn$update_xml(file, "books")
318317
#> [1] 0
319318
#>
320319
#> $responseHeader$QTime
321-
#> [1] 32
320+
#> [1] 30
322321
```
323322

324323
### Notes

inst/stuff/local_setup.md

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@
77
Local Solr setup
88
======
99

10+
The Solr version you are working with my differ from below. Don't worry, just go with the version you want to use.
11+
1012
### OSX
1113

12-
__Based on http://lucene.apache.org/solr/quickstart.html__
14+
__Based on http://lucene.apache.org/solr/guide/7_0/solr-tutorial.html__
1315

14-
1. Download most recent version from an Apache mirror http://www.apache.org/dyn/closer.cgi/lucene/solr/5.4.1
15-
2. Unzip/untar the file. Move to your desired location. Now you have Solr `v.5.4.1`
16-
3. Go into the directory you just created: `cd solr-5.4.1`
16+
1. Download most recent version from an Apache mirror https://lucene.apache.org/solr/
17+
2. Unzip/untar the file. Move to your desired location. Now you have Solr `v.7.0.0`
18+
3. Go into the directory you just created: `cd solr-7.0.0`
1719
4. Launch Solr: `bin/solr start -e cloud -noprompt` - Sets up SolrCloud mode, rather
1820
than Standalone mode. As far as I can tell, SolrCloud mode seems more common.
1921
5. Once Step 4 completes, you can go to `http://localhost:8983/solr/` now, which is
@@ -37,13 +39,28 @@ You should be able to use the above instructions for OSX on a Windows machine, b
3739

3840
### `solrium` usage
3941

40-
And we can now use the `solrium` R package to query the Solr database to get raw JSON data:
42+
First, setup a connection object
4143

4244

4345
```r
44-
solr_connect('http://localhost:8983')
45-
solr_search("gettingstarted", q = '*:*', raw = TRUE, rows = 3)
46+
(conn <- SolrClient$new())
47+
```
48+
49+
```
50+
## <Solr Client>
51+
## host: 127.0.0.1
52+
## path:
53+
## port: 8983
54+
## scheme: http
55+
## errors: simple
56+
## proxy:
57+
```
4658

59+
And we can now use the `solrium` R package to query the Solr database to get raw JSON data:
60+
61+
62+
```r
63+
conn$search("gettingstarted", params = list(q = '*:*', rows = 3), raw = TRUE)
4764
#> [1] "{\"responseHeader\":{\"status\":0,\"QTime\":8,\"params\":{\"q\":\"*:*\",\"rows\":\"3\",\"wt\":\"json\"}},\"response\":{\"numFound\":3577,\"start\":0,\"maxScore\":1.0,\"docs\":[{\"id\":\"/Users/sacmac/solr-5.2.1/docs/solr-core/org/apache/solr/highlight/class-use/SolrFragmenter.html\",\"stream_size\":[9016],\"date\":[\"2015-06-10T00:00:00Z\"],\"x_parsed_by\":[\"org.apache.tika.parser.DefaultParser\",\"org.apache.tika.parser.html.HtmlParser\"],\"stream_content_type\":[\"text/html\"],\"dc_title\":[\"Uses of Interface org.apache.solr.highlight.SolrFragmenter (Solr 5.2.1 API)\"],\"content_encoding\":[\"UTF-8\"],\"resourcename\":[\"/Users/sacmac/solr-5.2.1/docs/solr-core/org/apache/solr/highlight/class-use/SolrFragmenter.html\"],\"title\":[\"Uses of Interface org.apache.solr.highlight.SolrFragmenter (Solr 5.2.1 API)\"],\"content_type\":[\"text/html\"],\"_version_\":1507965023127863296},{\"id\":\"/Users/sacmac/solr-5.2.1/docs/solr-core/org/apache/solr/highlight/class-use/SolrFragmentsBuilder.html\",\"stream_size\":[10336],\"date\":[\"2015-06-10T00:00:00Z\"],\"x_parsed_by\":[\"org.apache.tika.parser.DefaultParser\",\"org.apache.tika.parser.html.HtmlParser\"],\"stream_content_type\":[\"text/html\"],\"dc_title\":[\"Uses of Class org.apache.solr.highlight.SolrFragmentsBuilder (Solr 5.2.1 API)\"],\"content_encoding\":[\"UTF-8\"],\"resourcename\":[\"/Users/sacmac/solr-5.2.1/docs/solr-core/org/apache/solr/highlight/class-use/SolrFragmentsBuilder.html\"],\"title\":[\"Uses of Class org.apache.solr.highlight.SolrFragmentsBuilder (Solr 5.2.1 API)\"],\"content_type\":[\"text/html\"],\"_version_\":1507965023153029120},{\"id\":\"/Users/sacmac/solr-5.2.1/docs/solr-core/org/apache/solr/internal/csv/CSVParser.html\",\"stream_size\":[32427],\"date\":[\"2015-06-10T00:00:00Z\"],\"x_parsed_by\":[\"org.apache.tika.parser.DefaultParser\",\"org.apache.tika.parser.html.HtmlParser\"],\"stream_content_type\":[\"text/html\"],\"dc_title\":[\"CSVParser (Solr 5.2.1 API)\"],\"content_encoding\":[\"UTF-8\"],\"resourcename\":[\"/Users/sacmac/solr-5.2.1/docs/solr-core/org/apache/solr/internal/csv/CSVParser.html\"],\"title\":[\"CSVParser (Solr 5.2.1 API)\"],\"content_type\":[\"text/html\"],\"_version_\":1507965023221186560}]}}\n"
4865
#> attr(,"class")
4966
#> [1] "sr_search"
@@ -55,8 +72,7 @@ Or parsed data to a data.frame (just looking at a few columns for brevity):
5572

5673

5774
```r
58-
solr_search("gettingstarted", q = '*:*', fl = c('date', 'title'))
59-
75+
conn$search("gettingstarted", params = list(q = '*:*', fl = c('date', 'title')))
6076
#> Source: local data frame [10 x 2]
6177
#>
6278
#> date title
@@ -72,6 +88,8 @@ solr_search("gettingstarted", q = '*:*', fl = c('date', 'title'))
7288
#> 10 2015-06-10T00:00:00Z CSVConfigGuesser (Solr 5.2.1 API)
7389
```
7490

91+
## Other Vignettes
92+
7593
See the other vignettes for more thorough examples:
7694

7795
* `Document management`

0 commit comments

Comments
 (0)