Return the file of each search result in response

- Useful for enabling jump to note functionality in interfaces
- It will be used in the Khoj plugin for Obsidian
This commit is contained in:
Debanjum Singh Solanky 2023-01-03 01:25:34 -03:00
parent fe1398401d
commit 152e5f1661

View file

@ -186,7 +186,10 @@ def collate_results(hits, entries: list[Entry], count=5) -> list[SearchResponse]
return [SearchResponse.parse_obj(
{
"entry": entries[hit['corpus_id']].raw,
"score": f"{hit['cross-score'] if 'cross-score' in hit else hit['score']:.3f}"
"score": f"{hit['cross-score'] if 'cross-score' in hit else hit['score']:.3f}",
"additional": {
"file": entries[hit['corpus_id']].file,
}
})
for hit
in hits[0:count]]