search script
This commit is contained in:
@@ -48,14 +48,29 @@ class SearchObject:
|
||||
self.raw= res.get("_source",{}).get("raw","")
|
||||
self.highlight=res.get("highlight",{}).get("title",[""]) + res.get("highlight",{}).get("text",[""])
|
||||
|
||||
|
||||
|
||||
def es_sorting():
|
||||
return {
|
||||
"_script": {
|
||||
"type": "number",
|
||||
"script": {
|
||||
"lang": "painless",
|
||||
"source": "Math.log10(1+doc['updated_at'].value.toInstant().toEpochMilli()/1000000000/100) + Math.log10(1+_score)/10 + Math.log10(1+doc['prio'].value/1000) ", # * Math.log10(1+) * Math.log10(doc['prio'].value/10)" #* doc['_score'].value
|
||||
},
|
||||
"order": "desc",
|
||||
}
|
||||
}
|
||||
|
||||
def es_search(query:str):
|
||||
logging.debug(f"Run Search for legacy :%s" % query)
|
||||
with es_client() as client:
|
||||
result = client.search(
|
||||
index=ELASTIC_INDEX,
|
||||
size=10,
|
||||
size=20,
|
||||
query=es_query(query),
|
||||
highlight = es_highlight()
|
||||
sort=es_sorting(),
|
||||
highlight=es_highlight(),
|
||||
)
|
||||
logging.debug(result.keys())
|
||||
return [SearchObject(r) for r in result["hits"]["hits"]]
|
||||
|
||||
Reference in New Issue
Block a user