forked from AnishmMore/patent_search
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
42 lines (34 loc) · 1.37 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from flask import Flask,render_template,request
from elasticsearch import Elasticsearch
import json
from bert import *
from flask_paginate import Pagination, get_page_parameter
#old url for less data
#es_url = 'https://1pdwgdsjzl:[email protected]:443'
#new url for large data
es_url = 'https://9yn9ttqsvv:[email protected]:443'
es = Elasticsearch(es_url)
es.ping()
app = Flask(__name__)
@app.route('/')
def msg():
return render_template('index.html')
@app.route("/search", methods=['POST','GET'])
def search():
search_term = request.form["input"]
res= es.search(index='patents', body={"query": {"multi_match":
{"query": search_term,
"fields":["title","abstract","publication_number","inventors"]
}
}})
return render_template('search.html',res=res)
@app.route("/bert", methods=['POST','GET'])
def bert():
search_term = request.form["input"]
D, I = s_v([search_term], model, index, num_results=10)
res= indx(df, I)
#print(res)
return render_template('bert.html',res=res)
# main driver function
if __name__ == '__main__':
app.run(port=8080)