Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

SOLR-16125 Make tutorial commands copyable (#774)

Mike Drobca0f6c09e09f
diff --git a/solr/solr-ref-guide/modules/getting-started/pages/solr-tutorial.adoc b/solr/solr-ref-guide/modules/getting-started/pages/solr-tutorial.adoc
index 31fce6a8c4c..062faa39518 100644
--- a/solr/solr-ref-guide/modules/getting-started/pages/solr-tutorial.adoc
+++ b/solr/solr-ref-guide/modules/getting-started/pages/solr-tutorial.adoc
@@ -84,7 +84,10 @@ Nice work!
As you work through this tutorial, you may want to stop Solr and reset the environment back to the starting point.
The following command line will stop Solr and remove the directories for each of the two nodes that were created all the way back in Exercise 1:
-`bin/solr stop -all ; rm -Rf example/cloud/`
+[source,bash]
+----
+bin/solr stop -all ; rm -Rf example/cloud/
+----
== Where to next?
diff --git a/solr/solr-ref-guide/modules/getting-started/pages/tutorial-diy.adoc b/solr/solr-ref-guide/modules/getting-started/pages/tutorial-diy.adoc
index 9c9ea1102bd..1283240dfd5 100644
--- a/solr/solr-ref-guide/modules/getting-started/pages/tutorial-diy.adoc
+++ b/solr/solr-ref-guide/modules/getting-started/pages/tutorial-diy.adoc
@@ -35,7 +35,10 @@ This exercise is intended to get you thinking about what you will need to do for
Before you get started, create a new collection, named whatever you'd like.
In this example, the collection will be named "localDocs"; replace that name with whatever name you choose if you want to.
-`./bin/solr create -c localDocs -s 2 -rf 2`
+[source,bash]
+----
+./bin/solr create -c localDocs -s 2 -rf 2
+----
Again, as we saw from Exercise 2 above, this will use the `_default` configset and all the schemaless features it provides.
As we noted previously, this may cause problems when we index our data.
@@ -55,7 +58,10 @@ We used only JSON, XML and CSV in our exercises, but the Post Tool can also hand
In this example, assume there is a directory named "Documents" locally.
To index it, we would issue a command like this (correcting the collection name after the `-c` parameter as needed):
+
-`./bin/post -c localDocs ~/Documents`
+[source,bash]
+----
+./bin/post -c localDocs ~/Documents
+----
+
You may get errors as it works through your documents.
These might be caused by the field guessing, or the file type may not be supported.
@@ -95,11 +101,17 @@ We can use `bin/post` to delete documents also if we structure the request prope
Execute the following command to delete a specific document:
-`bin/post -c localDocs -d "<delete><id>SP2514N</id></delete>"`
+[source,bash]
+----
+bin/post -c localDocs -d "<delete><id>SP2514N</id></delete>"
+----
To delete all documents, you can use "delete-by-query" command like:
-`bin/post -c localDocs -d "<delete><query>*:*</query></delete>"`
+[source,bash]
+----
+bin/post -c localDocs -d "<delete><query>*:*</query></delete>"
+----
You can also modify the above to only delete documents that match a specific query.
diff --git a/solr/solr-ref-guide/modules/getting-started/pages/tutorial-films.adoc b/solr/solr-ref-guide/modules/getting-started/pages/tutorial-films.adoc
index e53956472b6..384cf3c521e 100644
--- a/solr/solr-ref-guide/modules/getting-started/pages/tutorial-films.adoc
+++ b/solr/solr-ref-guide/modules/getting-started/pages/tutorial-films.adoc
@@ -29,12 +29,18 @@ Then go ahead to the next section.
If you did, though, and need to restart Solr, issue these commands:
-`./bin/solr start -c -p 8983 -s example/cloud/node1/solr`
+[source,bash]
+----
+./bin/solr start -c -p 8983 -s example/cloud/node1/solr
+----
This starts the first node.
When it's done start the second node, and tell it how to connect to ZooKeeper:
-`./bin/solr start -c -p 7574 -s example/cloud/node2/solr -z localhost:9983`
+[source,bash]
+----
+./bin/solr start -c -p 7574 -s example/cloud/node2/solr -z localhost:9983
+----
NOTE: If you have defined `ZK_HOST` in `solr.in.sh`/`solr.in.cmd` (see xref:deployment-guide:zookeeper-ensemble#updating-solr-include-files[Updating Solr Include Files]) you can omit `-z <zk host string>` from the above command.
@@ -66,7 +72,10 @@ This time, we're going to use a configset that has a very minimal schema and let
The data you're going to index is related to movies, so start by creating a collection named "films" that uses the `_default` configset:
-`bin/solr create -c films -s 2 -rf 2`
+[source,bash]
+----
+bin/solr create -c films -s 2 -rf 2
+----
Whoa, wait.
We didn't specify a configset!
@@ -321,7 +330,10 @@ Or, perhaps you do want all the facets, and you'll let your application's front-
If you wanted to control the number of items in a bucket, you could do something like this:
-`curl "http://localhost:8983/solr/films/select?=&q=\*:*&facet.field=genre_str&facet.mincount=200&facet=on&rows=0"`
+[source,bash]
+----
+curl "http://localhost:8983/solr/films/select?=&q=\*:*&facet.field=genre_str&facet.mincount=200&facet=on&rows=0"
+----
You should only see 4 facets returned.
@@ -340,13 +352,13 @@ If we construct a query that looks like this:
[source,bash]
curl 'http://localhost:8983/solr/films/select?q=*:*&rows=0'\
- '&facet=true'\
- '&facet.range=initial_release_date'\
- '&facet.range.start=NOW-20YEAR'\
- '&facet.range.end=NOW'\
- '&facet.range.gap=%2B1YEAR'
+'&facet=true'\
+'&facet.range=initial_release_date'\
+'&facet.range.start=NOW/YEAR-25YEAR'\
+'&facet.range.end=NOW'\
+'&facet.range.gap=%2B1YEAR'
-This will request all films and ask for them to be grouped by year starting with 20 years ago (our earliest release date is in 2000) and ending today.
+This will request all films and ask for them to be grouped by year starting with 25 years ago (our earliest release date is in 2000) and ending today.
Note that this query again URL encodes a `+` as `%2B`.
In the terminal you will see:
@@ -364,7 +376,7 @@ In the terminal you will see:
"facet.range.gap":"+1YEAR",
"rows":"0",
"facet":"on",
- "facet.range.start":"NOW-20YEAR",
+ "facet.range.start":"NOW-25YEAR",
"facet.range.end":"NOW"}},
"response":{"numFound":1100,"start":0,"maxScore":1.0,"docs":[]
},
@@ -374,29 +386,29 @@ In the terminal you will see:
"facet_ranges":{
"initial_release_date":{
"counts":[
- "1997-07-28T17:12:06.919Z",0,
- "1998-07-28T17:12:06.919Z",0,
- "1999-07-28T17:12:06.919Z",48,
- "2000-07-28T17:12:06.919Z",82,
- "2001-07-28T17:12:06.919Z",103,
- "2002-07-28T17:12:06.919Z",131,
- "2003-07-28T17:12:06.919Z",137,
- "2004-07-28T17:12:06.919Z",163,
- "2005-07-28T17:12:06.919Z",189,
- "2006-07-28T17:12:06.919Z",92,
- "2007-07-28T17:12:06.919Z",26,
- "2008-07-28T17:12:06.919Z",7,
- "2009-07-28T17:12:06.919Z",3,
- "2010-07-28T17:12:06.919Z",0,
- "2011-07-28T17:12:06.919Z",0,
- "2012-07-28T17:12:06.919Z",1,
- "2013-07-28T17:12:06.919Z",1,
- "2014-07-28T17:12:06.919Z",1,
- "2015-07-28T17:12:06.919Z",0,
- "2016-07-28T17:12:06.919Z",0],
+ "1997-01-01T00:00:00Z",0,
+ "1998-01-01T00:00:00Z",0,
+ "1999-01-01T00:00:00Z",0,
+ "2000-01-01T00:00:00Z",80,
+ "2001-01-01T00:00:00Z",94,
+ "2002-01-01T00:00:00Z",112,
+ "2003-01-01T00:00:00Z",125,
+ "2004-01-01T00:00:00Z",166,
+ "2005-01-01T00:00:00Z",167,
+ "2006-01-01T00:00:00Z",173,
+ "2007-01-01T00:00:00Z",45,
+ "2008-01-01T00:00:00Z",13,
+ "2009-01-01T00:00:00Z",5,
+ "2010-01-01T00:00:00Z",1,
+ "2011-01-01T00:00:00Z",0,
+ "2012-01-01T00:00:00Z",0,
+ "2013-01-01T00:00:00Z",2,
+ "2014-01-01T00:00:00Z",0,
+ "2015-01-01T00:00:00Z",1,
+ "2016-01-01T00:00:00Z",0],
"gap":"+1YEAR",
- "start":"1997-07-28T17:12:06.919Z",
- "end":"2017-07-28T17:12:06.919Z"}},
+ "start":"1997-01-01T00:00:00Z",
+ "end":"2017-01-01T00:00:00Z"}},
"facet_intervals":{},
"facet_heatmaps":{}}}
@@ -406,7 +418,10 @@ Another faceting type is pivot facets, also known as "decision trees", allowing
Using the films data, pivot facets can be used to see how many of the films in the "Drama" category (the `genre_str` field) are directed by a director.
Here's how to get at the raw data for this scenario:
-`curl "http://localhost:8983/solr/films/select?q=\*:*&rows=0&facet=on&facet.pivot=genre_str,directed_by_str"`
+[source,bash]
+----
+curl "http://localhost:8983/solr/films/select?q=\*:*&rows=0&facet=on&facet.pivot=genre_str,directed_by_str"
+----
This results in the following response, which shows a facet for each category and director combination:
@@ -459,4 +474,7 @@ Like our previous exercise, this data may not be relevant to your needs.
We can clean up our work by deleting the collection.
To do that, issue this command at the command line:
-`bin/solr delete -c films`
+[source,bash]
+----
+bin/solr delete -c films
+----
diff --git a/solr/solr-ref-guide/modules/getting-started/pages/tutorial-techproducts.adoc b/solr/solr-ref-guide/modules/getting-started/pages/tutorial-techproducts.adoc
index c2bfbb4f88a..ed2a4273cd9 100644
--- a/solr/solr-ref-guide/modules/getting-started/pages/tutorial-techproducts.adoc
+++ b/solr/solr-ref-guide/modules/getting-started/pages/tutorial-techproducts.adoc
@@ -260,7 +260,10 @@ If you click on it, your browser will show you the raw response.
To use curl, give the same URL shown in your browser in quotes on the command line:
-`curl "http://localhost:8983/solr/techproducts/select?indent=on&q=\*:*"`
+[source,bash]
+----
+curl "http://localhost:8983/solr/techproducts/select?indent=on&q=\*:*"
+----
What's happening here is that we are using Solr's query parameter (`q`) with a special syntax that requests all documents in the index (`\*:*`).
All of the documents are not returned to us, however, because of the default for a parameter called `rows`, which you can see in the form is `10`.
@@ -277,7 +280,10 @@ Enter "foundation" and hit btn:[Execute Query] again.
If you prefer curl, enter something like this:
-`curl "http://localhost:8983/solr/techproducts/select?q=foundation"`
+[source,bash]
+----
+curl "http://localhost:8983/solr/techproducts/select?q=foundation"
+----
You'll see something like this:
@@ -321,7 +327,10 @@ This is one of the available fields on the query form in the Admin UI.
Put "id" (without quotes) in the "fl" box and hit btn:[Execute Query] agai
Or, to specify it with curl:
-`curl "http://localhost:8983/solr/techproducts/select?q=foundation&fl=id"`
+[source,bash]
+----
+curl "http://localhost:8983/solr/techproducts/select?q=foundation&fl=id"
+----
You should only see the IDs of the matching records returned.
@@ -414,7 +423,10 @@ For example, search for "CAS latency" by entering that phrase in quotes to the `
If you're following along with curl, note that the space between terms must be converted to "+" in a URL, as so:
-`curl "http://localhost:8983/solr/techproducts/select?q=\"CAS+latency\""`
+[source,bash]
+----
+curl "http://localhost:8983/solr/techproducts/select?q=\"CAS+latency\""
+----
We get 2 results:
@@ -472,14 +484,20 @@ To find documents that contain both terms "electronics" and "music", enter `+ele
If you're using curl, you must encode the `+` character because it has a reserved purpose in URLs (encoding the space character).
The encoding for `+` is `%2B` as in:
-`curl "http://localhost:8983/solr/techproducts/select?q=%2Belectronics%20%2Bmusic"`
+[source,bash]
+----
+curl "http://localhost:8983/solr/techproducts/select?q=%2Belectronics%20%2Bmusic"
+----
You should only get a single result.
To search for documents that contain the term "electronics" but *don't* contain the term "music", enter `+electronics -music` in the `q` box in the Admin UI.
For curl, again, URL encode `+` as `%2B` as in:
-`curl "http://localhost:8983/solr/techproducts/select?q=%2Belectronics+-music"`
+[source,bash]
+----
+curl "http://localhost:8983/solr/techproducts/select?q=%2Belectronics+-music"
+----
This time you get 13 results.
@@ -496,14 +514,23 @@ You can choose now to continue to the next example which will introduce more Sol
If you decide not to continue with this tutorial, the data we've indexed so far is likely of little value to you.
You can delete your installation and start over, or you can use the `bin/solr` script we started out with to delete this collection:
-`bin/solr delete -c techproducts`
+[source,bash]
+----
+bin/solr delete -c techproducts
+----
And then create a new collection:
-`bin/solr create -c <yourCollection> -s 2 -rf 2`
+[source,bash]
+----
+bin/solr create -c <yourCollection> -s 2 -rf 2
+----
To stop both of the Solr nodes we started, issue the command:
-`bin/solr stop -all`
+[source,bash]
+----
+bin/solr stop -all
+----
For more information on start/stop and collection options with `bin/solr`, see xref:deployment-guide:solr-control-script-reference.adoc[].