Skip to content

Commit

Permalink
Polish up the docs a bit to show the features.
Browse files Browse the repository at this point in the history
  • Loading branch information
epugh committed Nov 19, 2024
1 parent b0837e6 commit 479fdfe
Showing 1 changed file with 35 additions and 9 deletions.
44 changes: 35 additions & 9 deletions solr/solr-ref-guide/modules/query-guide/pages/stream-tool.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@ To run it, open a terminal and enter:

[,console]
----
$ bin/solr stream --header -c techproducts --delimiter=\| 'search(techproducts,q="name:memory",fl="name,price")'
$ bin/solr stream -c techproducts --header --fields price,name --delimiter=\| 'search(techproducts,q="iPod",fl="name,price")'
----

This will run the provided streaming expression on the `techproducts` collection on your local Solr and produce:

[,console]
----
name|price
CORSAIR XMS 2GB (2 x 1GB) 184-Pin DDR SDRAM Unbuffered DDR 400 (PC 3200) Dual Channel Kit System Memory - Retail|185.0
CORSAIR ValueSelect 1GB 184-Pin DDR SDRAM Unbuffered DDR 400 (PC 3200) System Memory - Retail|74.99
A-DATA V-Series 1GB 184-Pin DDR SDRAM Unbuffered DDR 400 (PC 3200) System Memory - OEM|
price|name
11.5|iPod & iPod Mini USB 2.0 Cable
19.95|Belkin Mobile Power Cord for iPod w/ Dock
399.0|Apple 60 GB iPod with Video Playback Black
----

TIP: Notice how we used the pipe character (|) as the delimiter? It required a backslash for escaping it so it wouldn't be treated as a pipe within the shell script.
Expand All @@ -50,19 +50,28 @@ Assuming you have create the file `stream.expr` with the contents:
----
# Stream a search
/*
You can have
multi-line comments as well.
*/
search(
techproducts,
q="name:memory",
fl="name,price",
sort="price desc"
sort="price $1"
)
// the end
----

Notice the various ways to format comments in the file?

Then you can run it on the Solr collection `techproducts`, specifying you want a header row:

[,console]
----
$ bin/solr stream --header -c techproducts stream.expr
$ bin/solr stream --header -c techproducts stream.expr desc
----

And this will produce:
Expand All @@ -83,7 +92,7 @@ The `--help` (or simply `-h`) option will output information on its usage (i.e.,

[source,plain]
----
usage: bin/solr stream [--array-delimiter <CHARACTER>] [-c <NAME>] [--delimiter <CHARACTER>] [-e <ENVIRONMENT>] [-f
usage: bin/solr stream [--array-delimiter <CHARACTER>] [-c <NAME>] [--delimiter <CHARACTER>] [--execution <ENVIRONMENT>] [--fields
<FIELDS>] [-h] [--header] [-s <HOST>] [-u <credentials>] [-v] [-z <HOST>]
List of options:
Expand Down Expand Up @@ -173,4 +182,21 @@ $ bin/solr stream -c techproducts 'echo("$1")' "Hello World"
Hello World
----

This also works when using `.expr` files.
This also works when using `.expr` files. You can nest as many variables you want.
Here is an example of passing in both the file and the number of lines to process:

----
# Index CSV File
update(
gettingstarted,
parseCSV(
cat($1, maxLines=$2)
)
)
----

[,console]
----
$ bin/solr stream -c techproducts file.expr ./example/exampledocs/books.csv 10
----

0 comments on commit 479fdfe

Please sign in to comment.