$ solr start -c -p 8983 -s example/cloud/node1/solr
$ solr start -c -p 7574 -s example/cloud/node2/solr -z localhost:9983
$ solr start -e cloud
$ solr stop -all
A configSet
includes at a minimum:
- schema file (named either
managed-schema
orschema.xml
) solrconfig.xml
The schema can be defined either manually or through the Schema API. The latter is preferred, since it allows you to dynamically change the schema. Then solr writes the schema configuration file and we interact with it through the rest API as seen here.
$ curl http://localhost:8983/solr/<collection>/schema
$ curl http://localhost:8983/solr/<collection>/schema/fields
Or
$ curl http://localhost:8983/solr/<collection>/schema/fields/<field_name>
$ curl http://localhost:8983/solr/<collection>/schema/dynamicfields
Or
$ curl http://localhost:8983/solr/<collection>/schema/dynamicfields/<field_name>
$ curl http://localhost:8983/solr/<collection>/schema/copyfields
$ curl http://localhost:8983/solr/<collection>/schema/fieldtypes
Or
$ curl http://localhost:8983/solr/<collection>/schema/fieldtypes/<field_type_name>
$ curl -X POST -H 'Content-type:application/json' --data-binary '{"add-field": {"name":"name", "type":"text_general", "multiValued":false, "stored":true}}' http://localhost:8983/solr/<collection>/schema
A copy field can be set up to take all data from all fields and index it into a new field, which we can set up as the default to search against.
$ curl -X POST -H 'Content-type:application/json' --data-binary '{"add-copy-field" : {"source":"*","dest":"_text_"}}' http://localhost:8983/solr/<collection>/schema
$ solr create -c <collection_name> -s 2 -rf 2
$ solr delete -c <collection_name>
Via post
:
$ post -c <collection> -d "<delete><id>TEST1</id></delete>"
Via curl
:
$ curl http://localhost:8983/solr/<collection>/update?commit=true -H 'Content-type:application/json' -d '{"delete": {"id": "TEST1"}}'
Via post
:
$ post -c <collection> -d "<delete><query>*:*</query></delete>"
Via curl
:
$ curl http://localhost:8983/solr/<collection>/update?commit=true -H 'Content-type:application/json' -d '{"delete": {"query": "*:*"}}'
Via post
:
$ post -c techproducts $SOLR_HOME/example/exampledocs/*
Via curl
:
$ curl http://localhost:8983/solr/techproducts/update?commit=true -H 'Content-type: application/json' -d '[{"id": "TEST1", "cat": ["electronics"], "name": "Test Product 1"}]'
$ curl http://localhost:8983/solr/techproducts/update?commit=true -H 'Content-type: application/json' -d '[{"id": "TEST1", "cat": {"add-distinct": ["electronics", "toys"]}, "name": {"set": "Test Product 1 Foundation"}}]'
$ curl "http://localhost:8983/solr/<collection>/select?indent=on&q=*:*"
$ curl "http://localhost:8983/solr/techproducts/select?q=foundation"
$ curl "http://localhost:8983/solr/techproducts/select?q=cat:electronics"
$ curl "http://localhost:8983/solr/techproducts/select?q=\"CAS+latency\""
For documents containing both music
and electronics
, we would have to query with +music
and +electronics
and encode the +
to %2B
(since +
denotes a space in a URL):
$ curl "http://localhost:8983/solr/techproducts/select?q=%2Belectronics%20%2Bmusic"
Documents containing electronics
but not music
:
$ curl "http://localhost:8983/solr/techproducts/select?q=%2Belectronics+-music"
$ curl "http://localhost:8983/solr/films/select?q=*:*&rows=0&facet=true&facet.field=genre_str"
$ 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"
$ curl "http://localhost:8983/solr/films/select?q=*:*&rows=0&facet=on&facet.pivot=genre_str,directed_by_str"