Finish reimplementing Elasticsearch
This commit is contained in:
@@ -77,7 +77,8 @@ class DruidBackend(StorageBackend):
|
||||
self.add_type("or", search_query, extra_should2)
|
||||
return search_query
|
||||
|
||||
def construct_query(self, query, size, index, blank=False):
|
||||
def construct_query(self, query, size, blank=False, **kwargs):
|
||||
index = kwargs.get("index")
|
||||
search_query = {
|
||||
"limit": size,
|
||||
"queryType": "scan",
|
||||
@@ -107,19 +108,13 @@ class DruidBackend(StorageBackend):
|
||||
|
||||
def parse(self, response):
|
||||
parsed = parse_druid(response)
|
||||
print("PARSE LEN", len(parsed))
|
||||
return parsed
|
||||
|
||||
def run_query(self, user, search_query):
|
||||
ss = orjson.dumps(search_query, option=orjson.OPT_INDENT_2)
|
||||
ss = ss.decode()
|
||||
print(ss)
|
||||
response = requests.post("http://druid:8082/druid/v2", json=search_query)
|
||||
response = orjson.loads(response.text)
|
||||
print("RESPONSE LEN", len(response))
|
||||
# ss = orjson.dumps(response, option=orjson.OPT_INDENT_2)
|
||||
# ss = ss.decode()
|
||||
# print(ss)
|
||||
return response
|
||||
|
||||
def filter_blacklisted(self, user, response):
|
||||
@@ -172,7 +167,7 @@ class DruidBackend(StorageBackend):
|
||||
|
||||
# Q/T - Query/Tags
|
||||
search_query = self.parse_query(
|
||||
query_params, tags, size, index, custom_query, add_bool
|
||||
query_params, tags, size, custom_query, add_bool, index=index
|
||||
)
|
||||
# Query should be a dict, so check if it contains message here
|
||||
if "message" in search_query:
|
||||
|
||||
Reference in New Issue
Block a user