mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-12-02 01:55:03 +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 request = null;
|
||||||
var timeoutID = null;
|
var timeoutID = null;
|
||||||
|
|
||||||
$('#search').on('input', function () {
|
$('#query, #facet').on('input', function () {
|
||||||
var query = $(this).val();
|
var query = $('#query').val();
|
||||||
|
var facet = $('#facet').val();
|
||||||
var timeoutMs = 100;
|
var timeoutMs = 100;
|
||||||
|
|
||||||
if (timeoutID !== null) {
|
if (timeoutID !== null) {
|
||||||
@ -14,7 +15,7 @@ $('#search').on('input', function () {
|
|||||||
type: "POST",
|
type: "POST",
|
||||||
url: "query",
|
url: "query",
|
||||||
contentType: 'application/json',
|
contentType: 'application/json',
|
||||||
data: JSON.stringify({ 'query': query }),
|
data: JSON.stringify({ 'query': query, 'facetCondition': facet }),
|
||||||
contentType: 'application/json',
|
contentType: 'application/json',
|
||||||
success: function (data, textStatus, request) {
|
success: function (data, textStatus, request) {
|
||||||
results.innerHTML = '';
|
results.innerHTML = '';
|
||||||
@ -77,5 +78,5 @@ $('#db-size').text(function(index, text) {
|
|||||||
// We trigger the input when we load the script, this way
|
// We trigger the input when we load the script, this way
|
||||||
// we execute a placeholder search when the input is empty.
|
// we execute a placeholder search when the input is empty.
|
||||||
$(window).on('load', function () {
|
$(window).on('load', function () {
|
||||||
$('#search').trigger('input');
|
$('#query').trigger('input');
|
||||||
});
|
});
|
||||||
|
@ -573,9 +573,10 @@ async fn main() -> anyhow::Result<()> {
|
|||||||
search.query(query);
|
search.query(query);
|
||||||
}
|
}
|
||||||
if let Some(condition) = query.facet_condition {
|
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);
|
search.facet_condition(condition);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let SearchResult { found_words, documents_ids } = search.execute().unwrap();
|
let SearchResult { found_words, documents_ids } = search.execute().unwrap();
|
||||||
|
|
||||||
|
@ -55,7 +55,8 @@
|
|||||||
<div class="level-left">
|
<div class="level-left">
|
||||||
<div class="level-item">
|
<div class="level-item">
|
||||||
<div class="field has-addons has-addons-right">
|
<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>
|
</div>
|
||||||
<div class="level-item"></div>
|
<div class="level-item"></div>
|
||||||
|
Loading…
Reference in New Issue
Block a user