This is the code I am trying to implement:-
import requests
import tornado.ioloop
import tornado.web
import tornado.autoreload
import json
class MainHandler(tornado.web.RequestHandler):
def get(self):
payload = [{"id" : "978-0641723445", "cat" : ["book","hardcover"], "name" : "The Lightning Thief", "author" : "Rick Riordan","series_t" : "Percy Jackson Olympians", "sequence_i" : 1, "genre_s" : "fantasy", "inStock" : True, "price" : 12.50, "pages_i" : 384}]
url = 'http://localhost:8983/solr/update/json'
headers = {'content-type' : 'application/json'}
# files = {'file': ('books.json', open('books.json', 'rb'))}
timeline = requests.post(url, data = json.dumps(payload), headers = headers)
self.write(timeline.text)
class QueryHandler(tornado.web.RequestHandler):
def get(self):
# timeline = requests.get('http://localhost:8983/solr/collection1/select?q=a&wt=json&indent=true')
payload = {'q' : 'a', 'wt' : 'json', 'indent' : True}
timeline = requests.get('http://localhost:8983/solr/collection1/select', params = payload)
self.write(timeline.json())
application = tornado.web.Application([
(r"/", MainHandler),
(r"/query", QueryHandler)
])
if __name__ == "__main__":
application.listen(8888)
io_loop = tornado.ioloop.IOLoop.instance()
tornado.autoreload.start(io_loop)
io_loop.start()
I am able to query the solr server on localhost:8888/query but on localhost:8888 where I am trying to post the data, I get this response from solr:-
{
responseHeader: {
status: 0,
QTime: 46
}
}
Data is not getting posted to the solr server.
Any suggestions ??