From 218eb972416f06a187b0ca42bbbd18d866056c97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renault?= Date: Sat, 14 Nov 2020 14:01:41 +0100 Subject: [PATCH] Introduce an input field for the facet filters on the http-ui --- http-ui/public/script.js | 9 +++++---- http-ui/src/main.rs | 5 +++-- http-ui/templates/index.html | 3 ++- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/http-ui/public/script.js b/http-ui/public/script.js index 70b9e4da1..fb7a95cc9 100644 --- a/http-ui/public/script.js +++ b/http-ui/public/script.js @@ -1,8 +1,9 @@ var request = null; var timeoutID = null; -$('#search').on('input', function () { - var query = $(this).val(); +$('#query, #facet').on('input', function () { + var query = $('#query').val(); + var facet = $('#facet').val(); var timeoutMs = 100; if (timeoutID !== null) { @@ -14,7 +15,7 @@ $('#search').on('input', function () { type: "POST", url: "query", contentType: 'application/json', - data: JSON.stringify({ 'query': query }), + data: JSON.stringify({ 'query': query, 'facetCondition': facet }), contentType: 'application/json', success: function (data, textStatus, request) { results.innerHTML = ''; @@ -77,5 +78,5 @@ $('#db-size').text(function(index, text) { // We trigger the input when we load the script, this way // we execute a placeholder search when the input is empty. $(window).on('load', function () { - $('#search').trigger('input'); + $('#query').trigger('input'); }); diff --git a/http-ui/src/main.rs b/http-ui/src/main.rs index d05b69f2c..9671576f6 100644 --- a/http-ui/src/main.rs +++ b/http-ui/src/main.rs @@ -573,8 +573,9 @@ async fn main() -> anyhow::Result<()> { search.query(query); } if let Some(condition) = query.facet_condition { - let condition = FacetCondition::from_str(&rtxn, &index, &condition).unwrap(); - search.facet_condition(condition); + if let Some(condition) = FacetCondition::from_str(&rtxn, &index, &condition).unwrap() { + search.facet_condition(condition); + } } let SearchResult { found_words, documents_ids } = search.execute().unwrap(); diff --git a/http-ui/templates/index.html b/http-ui/templates/index.html index f2161457d..0ef239622 100644 --- a/http-ui/templates/index.html +++ b/http-ui/templates/index.html @@ -55,7 +55,8 @@
- + +