This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"time" | |
) | |
func main() { | |
queue := make(chan int, 5) // buffer up to 5 items to be processed | |
done := make(chan bool) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h3>Search Box in your nav</h3> | |
<p>Once installed on your site, searching from this search box will take you to your search page at /GSASearch.aspx.</p> | |
<!-- 1. Add to global navigation to create a global search box --> | |
<div id="nav-search-box"></div> | |
<!-- 1. Add to global navigation to create a global search box --> | |
<hr> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h3>Nav autosuggest box</h3> | |
<div id="nav-search-box"></div> | |
<hr> | |
<h3>Results Page</h3> | |
<div id="results-search-box"></div> | |
<div id="results-search-response"></div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Step 1: global search box | |
// Put into main template (all pages) | |
// Assumes ID of search box will remain unchanged: CT_Header_0_ctl01_txtSearch | |
var getUrlParam = function(e){var t = new RegExp("[?&]" + e.replace(/[\[\]]/g, "\\$&") + "(=([^&#]*)|&|#|$)"),a = t.exec(window.location.href);return a && a[2] ? decodeURIComponent(a[2].replace(/\+/g, " ")) : ""}; | |
var setup = function(w,d,x,a,e,s,c,r){s = [];var b=function(){s.push(arguments);},q="ui";b.arr=s;w[a]=w[a]||[];w[a][q]=w[a][q]||[];w[a][q].push(b);c=d.createElement(x);c.async=1;c.src=e;r=d.getElementsByTagName(x)[0];r.parentNode.insertBefore(c,r);return b;}; | |
var searchBox = setup(window, document, "script", "sajari", "//cdn.sajari.net/js/integrations/website-search-1.4.js"); | |
searchBox({ | |
mode: "search-box", | |
project: "1520368576952702052", // Set this to your project. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1. Assumes the following div exists in the page, note: you can change this using the "attachDynamicContent" setting | |
// <div id="dynamic-content"></div> | |
// 2. The "pipeline" parameter controls the query execution, this example uses "popular", this is configurable | |
// 3. The "values" map controls the query. You don't need the "q" parameter, but can use this to control the context of | |
// the results. For example you may wish to use the "document.title" to find related content to the current page | |
// 4. The filter parameter allows any number of filters to be used to filter the query results, e.g. to domains, or sections, | |
// or any other number of factors | |
var recommend = setup(window, document, "script", "sajari", "//cdn.sajari.net/js/integrations/website-search-1.4.js"); | |
recommend({ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func (term *Term) Encode(version string) []byte { | |
builder := flatbuffers.NewBuilder(0) | |
// Preprocess the shotguns | |
shotguns := make([]flatbuffers.UOffsetT, len(term.Shotgun)) | |
shotgunStrs := make([]flatbuffers.UOffsetT, len(term.Shotgun)) | |
for i := 0; i < len(term.Shotgun); i++ { | |
shotgunStrs[i] = builder.CreateString(term.Shotgun[i].Term) | |
} | |
for i := 0; i < len(term.Shotgun); i++ { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
/* | |
#cgo CFLAGS: -O3 | |
#include <stdio.h> | |
#include <stdint.h> | |
#include <stdlib.h> | |
#define SJ_REV_BUCKET_SIZE 10000 // The maximum number of terms that the bucket can hold |