REST Messages Sent in URLs Through Browsers
The Apache Solr official website provides introduction to SolrCloud and related APIs at https://solr.apache.org/guide/8_11/.
To send messages through the URL of a browser, the client must be able to ping the server. If the system is in security mode, all requests must be HTTPS requests. If the system is in normal mode, all requests can be HTTPS or HTTP requests. The following uses HTTPS messages as an example:
Before sending URLs, ensure that the local host can ping the server.
- Creating a collection
https://solrIp:solrPort/solr/admin/collections?action=CREATE&name=test1&collection.configName=confWithSchema&numShards=3&replicationFactor=1
Parameter description:
- action: indicates the operation type.
- name: indicates the name of the collection to be created.
- collection.configName: indicates the config set used during collection creation.
- numShards: indicates the number of shards of the created collection.
- replicationFactor: indicates the replication factor of each shard.
Figure 1 Creating a collection
Specify solrIp and solrPort based on actual application scenarios.
There are two routing modes for creating a collection: ImplicitDocRouter and CompositeIdRouter. When a URL is used to create a collection and the numshards parameter is specified, CompositeIdRouter is used by default. When this mode is used, no shard can be added to the collection, and shards can be obtained only by splitting.
- Adding a document
https://solrIp:solrPort/solr/test1/update?stream.body=<add><doc boost="1.0"><field name="id">2</field><field name="name">Zhang San</field></doc></add>
&stream.contentType=text/xml;charset=utf-8&commit=true
Parameter description:
- test1: indicates the collection name.
- stream.body: indicates index data to be added.
- add: used to add a document.
- stream.contentType: indicates the format of the data to be added.
- commit: specifies whether to submit immediately.
- Querying collections
https://solrIp:solrPort/solr/test1/select?q=*&wt=json&indent=true
Parameter description:
- test1: indicates the collection name.
- q: indicates the content to be queried.
- wt: indicate the format of the return results.
- indent: indicates whether the return results are indented.
- Deleting a document
https://solrIp:solrPort/solr/test1/update?stream.body=<delete><query>*:*</query></delete>&stream.contentType=text/xml;charset=utf-8&commit=true
Parameter description:
- For detailed descriptions about test1, stream.body, stream.contentType, and commit, refer to the descriptions in the step of adding a document.
- delete: indicates the document to be deleted.
- query: indicates the document to be queried. *:* indicates that all the documents are queried.
- Deleting a collection
https://solrIp:solrPort/solr/admin/collections?action=DELETE&name=test1
Parameter description:
- action: indicates the operation type.
- name: indicates the name of the collection to be deleted.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot