I have a REST API built using Flask. It has GET and POST methods. The API returns a JSON response. I want SOLR to use the REST API’s URL to perform a search on this response based on the query and return relevant search results.
How can I achieve this? Does SOLR only take a JSON file as input, in which case I would need to write endpoint’s response to a JSON file, place it in the example folder and pass it into SOLR?
2
Answers
Thanks Amit! In the link you shared, it had curl commands. But I was trying to do this with Python. I found out a solution for this! Works like a charm. I have also embedded comments for further explanation.
You will have to invoke the REST API, get back the JSON response and add it to Solr Index. Then you can use Solr to search that data.
Please take a look at this documentation. It will help you indexing JSON documents.
https://lucene.apache.org/solr/guide/7_1/uploading-data-with-index-handlers.html#solr-style-json
This is partially correct understanding, however you do not have to place it in example folder. You need to post that JSON (or format JSON in the form required by Solr) as shown in the reference provided above.
Hope this helps.