Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d8d65b1f authored by Israel Yago Pereira's avatar Israel Yago Pereira Committed by Arnau Vàzquez
Browse files

Highlight search results

parent b2fb14f0
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -69,7 +69,7 @@ def search_query(es: Elasticsearch, user_query: str, language: str):
    },
    "highlight": {
        "fields" : {
            "body" : {}
            "description" : {}
        }
    },
    "_source": ["title", "subtitles", "url", "description", "lang", "body"]
@@ -78,7 +78,10 @@ def search_query(es: Elasticsearch, user_query: str, language: str):
  res = es.search(index=index_name, body=query)
  results = []
  for h in res['hits']['hits']:
    results.append(h['_source'])
    result = h['_source']
    if 'highlight' in h:
      result['description'] = ' '.join(h['highlight']['description'])
    results.append(result)
  return results

def autocomplete(es: Elasticsearch, language: str) -> List[str]: