diff --git a/src/scripts/tutti/4_search.js b/src/scripts/tutti/4_search.js index c705fa1a..9c53603c 100644 --- a/src/scripts/tutti/4_search.js +++ b/src/scripts/tutti/4_search.js @@ -7,16 +7,44 @@ $(document).ready(function() { if (typeof algoliaIndex === 'undefined') return; + var elasticSearch = function() { + + console.log('yay'); + + return function findMatches(q, cb, async){ + let newhits = []; + // do a query + console.log(q); + $.getJSON("/api/newsearch?q=" + q, function( data ) { + console.log(data.hits.hits); + let hits = data.hits.hits; + newhits = hits.map(function(hit){ + console.log(hit._source); + return hit._source; + }); + console.log(newhits); + cb(newhits); + console.log(cb); + async(); + }); + //api/newsearch?q=test%20dji + // return the matches.. + //cb(matches); + }; + + }; var searchInput = $('#cloud-search'); var tu = searchInput.typeahead({hint: true}, { - source: algoliaIndex.ttAdapter(), + //source: algoliaIndex.ttAdapter(), + source: elasticSearch(), displayKey: 'name', limit: 10, minLength: 0, templates: { suggestion: function(hit) { - + console.log('hit2'); + console.log(hit); var hitMedia = (hit.media ? ' ยท '+hit.media+'' : ''); var hitFree = (hit.is_free ? '