I'm using the instantsearch.js library provided by Algolia.
The behaviour I want is: if the visitor hasn't entered anything in the search box then no results are returned.
However, the Algolia documentation states that:
If no query parameter is set, the textual search will match with all the objects.
Is it possible to change this behaviour, while still using instantsearch.js?
Here is the code I currently have:
<script type="text/javascript" src="http://cdn.jsdelivr.net/instantsearch.js/1/instantsearch.min.js"></script>
<script type="text/javascript">
window.onload = function ()
{
function getTemplate(templateName) {
return document.getElementById(templateName + '-template').innerHTML;
}
var search = instantsearch({
appId: '{{config["ALGOLIA_APPLICATION_ID"]}}',
apiKey: '{{config["ALGOLIA_API_KEY"]}}',
indexName: '{{config["ALGOLIA_INDEX_NAME"]}}',
urlSync: true
});
search.addWidget(
instantsearch.widgets.searchBox({
container: '#search-input'
})
);
search.addWidget(
instantsearch.widgets.hits({
container: '#hits-container',
hitsPerPage: 10,
templates: {
item: getTemplate('hit'),
empty: getTemplate('no-results')
}
})
);
search.start();
};
</script>