T53161 project user search now also elastic

This commit is contained in:
2017-11-17 17:41:43 +01:00
parent d355e58f2f
commit 8b789d408e
2 changed files with 26 additions and 23 deletions

View File

@@ -1,23 +1,14 @@
(function ( $ ) {
// See organizations/view_embed.pug for example use.
$.fn.userSearch = function(algolia_application_id, algolia_public_key, algolia_index_users, on_selected) {
var client = algoliasearch(algolia_application_id, algolia_public_key);
var index = client.initIndex(algolia_index_users);
var target = this;
this.autocomplete({hint: false}, [
{
source: function (q, cb) {
index.search(q, {hitsPerPage: 5}, function (error, content) {
if (error) {
cb([]);
return;
}
cb(content.hits, content);
});
},
displayKey: 'full_name',
minLength: 2,
source: elasticSearch($, '/user'),
displayKey: 'full_name',
async: true,
minLength: 1,
limit: 10,
templates: {
suggestion: function (hit) {