{"action":"created","issue":{"url":"https://api.github.com/repos/matteodem/meteor-easy-search/issues/211","labels_url":"https://api.github.com/repos/matteodem/meteor-easy-search/issues/211/labels{/name}","comments_url":"https://api.github.com/repos/matteodem/meteor-easy-search/issues/211/comments","events_url":"https://api.github.com/repos/matteodem/meteor-easy-search/issues/211/events","html_url":"https://github.com/matteodem/meteor-easy-search/issues/211","id":74666516,"number":211,"title":"Custom Searcher - callback is not called","user":{"login":"dpdonohue","id":3017475,"avatar_url":"https://avatars.githubusercontent.com/u/3017475?v=3","gravatar_id":"","url":"https://api.github.com/users/dpdonohue","html_url":"https://github.com/dpdonohue","followers_url":"https://api.github.com/users/dpdonohue/followers","following_url":"https://api.github.com/users/dpdonohue/following{/other_user}","gists_url":"https://api.github.com/users/dpdonohue/gists{/gist_id}","starred_url":"https://api.github.com/users/dpdonohue/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dpdonohue/subscriptions","organizations_url":"https://api.github.com/users/dpdonohue/orgs","repos_url":"https://api.github.com/users/dpdonohue/repos","events_url":"https://api.github.com/users/dpdonohue/events{/privacy}","received_events_url":"https://api.github.com/users/dpdonohue/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/matteodem/meteor-easy-search/labels/question","name":"question","color":"cc317c"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-05-09T12:49:54Z","updated_at":"2015-05-10T13:22:54Z","closed_at":null,"body":"Hi Matteo,\r\nI am making a custom searcher that simply calls an external JSON web service.  \r\nThe problem is that my search() method fails to return anything.\r\nAs the user types, my searcher is called properly it retrieves the proper results.  \r\nI tried sending the results in the callback but the callback is \"not defined\".  In other words, Easy Search is calling my custom searcher's search() method without the callback argument defined.\r\nI also tried using futures, as you do with your ElasticSearch searcher.\r\n\r\nThanks\r\nDave D\r\n```\r\nif (Meteor.isServer) {\r\n\r\n    var Future = Npm.require('fibers/future');\r\n\r\n    bioolookupSearch = function (name, searchString, params, callback) {\r\n        var fut;\r\n        if (!callback) fut = new Future();\r\n        var bioportalConfig = YAML.eval(Assets.getText('config/bioportal.yml'));\r\n        var url = bioportalConfig.baseurl + \"search?display_links=false&q=\" + encodeURIComponent(searchString) + \"&apikey=\" + bioportalConfig.apikey;\r\n        console.log(\"bioolookupSearch: params=\" + JSON.stringify(params.ontologies));\r\n        console.log(\"bioolookupSearch: url=\" + url);\r\n        if (! params) params = {};\r\n        HTTP.get(url, params, function(err, results) {\r\n            if (err) {\r\n                console.error(\"Error in bioolookup: \" + err );\r\n                return;\r\n            }\r\n            var json = JSON.parse(results.content);\r\n            var data = {\r\n                total: 100,\r\n                results: json.collection\r\n            };\r\n\r\n            console.log(\"Received results: \" + JSON.stringify(data));\r\n            if (callback) {\r\n                return callback(data);\r\n            } else {\r\n                fut['return'](data);\r\n            }\r\n        });\r\n\r\n        if (!callback) return fut.wait();\r\n    };\r\n\r\n\r\n    EasySearch.createSearcher('bioontology', {\r\n        search: bioolookupSearch,\r\n        createSearchIndex: function(name, options) {\r\n            //do nothing.\r\n        }\r\n    });\r\n\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/matteodem/meteor-easy-search/issues/comments/100641271","html_url":"https://github.com/matteodem/meteor-easy-search/issues/211#issuecomment-100641271","issue_url":"https://api.github.com/repos/matteodem/meteor-easy-search/issues/211","id":100641271,"user":{"login":"dpdonohue","id":3017475,"avatar_url":"https://avatars.githubusercontent.com/u/3017475?v=3","gravatar_id":"","url":"https://api.github.com/users/dpdonohue","html_url":"https://github.com/dpdonohue","followers_url":"https://api.github.com/users/dpdonohue/followers","following_url":"https://api.github.com/users/dpdonohue/following{/other_user}","gists_url":"https://api.github.com/users/dpdonohue/gists{/gist_id}","starred_url":"https://api.github.com/users/dpdonohue/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dpdonohue/subscriptions","organizations_url":"https://api.github.com/users/dpdonohue/orgs","repos_url":"https://api.github.com/users/dpdonohue/repos","events_url":"https://api.github.com/users/dpdonohue/events{/privacy}","received_events_url":"https://api.github.com/users/dpdonohue/received_events","type":"User","site_admin":false},"created_at":"2015-05-10T13:22:54Z","updated_at":"2015-05-10T13:22:54Z","body":"I find that my custom searcher fails even if I send synchronous data.  \r\nCannot figure out what I might be doing wrong\r\nFrom my logs I see that my search() function is being called.  But in the browser it always shows \"No results found\".\r\n```\r\nEasySearch.createSearcher('bioontology', {\r\n    search: function (name, searchString, params, callback) {\r\n        var data = {\r\n            total: 2,\r\n            results: [\r\n                {prefLabel: \"one\"},\r\n                {prefLabel: \"two\"}\r\n            ]\r\n        };\r\n        return data;\r\n    },\r\n\r\n    createSearchIndex: function(name, options) {\r\n        //do nothing.\r\n    }\r\n});\r\n\r\n\r\nEasySearch.createSearchIndex('bioolookup', {\r\n    use : 'bioontology',\r\n    collection: Entities,\r\n    query: function(q) {\r\n        console.log(\"Query for: \" + JSON.stringify(q));\r\n        return q;\r\n    },\r\n    props: {\r\n        ontologies: 'RXNORM'\r\n    }\r\n});\r\n```\r\n\r\n```\r\n<template name=\"bioolookup\">\r\n    {{> esInput index=\"bioolookup\" placeholder=\"Search bioontology\"}}\r\n\r\n    {{#ifEsInputIsEmpty index=\"bioolookup\"}}\r\n        <div>No search term entered</div>\r\n    {{/ifEsInputIsEmpty}}\r\n\r\n    {{#ifEsHasNoResults index=\"bioolookup\"}}\r\n        <div class=\"no-results\">No results found</div>\r\n    {{else}}\r\n        {{#ifEsIsSearching index=\"bioolookup\"}}\r\n            <div>Loading...</div>\r\n        {{else}}\r\n            <div class=\"results-wrapper\">\r\n                {{#esEach index=\"bioolookup\"}}\r\n                    {{> bioolookupItem}}\r\n                {{/esEach}}\r\n            </div>\r\n\r\n            {{> esLoadMoreButton index=\"bioolookup\"}}\r\n        {{/ifEsIsSearching}}\r\n    {{/ifEsHasNoResults}}\r\n</template>\r\n\r\n<template name=\"bioolookupItem\">\r\n    Item: {{prefLabel}}\r\n</template>\r\n```\r\n"}}