Mercurial > hg > NetworkVis
comparison ismi-python-neo4jrestclient/ismi-vis.py @ 37:7b5dcd3238d2
search field also accepts ismi_ids. display list of authors in head. display author name in title list.
author | casties |
---|---|
date | Thu, 04 Feb 2016 17:35:50 +0100 |
parents | 9f0d4fd3a412 |
children |
comparison
equal
deleted
inserted
replaced
36:810ea40a9ef8 | 37:7b5dcd3238d2 |
---|---|
151 @app.route("/search") | 151 @app.route("/search") |
152 def get_search(): | 152 def get_search(): |
153 try: | 153 try: |
154 q = request.args["q"] | 154 q = request.args["q"] |
155 qs = urllib.parse.quote(q) | 155 qs = urllib.parse.quote(q) |
156 | |
156 norm_js = loadJSON(ismi_db_baseurl + "jsonInterface?method=normalize_string&type=arabic_translit&text=%s"%qs) | 157 norm_js = loadJSON(ismi_db_baseurl + "jsonInterface?method=normalize_string&type=arabic_translit&text=%s"%qs) |
157 nq = norm_js.get("normalized_text") | 158 nq = norm_js.get("normalized_text") |
158 except KeyError: | 159 except KeyError: |
159 return [] | 160 return [] |
160 else: | 161 else: |
161 #query = ("MATCH (t:TEXT)-[:was_created_by]->(p:PERSON {ismi_id: {id}})" | 162 if qs.isdigit(): |
162 # " RETURN t,p,exists((t)-[:is_commentary_on]->()),exists(()-[:is_commentary_on]->(t))") | 163 query = ("MATCH (t:TEXT)-[:was_created_by]->(p:PERSON {ismi_id: {id}})" |
163 query = ("MATCH (t:TEXT)-[:was_created_by]->(p:PERSON)" | 164 " RETURN t,p,exists((t)-[:is_commentary_on]->()),exists(()-[:is_commentary_on]->(t))") |
164 " WHERE p._n_label =~ {name}" | 165 param = {"id": int(qs)} |
165 " RETURN t,p,exists((t)-[:is_commentary_on]->()),exists(()-[:is_commentary_on]->(t))") | 166 |
167 else: | |
168 query = ("MATCH (t:TEXT)-[:was_created_by]->(p:PERSON)" | |
169 " WHERE p._n_label =~ {name}" | |
170 " RETURN t,p,exists((t)-[:is_commentary_on]->()),exists(()-[:is_commentary_on]->(t))") | |
171 param = {"name": ".*%s.*"%nq.lower()} | |
172 | |
166 results = gdb.query( | 173 results = gdb.query( |
167 query, | 174 query, |
168 returns=(Node,Node,bool,bool), | 175 returns=(Node,Node,bool,bool), |
169 params={"name": ".*%s.*"%nq.lower()} | 176 params=param |
170 ) | 177 ) |
171 # {"name": "(?i).*" + q + ".*"} | 178 # {"name": "(?i).*" + q + ".*"} |
172 print("search for %s returned %s results"%(repr(q),len(results))) | 179 print("search for %s returned %s results"%(repr(q),len(results))) |
173 data = [{"text": t.properties, | 180 data = [{"text": t.properties, |
174 "author": a.properties, | 181 "author": a.properties, |