Introduce an input field for the facet filters on the http-ui

This commit is contained in:
Clément Renault 2020-11-14 14:01:41 +01:00
parent 2341b99379
commit 218eb97241
No known key found for this signature in database
GPG Key ID: 92ADA4E935E71FA4
3 changed files with 10 additions and 7 deletions

View File

@ -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');
});

View File

@ -573,9 +573,10 @@ async fn main() -> anyhow::Result<()> {
search.query(query);
}
if let Some(condition) = query.facet_condition {
let condition = FacetCondition::from_str(&rtxn, &index, &condition).unwrap();
if let Some(condition) = FacetCondition::from_str(&rtxn, &index, &condition).unwrap() {
search.facet_condition(condition);
}
}
let SearchResult { found_words, documents_ids } = search.execute().unwrap();

View File

@ -55,7 +55,8 @@
<div class="level-left">
<div class="level-item">
<div class="field has-addons has-addons-right">
<input id="search" class="input" type="text" autofocus placeholder="e.g. George Clooney">
<input id="query" class="input" type="text" autofocus placeholder="e.g. George Clooney">
<input id="facet" class="input" type="text" placeholder="facet filter like released >= 1577836800">
</div>
</div>
<div class="level-item"></div>