aboutsummaryrefslogtreecommitdiff
path: root/gn2
diff options
context:
space:
mode:
authorzsloan2024-06-26 22:24:53 +0000
committerzsloan2024-06-27 14:34:42 -0500
commitbb50f7dfcc753e1067c4e146f9b8973872fb2d63 (patch)
tree830134bb7edefcbd220951181c2a3f495048b229 /gn2
parentf6bcad10df3b6663d19227d2cf58d2e2b52bbe91 (diff)
downloadgenenetwork2-bb50f7dfcc753e1067c4e146f9b8973872fb2d63.tar.gz
Automatically decide whether to use Xapian or SQL (uses Xapian if possible) + remove separate search button
Change logic so that SQL is used for non-term Publish searches, since searches for phenotype trait IDs currently don't work in Xapian
Diffstat (limited to 'gn2')
-rw-r--r--gn2/wqflask/search_results.py7
-rw-r--r--gn2/wqflask/static/new/javascript/dataset_select_menu_orig.js5
-rwxr-xr-xgn2/wqflask/templates/index_page.html4
3 files changed, 4 insertions, 12 deletions
diff --git a/gn2/wqflask/search_results.py b/gn2/wqflask/search_results.py
index b269b031..057ee1ff 100644
--- a/gn2/wqflask/search_results.py
+++ b/gn2/wqflask/search_results.py
@@ -43,7 +43,7 @@ class SearchResultPage:
self.uc_id = uuid.uuid4()
self.go_term = None
- self.search_type = kw['search_type']
+ self.search_type = "sql" # Assume it's an SQL search by default, since all searches will work with SQL
if kw['search_terms_or']:
self.and_or = "or"
@@ -90,7 +90,7 @@ class SearchResultPage:
else:
self.gen_search_result()
- def gen_search_result(self, search_type="sql"):
+ def gen_search_result(self):
"""
Get the info displayed in the search result table from the set of results computed in
the "search" function
@@ -279,7 +279,8 @@ class SearchResultPage:
# Set of terms compatible with Xapian currently (None is a search without a term)
xapian_terms = ["POSITION", "MEAN", "LRS", "LOD"]
- if self.search_type == "xapian" and all([(the_term['key'] in xapian_terms) or not the_term['key'] for the_term in self.search_terms]):
+ if all([(the_term['key'] in xapian_terms) or (not the_term['key'] and self.dataset.type != "Publish") for the_term in self.search_terms]):
+ self.search_type = "xapian"
self.results = requests.get(generate_xapian_request(self.dataset, self.search_terms, self.and_or)).json()
else:
self.search_type = "sql"
diff --git a/gn2/wqflask/static/new/javascript/dataset_select_menu_orig.js b/gn2/wqflask/static/new/javascript/dataset_select_menu_orig.js
index 4310c4a8..2875eabd 100644
--- a/gn2/wqflask/static/new/javascript/dataset_select_menu_orig.js
+++ b/gn2/wqflask/static/new/javascript/dataset_select_menu_orig.js
@@ -329,8 +329,3 @@ $("#make_default").click(make_default);
$("#btsearch").click(function() {
$("#searchform").prop("action", "/search")
});
-
-$("#xapianSearch").click(function() {
- $("input[name='search_type']").val("xapian")
- $("#searchform").prop("action", "/search")
-});
diff --git a/gn2/wqflask/templates/index_page.html b/gn2/wqflask/templates/index_page.html
index 84d441f2..f0840425 100755
--- a/gn2/wqflask/templates/index_page.html
+++ b/gn2/wqflask/templates/index_page.html
@@ -111,7 +111,6 @@
</div>
<form method="get" action="/search" target="_blank" id="searchform" name="SEARCHFORM",
data-gn_server_url="{{gn_server_url}}">
- <input name="search_type" type="hidden" value="sql">
<fieldset>
<div style="padding-left: 20px; padding-right: 20px;" class="form-horizontal">
@@ -199,9 +198,6 @@
<div class="col-2 controls">
<button id="btsearch" class="btn btn-primary form-control"><span class="glyphicon glyphicon-search"></span> Search</button>
</div>
- <div class="col-2 controls" style="padding-left: 20px;">
- <button id="xapianSearch" class="btn btn-primary form-control"><span class="glyphicon glyphicon-search"></span> Xapian Search</button>
- </div>
<div class="col-2 align-self-end controls" style="padding-left: 20px;">
<button type="button" id="make_default" class="btn form-control info-button"><span class="glyphicon glyphicon-pushpin"></span> Lock Menu</button>
</div>