Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -13,10 +13,6 @@ from elasticsearch_dsl import Search, Q
|
|
| 13 |
# es = Elasticsearch(os.environ.get("host"), timeout=100, http_compress=True, maxsize=1000)
|
| 14 |
es = Elasticsearch(os.environ.get("host"), http_compress=True, timeout=200)
|
| 15 |
def mark_tokens_bold(text, tokens):
|
| 16 |
-
# if query.startswith('"') and query.endswith('"'):
|
| 17 |
-
# tokens = query[1:-1]
|
| 18 |
-
# else:
|
| 19 |
-
# tokens = query.split(" ")
|
| 20 |
for token in tokens:
|
| 21 |
if token in ["<", "b", "/", ">"]:
|
| 22 |
continue
|
|
@@ -32,10 +28,10 @@ def process_results(results, query):
|
|
| 32 |
results_html = ""
|
| 33 |
for result in results:
|
| 34 |
text_html = result["text"]
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
repository = result["repository"]
|
| 40 |
path = result["path"]
|
| 41 |
license = result["license"]
|
|
|
|
| 13 |
# es = Elasticsearch(os.environ.get("host"), timeout=100, http_compress=True, maxsize=1000)
|
| 14 |
es = Elasticsearch(os.environ.get("host"), http_compress=True, timeout=200)
|
| 15 |
def mark_tokens_bold(text, tokens):
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
for token in tokens:
|
| 17 |
if token in ["<", "b", "/", ">"]:
|
| 18 |
continue
|
|
|
|
| 28 |
results_html = ""
|
| 29 |
for result in results:
|
| 30 |
text_html = result["text"]
|
| 31 |
+
if query.startswith('"') and query.endswith('"'):
|
| 32 |
+
text_html = mark_tokens_bold(text_html, query[1:-1].split(" "))
|
| 33 |
+
else:
|
| 34 |
+
text_html = mark_tokens_bold(text_html, query.split(" "))
|
| 35 |
repository = result["repository"]
|
| 36 |
path = result["path"]
|
| 37 |
license = result["license"]
|