{"action":"created","issue":{"url":"https://api.github.com/repos/matteodem/meteor-easy-search/issues/207","labels_url":"https://api.github.com/repos/matteodem/meteor-easy-search/issues/207/labels{/name}","comments_url":"https://api.github.com/repos/matteodem/meteor-easy-search/issues/207/comments","events_url":"https://api.github.com/repos/matteodem/meteor-easy-search/issues/207/events","html_url":"https://github.com/matteodem/meteor-easy-search/issues/207","id":73338875,"number":207,"title":"Autosuggest error: \"Use a string value as the first field specified for autosuggest!\"","user":{"login":"mesosteros","id":1943233,"avatar_url":"https://avatars.githubusercontent.com/u/1943233?v=3","gravatar_id":"","url":"https://api.github.com/users/mesosteros","html_url":"https://github.com/mesosteros","followers_url":"https://api.github.com/users/mesosteros/followers","following_url":"https://api.github.com/users/mesosteros/following{/other_user}","gists_url":"https://api.github.com/users/mesosteros/gists{/gist_id}","starred_url":"https://api.github.com/users/mesosteros/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mesosteros/subscriptions","organizations_url":"https://api.github.com/users/mesosteros/orgs","repos_url":"https://api.github.com/users/mesosteros/repos","events_url":"https://api.github.com/users/mesosteros/events{/privacy}","received_events_url":"https://api.github.com/users/mesosteros/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":2,"created_at":"2015-05-05T15:01:04Z","updated_at":"2015-05-06T08:56:16Z","closed_at":null,"body":"I'm trying to implement autosuggest but it gives me this error. The regular search returns results and I made sure that my first field is a string value.\r\nI'm tring to return values from the Visit Tracker meteor package (https://atmospherejs.com/bigdata/visit-tracker) namely IP addresses, browser names, etc.\r\nI just can't get the suggestion to work. I don't know if it is because the collection is nested (I have to call it like VisitTracker.visits). I'm also using Carbon Router but I don't think this is related (data subscription is returning after all).\r\n\r\nIn my lib folder's collection.js I added:\r\n\r\n```javascript\r\nEasySearch.createSearchIndex('visits', {\r\n    'field' : ['userAgent.browser.family', 'ipAddress', 'createdAt', 'geo', 'returnVisits'],\r\n    'collection' : VisitTracker.visits,\r\n    'limit' : 20,\r\n    'use': 'mongo-db',\r\n    'query' : function (searchString, opts) {\r\n        var query = EasySearch.getSearcher(this.use).defaultQuery(this, searchString);\r\n        return query;\r\n    }\r\n});\r\n```\r\nAnd in the html:\r\n\r\n```html\r\n<template name=\"altSearch\">\r\n    {{> esAutosuggest index=\"visits\" renderSuggestion=suggestion }}\r\n    <ul>\r\n        {{#esEach index=\"visits\"}}\r\n            <li>{{createdAt}}, IP: {{ipAddress}} , userAgentData: {{userAgent.browser.family}}</li>\r\n        {{/esEach}}\r\n    </ul>\r\n    {{> esLoadMoreButton index=\"visits\"}}\r\n    {{#ifEsHasNoResults index=\"visits\"}}\r\n        <div class=\"no-results\">No results found!</div>\r\n    {{/ifEsHasNoResults}}\r\n    {{#ifEsIsSearching index=\"visits\"}}\r\n            <div>Loading...</div>\r\n    {{/ifEsIsSearching}}\r\n</template>\r\n<template name=\"suggestionTpl\">\r\n    {{pre}}<span class=\"found\">{{found}}</span>{{post}}\r\n    {{{doc.userAgent.browser.family}}}\r\n</template>\r\n```\r\n\r\nFinally the js:\r\n\r\n```javascript\r\nTemplate.altSearch.onCreated(function () {\r\n  this.autorun(function () {\r\n    var instance = EasySearch.getComponentInstance(\r\n        { index : 'visits' }\r\n    );\r\n    instance.on('autosuggestSelected', function (values) {\r\n      // run every time the autosuggest selection changes\r\n    });\r\n  });\r\n});\r\nTemplate.altSearch.helpers({\r\n  'suggestion' : function () {\r\n     return Template.suggestionTpl;\r\n  }\r\n});\r\n```\r\n\r\nHere is the error:\r\n```\r\nException in template helper: Error: Use a string value as the first field specified for autosuggest!\r\n    at Object.EasySearch.getComponentInstance.Template.esAutosuggest.helpers.snippets (http://localhost:3000/packages/matteodem_easy-search.js?19cc9f15488fd08f6c512b6858f4e98a2715cc16:1665:15)\r\n    at bindDataContext (http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:2880:16)\r\n    at Blaze._wrapCatchingExceptions (http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:1651:16)\r\n    at http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:2928:66\r\n    at Function.Template._withTemplateInstanceFunc (http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:3476:12)\r\n    at wrapHelper (http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:2927:27)\r\n    at Spacebars.call (http://localhost:3000/packages/spacebars.js?7bafbe05ec09b6bbb6a3b276537e4995ab298a2f:172:18)\r\n    at Spacebars.mustacheImpl (http://localhost:3000/packages/spacebars.js?7bafbe05ec09b6bbb6a3b276537e4995ab298a2f:109:25)\r\n    at Object.Spacebars.dataMustache (http://localhost:3000/packages/spacebars.js?7bafbe05ec09b6bbb6a3b276537e4995ab298a2f:141:39)\r\n    at http://localhost:3000/packages/matteodem_easy-search.js?19cc9f15488fd08f6c512b6858f4e98a2715cc16:1043:32\r\n```"},"comment":{"url":"https://api.github.com/repos/matteodem/meteor-easy-search/issues/comments/99387976","html_url":"https://github.com/matteodem/meteor-easy-search/issues/207#issuecomment-99387976","issue_url":"https://api.github.com/repos/matteodem/meteor-easy-search/issues/207","id":99387976,"user":{"login":"mesosteros","id":1943233,"avatar_url":"https://avatars.githubusercontent.com/u/1943233?v=3","gravatar_id":"","url":"https://api.github.com/users/mesosteros","html_url":"https://github.com/mesosteros","followers_url":"https://api.github.com/users/mesosteros/followers","following_url":"https://api.github.com/users/mesosteros/following{/other_user}","gists_url":"https://api.github.com/users/mesosteros/gists{/gist_id}","starred_url":"https://api.github.com/users/mesosteros/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mesosteros/subscriptions","organizations_url":"https://api.github.com/users/mesosteros/orgs","repos_url":"https://api.github.com/users/mesosteros/repos","events_url":"https://api.github.com/users/mesosteros/events{/privacy}","received_events_url":"https://api.github.com/users/mesosteros/received_events","type":"User","site_admin":false},"created_at":"2015-05-06T08:56:16Z","updated_at":"2015-05-06T08:56:16Z","body":"```javascript\r\n{\r\ncreatedAt: Sat Apr 05 2014 03:42:12 GMT-0700 (PDT),\r\nreferer: 'https://www.google.com/search?q=visit+tracker&oq=visit+tracker&aqs=chrome..69i57j69i61l3j0l2.3647j0j8&sourceid=chrome&espv=210&es_sm=119&ie=UTF-8',\r\nipAddress: '76.167.148.250',\r\nuserAgent: {\r\n raw: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.152 Safari/537.36',\r\n os: {\r\n  family: 'Mac OS X',\r\n  major: '10',\r\n  minor: '9',\r\n  patch: '0',\r\n  patchMinor: null\r\n },\r\n device: {\r\n  family: 'Other'\r\n },\r\n browser: {\r\n  family: 'Chrome',\r\n  major: 33,\r\n  minor: 0,\r\n  patch: 1750\r\n }\r\n},\r\ntrafficSource: {\r\n sid: 'googd'\r\n cmp: '2341234'\r\n s1: 'ad4342'\r\n s2: 'dopetracker'\r\n}\r\ngeo: {\r\n range: [ 1286050560, 1286051327 ],\r\n country: 'US',\r\n region: 'CA',\r\n city: 'La Jolla',\r\n ll: [ 32.8667, -117.2481 ]\r\n}\r\nreturnVisits: [\r\n  Sat Apr 05 2014 04:22:05 GMT-0700 (PDT),\r\n  Sat Apr 05 2014 05:45:00 GMT-0700 (PDT)\r\n]\r\n}\r\n```"}}