# khanindexer # # @website https://git.khaganat.net/neodarz/khanindexer # # @results JSON # @stable yes # @parse (general) url, title, content from urllib import urlencode import json # engine dependent config categories = ['general'] # TODO , 'images', 'music', 'videos', 'files' paging = False language_support = False number_of_results = 5 # do search-request def request(query, params): params['data'] = json.dumps({ "index": "nevrax", "query": { "match": { "_all": query } }, "highlight": { "fields": { "content": {}, "url": {}, "title": {} }, "pre_tags": "_", "post_tags": "_" } }) params['method'] = 'POST' params['url'] = 'http://127.0.0.1:8080/json/search' return params # get response from search-request def response(resp): results = [] datas = json.loads(resp.text) if not 'error' in datas: for el in datas['hits']['hits']: results.append({ 'title': el["_source"]["title"], 'content': el["highlight"]["content"][0], 'url': el["_source"]["url"] }) else: print("ERROR:Search server: "+str(datas['error'])) # return results return results