mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-26 03:55:07 +08:00
Introduce an input field for the facet filters on the http-ui
This commit is contained in:
parent
2341b99379
commit
218eb97241
@ -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');
|
||||
});
|
||||
|
@ -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();
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user