Use Solr APIs

In addition to being able to use Managed Search APIs for managing clusters and collections, you can use Solr APIs for operations such as indexing documents and searching, with a few exceptions.

What is different

If you have used REST APIs to access Solr outside of Lucidworks Managed Search, you might wonder what differs regarding accessing Solr in Lucidworks Managed Search. This table summarizes all of the differences.

Aspect In Managed Search In Solr

Authentication

Authentication relies on the client app having an OAuth2 access token for Solr in Managed Search. This access token is distinct from the OAuth2 access token for Managed Search operations.

Various authentication methods are available via authentication plug-ins.

Authorization

The OAuth2 Client ID gives an application specific access to Solr APIs.

Authorization relies on authorization plugins.

Solr API endpoints

Endpoints for Solr operations such as searching begin with the URI root path https://cloud.lucidworks.com/customer/cluster/solr.

Endpoints for Solr operations such as searching begin with the URI root path https://solrhost:8983/solr.

Operations interface

For cluster management, Managed Search provides a limited set of APIs, and the Cluster Manager web app.

Administration is via the Solr Administration User Interface.

Excluded Solr APIs

To ensure ease of management and stability of Managed Search clusters, some Solr APIs are excluded.

How to use Solr APIs

Use Solr APIs in accordance with the Solr Reference Guide, considering the link#what-si-different[differences for Solr in Managed Search] and the excluded Solr APIs.

1.1. Get an OAuth2 access token for Solr APIs

Get an OAuth2 access token for Solr APIs. You do this in the same way as you do for an OAuth2 access token for Managed Search APIs, but specify a different scope.

1.2. Develop a client app

You need some means of submitting API requests to Solr. You can develop a client app or use an existing app:

Note
The client app that we use in our examples is curl, a command line tool that can send HTTP requests and receive responses (as well as other things).

1.3. Submit requests

Use Solr HTTP REST APIs to submit Solr requests.

  • Include the OAuth2 access token for Solr APIs in the Authorize header.

  • Specify the Solr API endpoints for Managed Search.

1.4. Use information from the responses

What you do with the information you get back from API requests is up to you.

Examples

Post a single document to a collection

curl -XPOST "https://cloud.lucidworks.com/lucidworks/jeff-1/solr/test-collection/update/json/docs?commit=true" -H "Authorization: Bearer accessTokenSolr" -H "Content-type: application/json" -d '{"id":"1", "field1": "value1"}'

Post multiple documents to a collection

curl -XPOST "https://cloud.lucidworks.com/lucidworks/jeff-1/solr/test-collection/update/json/docs?commit=true" -H "Authorization: Bearer {solr-access_token}" -H "Content-type: application/json" -d '[{"id":"1", "field1": "value1"},{"id":"2", "field1": "value2"},{"id":"3", "field1": "value3"}]'

Modify a document

curl -XPOST "https://cloud.lucidworks.com/lucidworks/jeff-1/solr/test-collection/update/json/docs?commit=true" -H "Authorization: Bearer accessTokenSolr" -H "Content-type: application/json" -d '{"id":"1", "field1": "value7"}'

Search for documents

curl -XGET "https://cloud.lucidworks.com/lucidworks/jeff-1/solr/test-collection/select?q=*:*" -H "Authorization: Bearer accessTokenSolr"