Last active
March 22, 2023 11:43
-
-
Save drew2a/e632fe807bb2462d6d33806ad194ae72 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from elasticsearch import Elasticsearch | |
elastic_client = Elasticsearch('http://localhost:9200', request_timeout=120) | |
print('query:') | |
for line in sys.stdin: | |
query = { | |
"simple_query_string": { | |
"query": line.rstrip(), | |
} | |
} | |
result = elastic_client.search(index='tribler', query=query, size=50) | |
print(f'\nResults({result.body["took"] / 1000}s):') | |
printed_infohashes = set() | |
for hit in result.body['hits']['hits']: | |
infohash = hit['_source']['infohash'] | |
if infohash in printed_infohashes: | |
continue | |
print(f"{hit['_source']['title']} [score: {hit['_score']} infohash: {infohash}]") | |
printed_infohashes.add(infohash) | |
print('\nquery:') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment