Join counts for multiple words
This commit is contained in:
parent
d30397cefa
commit
3d7b72e5ef
2 changed files with 9 additions and 3 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
src/__pycache__
|
||||
|
|
@ -6,7 +6,7 @@ import json
|
|||
from urllib.parse import unquote
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
## Todo - Boolean search (AND/OR/NOT/"")
|
||||
@app.route("/search/<query>")
|
||||
def search(query):
|
||||
with open('data/index.json', 'r') as index_json:
|
||||
|
|
@ -17,9 +17,14 @@ def search(query):
|
|||
for q in query_split:
|
||||
q = q.lower()
|
||||
if q in index:
|
||||
result.append(index[q])
|
||||
for item in index[q]:
|
||||
matching_results = list(filter(lambda entry: entry['url'] == item["url"], result))
|
||||
if len(matching_results) == 0:
|
||||
result.append(item)
|
||||
else:
|
||||
matching_results[0]["count"] += item["count"]
|
||||
#result.append(index[q])
|
||||
# result.sort(reverse= True,key=lambda entry: int(entry.count))
|
||||
print(result)
|
||||
return result
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue