Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
global vprint
vprint = lambda *args, **kwargs: None # noqa: E731
es_version = get_elasticsearch_version(args.host, args.port)
if es_version == "7":
es_class = Elasticsearch7
if args.doctype:
print(
"Can't specify document type (-d/--doctype) when using "
"Elasticsearch 7.X or greater.",
file=sys.stderr,
)
exit(1)
elif es_version == "6":
es_class = Elasticsearch6
if not args.doctype:
args.doctype = DOC_TYPE
else:
print(
"Elasticsearch version {} not supported.".format(es_version),
file=sys.stderr,
)
exit(1)
vprint("Elasticsearch major version:", es_version)
es = es_class(args.host, port=args.port)
vprint("Starting inelastic script...")
inv_index = get_inverted_index(
def search_chemicals(request, template_name="search/es_chemicals.html"):
"""
Returns both the raw elasticsearch results and the django objects
"""
q = request.GET.get("q", "")
es = Elasticsearch(
[
{
"host": settings.ELASTIC_HOST,
"port": settings.ELASTIC_PORT,
"use_ssl": False,
}
]
)
es_return = es.search(
index="factotum_chemicals",
body={
"aggs": {
"data_documents": {
"terms": {
"field": "data_document_id",
"order": {"score_sum": "desc"},