{"id":5580,"date":"2018-08-14T07:00:38","date_gmt":"2018-08-14T14:00:38","guid":{"rendered":"https:\/\/www.couchbase.com\/blog\/?p=5580"},"modified":"2025-06-13T20:59:14","modified_gmt":"2025-06-14T03:59:14","slug":"create-a-full-text-search-typeahead-with-go-jquery-and-nosql","status":"publish","type":"post","link":"https:\/\/www.couchbase.com\/blog\/pt\/create-a-full-text-search-typeahead-with-go-jquery-and-nosql\/","title":{"rendered":"Criar um tipo de pesquisa de texto completo com Go, jQuery e NoSQL"},"content":{"rendered":"<p>H\u00e1 cerca de uma semana, escrevi um tutorial para <a href=\"https:\/\/www.couchbase.com\/blog\/pt\/developing-a-typeahead-with-couchbase-node-js-and-full-text-search\/\" target=\"_blank\" rel=\"noopener noreferrer\">Implementa\u00e7\u00e3o de uma pesquisa typeahead com Node.js e jQuery<\/a>. Um typeahead \u00e9 um dos muitos casos de uso excelentes ao usar a pesquisa de texto completo (FTS), mas certamente n\u00e3o \u00e9 o \u00fanico caso de uso. Como muitos de voc\u00eas sabem, sou um grande f\u00e3 do Golang e do Node.js, ent\u00e3o achei que seria uma boa ideia ver o mesmo exemplo, mas desta vez usando uma tecnologia de programa\u00e7\u00e3o diferente.<\/p>\n<p>Veremos como usar o <a href=\"https:\/\/twitter.github.io\/typeahead.js\/\" target=\"_blank\" rel=\"noopener noreferrer\">typeahead.js<\/a>uma extens\u00e3o do jQuery, bem como <a href=\"https:\/\/www.couchbase.com\/blog\/pt\/\" target=\"_blank\" rel=\"noopener noreferrer\">Couchbase<\/a> e a linguagem de programa\u00e7\u00e3o Go para implementar um tipo de preenchimento autom\u00e1tico em nosso aplicativo.<\/p>\n<p><!--more--><\/p>\n<p>Se voc\u00ea n\u00e3o viu meu <a href=\"https:\/\/www.couchbase.com\/blog\/pt\/developing-a-typeahead-with-couchbase-node-js-and-full-text-search\/\" target=\"_blank\" rel=\"noopener noreferrer\">Artigo anterior<\/a>N\u00e3o se preocupe, pois \u00e9 uma linguagem diferente e, portanto, um problema diferente. Vamos come\u00e7ar do zero e ver como as coisas s\u00e3o feitas com o Go. Pressup\u00f5e-se que voc\u00ea tenha o Go instalado e configurado, bem como o Couchbase instalado e configurado.<\/p>\n<h2>Prepara\u00e7\u00e3o de um conjunto de dados e de um \u00edndice de pesquisa de texto completo<\/h2>\n<p>Para este exemplo, trabalharemos com um conjunto de dados muito simples, mas ele poderia ser significativamente mais complexo com um m\u00ednimo de esfor\u00e7o extra. Nosso conjunto de dados ser\u00e1 parecido com o seguinte:<\/p>\n<pre class=\"lang:default decode:true\">{\r\n  \"title\": \"Forever &amp; Always\",\r\n  \"artist\": \"Taylor Swift\",\r\n  \"type\": \"song\"\r\n}<\/pre>\n<p>Cada documento em nosso banco de dados representar\u00e1 uma m\u00fasica. Para simplificar, vamos nos concentrar apenas no documento <code>t\u00edtulo<\/code> e <code>artista<\/code> informa\u00e7\u00f5es, mas os documentos podem conter uma grande variedade de informa\u00e7\u00f5es.<\/p>\n<p>A pr\u00f3xima etapa \u00e9 criar um \u00edndice FTS para nossos documentos.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-5554 size-full\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2018\/07\/fts-music-index.png\" alt=\"\" width=\"1500\" height=\"689\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2018\/07\/fts-music-index.png 1500w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2018\/07\/fts-music-index-300x138.png 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2018\/07\/fts-music-index-1024x470.png 1024w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2018\/07\/fts-music-index-768x353.png 768w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2018\/07\/fts-music-index-20x9.png 20w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2018\/07\/fts-music-index-1320x606.png 1320w\" sizes=\"auto, (max-width: 1500px) 100vw, 1500px\" \/><\/p>\n<p>A imagem acima demonstra como deve ser um \u00edndice. No que se refere ao mapeamento de tipos, vamos mapear apenas o tipo <code>m\u00fasica<\/code> documentos. Tamb\u00e9m estamos especificando que queremos apenas o <code>artista<\/code> e <code>t\u00edtulo<\/code> informa\u00e7\u00f5es em nosso \u00edndice. A parte importante aqui \u00e9 que estamos armazenando os campos no \u00edndice. Se n\u00e3o optarmos especificamente por armazenar o campo no \u00edndice, n\u00e3o teremos informa\u00e7\u00f5es para preencher nos resultados da pesquisa.<\/p>\n<h2>Cria\u00e7\u00e3o do back-end do Go Powered Full Text Search (FTS)<\/h2>\n<p>Com alguns dados e nosso \u00edndice FTS instalados, podemos come\u00e7ar a desenvolver o backend que executar\u00e1 as consultas. Nosso backend ser\u00e1 uma API RESTful com um \u00fanico endpoint para pesquisa. O boilerplate para esse aplicativo pode ser visto abaixo:<\/p>\n<pre class=\"lang:default decode:true\">package main\r\n\r\nimport (\r\n\t\"encoding\/json\"\r\n\t\"net\/http\"\r\n\r\n\t\"github.com\/gorilla\/handlers\"\r\n\t\"github.com\/gorilla\/mux\"\r\n\tgocb \"gopkg.in\/couchbase\/gocb.v1\"\r\n\t\"gopkg.in\/couchbase\/gocb.v1\/cbft\"\r\n)\r\n\r\ntype Song struct {\r\n\tId     string  `json:\"id\"`\r\n\tScore  float64 `json:\"score\"`\r\n\tArtist string  `json:\"artist\"`\r\n\tTitle  string  `json:\"title\"`\r\n}\r\n\r\nvar bucket *gocb.Bucket\r\n\r\nfunc SearchEndpoint(response http.ResponseWriter, request *http.Request) { }\r\n\r\nfunc main() {\r\n\tcluster, _ := gocb.Connect(\"couchbase:\/\/localhost\")\r\n\tcluster.Authenticate(gocb.PasswordAuthenticator{Username: \"example\", Password: \"123456\"})\r\n\tbucket, _ = cluster.OpenBucket(\"example\", \"\")\r\n\trouter := mux.NewRouter()\r\n\trouter.HandleFunc(\"\/search\", SearchEndpoint).Methods(\"GET\")\r\n\thttp.ListenAndServe(\":12345\", handlers.CORS(handlers.AllowedHeaders([]string{\"X-Requested-With\", \"Content-Type\", \"Authorization\"}), handlers.AllowedMethods([]string{\"GET\", \"POST\", \"PUT\", \"HEAD\", \"OPTIONS\"}), handlers.AllowedOrigins([]string{\"*\"}))(router))\r\n}<\/pre>\n<p>Primeiro, estamos criando uma estrutura de dados nativa em Go que, por fim, conter\u00e1 nossos resultados de pesquisa previstos. Ignorando a l\u00f3gica do endpoint por enquanto, temos nosso <code>principal<\/code> na qual nos conectamos ao nosso banco de dados e definimos nosso \u00fanico ponto de extremidade. Como a pesquisa ser\u00e1 feita via JavaScript, precisamos configurar o compartilhamento de recursos entre origens (CORS) para permitir as solicita\u00e7\u00f5es.<\/p>\n<p>Se quiser saber mais sobre o compartilhamento de recursos entre origens com Go, escrevi um artigo sobre <a href=\"https:\/\/www.thepolyglotdeveloper.com\/2017\/10\/handling-cors-golang-web-application\/\" target=\"_blank\" rel=\"noopener noreferrer\">Artigo anterior<\/a> sobre o assunto. Entretanto, conhecer os detalhes n\u00e3o \u00e9 muito importante para este exemplo.<\/p>\n<p>Vamos dar uma olhada na fun\u00e7\u00e3o que importa:<\/p>\n<pre class=\"lang:default decode:true\">func SearchEndpoint(response http.ResponseWriter, request *http.Request) {\r\n\tresponse.Header().Set(\"content-type\", \"application\/json\")\r\n\tparams := request.URL.Query()\r\n\tquery := gocb.NewSearchQuery(\"idx-music\", cbft.NewMatchQuery(params.Get(\"query\")))\r\n\tquery.Fields(\"artist\", \"title\")\r\n\tresult, _ := bucket.ExecuteSearchQuery(query)\r\n\tvar hits []Song\r\n\tfor _, hit := range result.Hits() {\r\n\t\thits = append(hits, Song{\r\n\t\t\tId:     hit.Id,\r\n\t\t\tScore:  hit.Score,\r\n\t\t\tArtist: hit.Fields[\"artist\"],\r\n\t\t\tTitle:  hit.Fields[\"title\"],\r\n\t\t})\r\n\t}\r\n\tjson.NewEncoder(response).Encode(hits)\r\n}<\/pre>\n<p>Quando essa fun\u00e7\u00e3o \u00e9 chamada, extra\u00edmos todos os par\u00e2metros dos par\u00e2metros de consulta da solicita\u00e7\u00e3o. Esses par\u00e2metros s\u00e3o usados para criar uma nova consulta em nosso \u00edndice de pesquisa de texto completo. Na resposta, queremos que tanto o <code>artista<\/code> e <code>t\u00edtulo<\/code> portanto, devemos defini-los em nossa consulta. Ap\u00f3s a execu\u00e7\u00e3o bem-sucedida, percorremos os resultados da pesquisa e constru\u00edmos um objeto que pode ser \u00fatil para o nosso frontend.<\/p>\n<p>Se voc\u00ea quisesse executar o aplicativo Go, <strong>https:\/\/localhost:12345\/search?query=swift<\/strong> pode potencialmente retornar resultados.<\/p>\n<h2>Projetando o front-end jQuery para pesquisas Typeahead no banco de dados<\/h2>\n<p>Com o backend pronto, agora podemos nos concentrar no frontend. O frontend ser\u00e1 universal, independentemente de qual <a href=\"https:\/\/www.couchbase.com\/blog\/pt\/backend-languages\/\">linguagem de backend<\/a> que voc\u00ea vai usar.<\/p>\n<p>Nosso objetivo \u00e9 criar algo assim:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-5581 size-full\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2018\/08\/typeahead-golang-jquery.gif\" alt=\"\" width=\"1500\" height=\"498\" \/><\/p>\n<p>Vamos usar <a href=\"https:\/\/twitter.github.io\/typeahead.js\/\" target=\"_blank\" rel=\"noopener noreferrer\">typeahead.js<\/a>, <a href=\"https:\/\/jquery.com\/\" target=\"_blank\" rel=\"noopener noreferrer\">jQuery<\/a>e <a href=\"https:\/\/handlebarsjs.com\/\" target=\"_blank\" rel=\"noopener noreferrer\">Guid\u00e3o.js<\/a> para que essa parte seja um sucesso. No entanto, \u00e9 muito importante que usemos a vers\u00e3o <a href=\"https:\/\/github.com\/twitter\/typeahead.js\/releases\/tag\/v0.10.5\" target=\"_blank\" rel=\"noopener noreferrer\">0.10.5<\/a> do typeahead.js devido a um bug em vers\u00f5es posteriores.<\/p>\n<p>Com as bibliotecas baixadas, crie uma estrutura de projeto semelhante \u00e0 seguinte:<\/p>\n<pre class=\"lang:default decode:true\">js\r\n    handlebars-v4.0.11.js\r\n    jquery-3.3.1.min.js\r\n    typeahead.bundle.min.js\r\nindex.html<\/pre>\n<p>Certifique-se de que suas vers\u00f5es correspondam \u00e0s vers\u00f5es de seus arquivos e n\u00e3o \u00e0s minhas.<\/p>\n<p>No <strong>index.html<\/strong> podemos inicializar nosso c\u00f3digo com o seguinte:<\/p>\n<pre class=\"lang:default decode:true\">&lt;html&gt;\r\n    &lt;head&gt;\r\n        &lt;style&gt;\r\n            body {\r\n                background-color: #F0F0F0;\r\n            }\r\n            .tt-input, .tt-hint, .twitter-typeahead {\r\n                width: 100%;\r\n            }\r\n        &lt;\/style&gt;\r\n    &lt;\/head&gt;\r\n    &lt;body&gt;\r\n        &lt;div id=&quot;remote&quot;&gt;\r\n            &lt;input class=&quot;typeahead&quot; type=&quot;text&quot; placeholder=&quot;Songs...&quot;&gt;\r\n        &lt;\/div&gt;\r\n        &lt;script src=&quot;js\/jquery-3.3.1.min.js&quot;&gt;&lt;\/script&gt;\r\n        &lt;script src=&quot;js\/handlebars-v4.0.11.js&quot;&gt;&lt;\/script&gt;\r\n        &lt;script src=&quot;js\/typeahead.0.10.5.bundle.min.js&quot;&gt;&lt;\/script&gt;\r\n        &lt;script&gt;\r\n            \/\/ Logic here\r\n        &lt;\/script&gt;\r\n    &lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<p>Observe que o c\u00f3digo acima cont\u00e9m essencialmente apenas uma entrada de formul\u00e1rio e a importa\u00e7\u00e3o de todas as nossas bibliotecas. Eu recomendei onde nossa l\u00f3gica para o typeahead terminar\u00e1.<\/p>\n<p>Vamos encerrar esse assunto com nossa l\u00f3gica:<\/p>\n<pre class=\"lang:default decode:true\">$(&#039;#remote .typeahead&#039;).typeahead(\r\n    {\r\n        hint: true,\r\n        minLength: 3,\r\n        highlight: false,\r\n        limit: 5\r\n    }, {\r\n        name: &quot;song&quot;,\r\n        displayKey: &quot;id&quot;,\r\n        source: function (query, callback) {\r\n            $.getJSON(&quot;https:\/\/localhost:12345\/search?query=&quot; + query, function (data) {\r\n                return callback(data);\r\n            });\r\n        },\r\n        templates: {\r\n            suggestion: Handlebars.compile(&#039;&lt;div&gt;{{title}} - {{artista}}&lt;\/div&gt;&#039;)\r\n        }\r\n    }\r\n);<\/pre>\n<p>A primeira parte do nosso typeahead \u00e9 a configura\u00e7\u00e3o. Estamos dizendo que queremos que as dicas sejam exibidas e que nossa l\u00f3gica n\u00e3o ocorrer\u00e1 a menos que haja pelo menos tr\u00eas caracteres na pesquisa para economizar em chamadas remotas. N\u00e3o destacaremos os resultados, mas os limitaremos a cinco. Para conduzir a l\u00f3gica do nosso typeahead, emitiremos uma solicita\u00e7\u00e3o ao nosso backend e processaremos a resposta. Ela ser\u00e1 renderizada com base em nosso modelo personalizado do Handlebars.<\/p>\n<p>O <code>displayKey<\/code> \u00e9 o que queremos mostrar depois que um resultado \u00e9 clicado. Em nosso cen\u00e1rio, queremos mostrar os artistas e os t\u00edtulos das m\u00fasicas, mas preencher o ID quando clicado. Dessa forma, o ID pode ser enviado em uma solicita\u00e7\u00e3o futura, se quisermos.<\/p>\n<h2>Conclus\u00e3o<\/h2>\n<p>Voc\u00ea acabou de ver como criar uma pesquisa typeahead em jQuery com Go como backend e <a href=\"https:\/\/www.couchbase.com\/blog\/pt\/\" target=\"_blank\" rel=\"noopener noreferrer\">Couchbase<\/a> como o banco de dados NoSQL. Esse tutorial foi uma continua\u00e7\u00e3o de um <a href=\"https:\/\/www.couchbase.com\/blog\/pt\/developing-a-typeahead-with-couchbase-node-js-and-full-text-search\/\" target=\"_blank\" rel=\"noopener noreferrer\">tutorial anterior<\/a> onde escrevi o back-end do FTS com Node.js e JavaScript.<\/p>\n<p>Para obter mais informa\u00e7\u00f5es sobre como usar o Go SDK com o Couchbase, consulte a se\u00e7\u00e3o <a href=\"https:\/\/www.couchbase.com\/blog\/pt\/developers\/\" target=\"_blank\" rel=\"noopener noreferrer\">Portal do desenvolvedor do Couchbase<\/a>.<\/p>","protected":false},"excerpt":{"rendered":"<p>About a week ago I write a tutorial for implementing a typeahead search with Node.js and jQuery. A typeahead is one of many great use-cases when using full text search (FTS), but it certainly isn&#8217;t the only use-case. As many [&hellip;]<\/p>","protected":false},"author":63,"featured_media":5582,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[1815,1816,2165,1820],"tags":[2259],"ppma_author":[9032],"class_list":["post-5580","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-best-practices-and-tutorials","category-couchbase-server","category-full-text-search","category-golang","tag-typeahead"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v26.1 (Yoast SEO v26.1.1) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Create a Full Text Search Typeahead with Go, jQuery, and NoSQL<\/title>\n<meta name=\"description\" content=\"Learn how to use the Go programming language alongside jQuery and Couchbase NoSQL to create a full text search typeahead form.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.couchbase.com\/blog\/pt\/create-a-full-text-search-typeahead-with-go-jquery-and-nosql\/\" \/>\n<meta property=\"og:locale\" content=\"pt_BR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Create a Full Text Search Typeahead With Go, jQuery, NoSQL\" \/>\n<meta property=\"og:description\" content=\"Learn how to use the Go programming language alongside jQuery and Couchbase NoSQL to create a full text search typeahead form.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.couchbase.com\/blog\/pt\/create-a-full-text-search-typeahead-with-go-jquery-and-nosql\/\" \/>\n<meta property=\"og:site_name\" content=\"The Couchbase Blog\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/thepolyglotdeveloper\" \/>\n<meta property=\"article:published_time\" content=\"2018-08-14T14:00:38+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-06-14T03:59:14+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2018\/08\/search-2041815_1920.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1920\" \/>\n\t<meta property=\"og:image:height\" content=\"1279\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Nic Raboy, Developer Advocate, Couchbase\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@nraboy\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Nic Raboy, Developer Advocate, Couchbase\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutos\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/create-a-full-text-search-typeahead-with-go-jquery-and-nosql\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/create-a-full-text-search-typeahead-with-go-jquery-and-nosql\/\"},\"author\":{\"name\":\"Nic Raboy, Developer Advocate, Couchbase\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/bb545ebe83bb2d12f91095811d0a72e1\"},\"headline\":\"Create a Full Text Search Typeahead With Go, jQuery, NoSQL\",\"datePublished\":\"2018-08-14T14:00:38+00:00\",\"dateModified\":\"2025-06-14T03:59:14+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/create-a-full-text-search-typeahead-with-go-jquery-and-nosql\/\"},\"wordCount\":925,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/create-a-full-text-search-typeahead-with-go-jquery-and-nosql\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2018\/08\/search-2041815_1920.jpg\",\"keywords\":[\"typeahead\"],\"articleSection\":[\"Best Practices and Tutorials\",\"Couchbase Server\",\"Full-Text Search\",\"GoLang\"],\"inLanguage\":\"pt-BR\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.couchbase.com\/blog\/create-a-full-text-search-typeahead-with-go-jquery-and-nosql\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/create-a-full-text-search-typeahead-with-go-jquery-and-nosql\/\",\"url\":\"https:\/\/www.couchbase.com\/blog\/create-a-full-text-search-typeahead-with-go-jquery-and-nosql\/\",\"name\":\"Create a Full Text Search Typeahead with Go, jQuery, and NoSQL\",\"isPartOf\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/create-a-full-text-search-typeahead-with-go-jquery-and-nosql\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/create-a-full-text-search-typeahead-with-go-jquery-and-nosql\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2018\/08\/search-2041815_1920.jpg\",\"datePublished\":\"2018-08-14T14:00:38+00:00\",\"dateModified\":\"2025-06-14T03:59:14+00:00\",\"description\":\"Learn how to use the Go programming language alongside jQuery and Couchbase NoSQL to create a full text search typeahead form.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/create-a-full-text-search-typeahead-with-go-jquery-and-nosql\/#breadcrumb\"},\"inLanguage\":\"pt-BR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.couchbase.com\/blog\/create-a-full-text-search-typeahead-with-go-jquery-and-nosql\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"pt-BR\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/create-a-full-text-search-typeahead-with-go-jquery-and-nosql\/#primaryimage\",\"url\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2018\/08\/search-2041815_1920.jpg\",\"contentUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2018\/08\/search-2041815_1920.jpg\",\"width\":1920,\"height\":1279},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/create-a-full-text-search-typeahead-with-go-jquery-and-nosql\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.couchbase.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Create a Full Text Search Typeahead With Go, jQuery, NoSQL\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#website\",\"url\":\"https:\/\/www.couchbase.com\/blog\/\",\"name\":\"The Couchbase Blog\",\"description\":\"Couchbase, the NoSQL Database\",\"publisher\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.couchbase.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"pt-BR\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\",\"name\":\"The Couchbase Blog\",\"url\":\"https:\/\/www.couchbase.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"pt-BR\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png\",\"contentUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png\",\"width\":218,\"height\":34,\"caption\":\"The Couchbase Blog\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/bb545ebe83bb2d12f91095811d0a72e1\",\"name\":\"Nic Raboy, Developer Advocate, Couchbase\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"pt-BR\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/image\/8863514d8bed0cf6080f23db40e00354\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/bedeb68368d4681aca4c74fe5f697f0c423b80d498ec50fd915ba018b72c101f?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/bedeb68368d4681aca4c74fe5f697f0c423b80d498ec50fd915ba018b72c101f?s=96&d=mm&r=g\",\"caption\":\"Nic Raboy, Developer Advocate, Couchbase\"},\"description\":\"Nic Raboy is an advocate of modern web and mobile development technologies. He has experience in Java, JavaScript, Golang and a variety of frameworks such as Angular, NativeScript, and Apache Cordova. Nic writes about his development experiences related to making web and mobile development easier to understand.\",\"sameAs\":[\"https:\/\/www.thepolyglotdeveloper.com\",\"https:\/\/www.facebook.com\/thepolyglotdeveloper\",\"https:\/\/x.com\/nraboy\"],\"url\":\"https:\/\/www.couchbase.com\/blog\/pt\/author\/nic-raboy-2\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Create a Full Text Search Typeahead with Go, jQuery, and NoSQL","description":"Saiba como usar a linguagem de programa\u00e7\u00e3o Go junto com jQuery e Couchbase NoSQL para criar um formul\u00e1rio de pesquisa de texto completo.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.couchbase.com\/blog\/pt\/create-a-full-text-search-typeahead-with-go-jquery-and-nosql\/","og_locale":"pt_BR","og_type":"article","og_title":"Create a Full Text Search Typeahead With Go, jQuery, NoSQL","og_description":"Learn how to use the Go programming language alongside jQuery and Couchbase NoSQL to create a full text search typeahead form.","og_url":"https:\/\/www.couchbase.com\/blog\/pt\/create-a-full-text-search-typeahead-with-go-jquery-and-nosql\/","og_site_name":"The Couchbase Blog","article_author":"https:\/\/www.facebook.com\/thepolyglotdeveloper","article_published_time":"2018-08-14T14:00:38+00:00","article_modified_time":"2025-06-14T03:59:14+00:00","og_image":[{"width":1920,"height":1279,"url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2018\/08\/search-2041815_1920.jpg","type":"image\/jpeg"}],"author":"Nic Raboy, Developer Advocate, Couchbase","twitter_card":"summary_large_image","twitter_creator":"@nraboy","twitter_misc":{"Written by":"Nic Raboy, Developer Advocate, Couchbase","Est. reading time":"5 minutos"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.couchbase.com\/blog\/create-a-full-text-search-typeahead-with-go-jquery-and-nosql\/#article","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/create-a-full-text-search-typeahead-with-go-jquery-and-nosql\/"},"author":{"name":"Nic Raboy, Developer Advocate, Couchbase","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/bb545ebe83bb2d12f91095811d0a72e1"},"headline":"Create a Full Text Search Typeahead With Go, jQuery, NoSQL","datePublished":"2018-08-14T14:00:38+00:00","dateModified":"2025-06-14T03:59:14+00:00","mainEntityOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/create-a-full-text-search-typeahead-with-go-jquery-and-nosql\/"},"wordCount":925,"commentCount":0,"publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/create-a-full-text-search-typeahead-with-go-jquery-and-nosql\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2018\/08\/search-2041815_1920.jpg","keywords":["typeahead"],"articleSection":["Best Practices and Tutorials","Couchbase Server","Full-Text Search","GoLang"],"inLanguage":"pt-BR","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.couchbase.com\/blog\/create-a-full-text-search-typeahead-with-go-jquery-and-nosql\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.couchbase.com\/blog\/create-a-full-text-search-typeahead-with-go-jquery-and-nosql\/","url":"https:\/\/www.couchbase.com\/blog\/create-a-full-text-search-typeahead-with-go-jquery-and-nosql\/","name":"Create a Full Text Search Typeahead with Go, jQuery, and NoSQL","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/create-a-full-text-search-typeahead-with-go-jquery-and-nosql\/#primaryimage"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/create-a-full-text-search-typeahead-with-go-jquery-and-nosql\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2018\/08\/search-2041815_1920.jpg","datePublished":"2018-08-14T14:00:38+00:00","dateModified":"2025-06-14T03:59:14+00:00","description":"Saiba como usar a linguagem de programa\u00e7\u00e3o Go junto com jQuery e Couchbase NoSQL para criar um formul\u00e1rio de pesquisa de texto completo.","breadcrumb":{"@id":"https:\/\/www.couchbase.com\/blog\/create-a-full-text-search-typeahead-with-go-jquery-and-nosql\/#breadcrumb"},"inLanguage":"pt-BR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.couchbase.com\/blog\/create-a-full-text-search-typeahead-with-go-jquery-and-nosql\/"]}]},{"@type":"ImageObject","inLanguage":"pt-BR","@id":"https:\/\/www.couchbase.com\/blog\/create-a-full-text-search-typeahead-with-go-jquery-and-nosql\/#primaryimage","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2018\/08\/search-2041815_1920.jpg","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2018\/08\/search-2041815_1920.jpg","width":1920,"height":1279},{"@type":"BreadcrumbList","@id":"https:\/\/www.couchbase.com\/blog\/create-a-full-text-search-typeahead-with-go-jquery-and-nosql\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.couchbase.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Create a Full Text Search Typeahead With Go, jQuery, NoSQL"}]},{"@type":"WebSite","@id":"https:\/\/www.couchbase.com\/blog\/#website","url":"https:\/\/www.couchbase.com\/blog\/","name":"Blog do Couchbase","description":"Couchbase, o banco de dados NoSQL","publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.couchbase.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"pt-BR"},{"@type":"Organization","@id":"https:\/\/www.couchbase.com\/blog\/#organization","name":"Blog do Couchbase","url":"https:\/\/www.couchbase.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"pt-BR","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png","width":218,"height":34,"caption":"The Couchbase Blog"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/bb545ebe83bb2d12f91095811d0a72e1","name":"Nic Raboy, defensor dos desenvolvedores, Couchbase","image":{"@type":"ImageObject","inLanguage":"pt-BR","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/image\/8863514d8bed0cf6080f23db40e00354","url":"https:\/\/secure.gravatar.com\/avatar\/bedeb68368d4681aca4c74fe5f697f0c423b80d498ec50fd915ba018b72c101f?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/bedeb68368d4681aca4c74fe5f697f0c423b80d498ec50fd915ba018b72c101f?s=96&d=mm&r=g","caption":"Nic Raboy, Developer Advocate, Couchbase"},"description":"Nic Raboy \u00e9 um defensor das modernas tecnologias de desenvolvimento m\u00f3vel e da Web. Ele tem experi\u00eancia em Java, JavaScript, Golang e uma variedade de estruturas, como Angular, NativeScript e Apache Cordova. Nic escreve sobre suas experi\u00eancias de desenvolvimento relacionadas a tornar o desenvolvimento m\u00f3vel e da Web mais f\u00e1cil de entender.","sameAs":["https:\/\/www.thepolyglotdeveloper.com","https:\/\/www.facebook.com\/thepolyglotdeveloper","https:\/\/x.com\/nraboy"],"url":"https:\/\/www.couchbase.com\/blog\/pt\/author\/nic-raboy-2\/"}]}},"authors":[{"term_id":9032,"user_id":63,"is_guest":0,"slug":"nic-raboy-2","display_name":"Nic Raboy, Developer Advocate, Couchbase","avatar_url":"https:\/\/secure.gravatar.com\/avatar\/bedeb68368d4681aca4c74fe5f697f0c423b80d498ec50fd915ba018b72c101f?s=96&d=mm&r=g","author_category":"","last_name":"Raboy","first_name":"Nic","job_title":"","user_url":"https:\/\/www.thepolyglotdeveloper.com","description":"Nic Raboy \u00e9 um defensor das modernas tecnologias de desenvolvimento m\u00f3vel e da Web. Ele tem experi\u00eancia em Java, JavaScript, Golang e uma variedade de estruturas, como Angular, NativeScript e Apache Cordova. Nic escreve sobre suas experi\u00eancias de desenvolvimento relacionadas a tornar o desenvolvimento m\u00f3vel e da Web mais f\u00e1cil de entender."}],"_links":{"self":[{"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/posts\/5580","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/users\/63"}],"replies":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/comments?post=5580"}],"version-history":[{"count":0,"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/posts\/5580\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/media\/5582"}],"wp:attachment":[{"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/media?parent=5580"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/categories?post=5580"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/tags?post=5580"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/ppma_author?post=5580"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}