Issue from code4lib discussions. The idea is that the search UI can look at the hash so that https://minicomp.github.io/wax/search/#Qatar opens up a search directly to items matching the string "#Qatar".
Happy to have this assigned to me if it's desirable.
One question is whether entering a search should also update the hash dynamically as well.
function startSearchUI(fields, indexFile, url) {
$.getJSON(indexFile, function(store) {
var index = new elasticlunr.Index;
index.saveDocument(false);
index.setRef('lunr_id');
for (i in fields) { index.addField(fields[i]); }
for (i in store) { index.addDoc(store[i]); }
function run_search(terms) {
var results_div = $('#results');
var query = terms
var results = index.search(query, { boolean: 'AND', expand: true });
results_div.empty();
results_div.append(`<p class="results-info">Displaying ${results.length} results</p>`);
for (var r in results) {
var ref = results[r].ref;
var item = store[ref];
var result = displayResult(item, fields, url);
results_div.append(result);
}
}
if (window.location.hash) {
var search = decodeURIComponent(window.location.hash.slice(1);
$('input#search').val(search) // Is this how you assign in jquery?
run_search(search)
}
$('input#search').on('keyup', function() {
var query = $(this).val();
run_search(query)
}
});
});
}
Issue from code4lib discussions. The idea is that the search UI can look at the hash so that
https://minicomp.github.io/wax/search/#Qatar
opens up a search directly to items matching the string "#Qatar".Happy to have this assigned to me if it's desirable.
One question is whether entering a search should also update the hash dynamically as well.