Sitesearch API documentation
This search interface API documentation lists the available customizations and configurations for the JavaScript search interface. The engine uses a straightforward key/value configuration format. Make sure the parameters are set in the code block below:
<script type="text/javascript">
jQuery(window).ready(function() {
openindex.<KEY> = <VALUE>
});
</script>
Result widget options
openindex.result.defaultTitle
Default title for search results without a title field or fall-back in case no suitable title was detected.
openindex.result.defaultTitle = "No title";
openindex.result.titleLength
Maximum length for a result title before it is truncated and appended with single character ellipsis (…). A value of -1 disables length checking.
openindex.result.titleLength = 52;
openindex.result.removeFromTitle
A substring or regular expression that is to be removed from the title. It can remove common page title prefixes or suffixes.
openindex.result.removeFromTitle = "";
openindex.result.fileNameAsTitleFor
Instructs the engine to use the file name as title when the original title matches one of
the comma separated case-insensitive titles. This is especially useful if the engine extracts a
default title from PDF documents.
openindex.result.fileNameAsTitleFor = "new title,title,untitled";
openindex.result.icons
A list of possible icons for the various documents in the search result set. Each icon consists
of a key/value pair of which the value is the icon URL. The key consists of another key/value pair of
which the key is a field of the document and the value is the value for that field in the document.
The icons that matches first is selected. Only the fields lang, host, type and cat
are allowed. The icon's alt text is selected from the documents field value.
openindex.result.icons =
{
"type:text/html" : "http://www.openindex.io/img/icons/text-html.png",
"type:application/pdf" : "http://www.openindex.io/img/icons/application-pdf.png"
};
openindex.result.defaultIcon
The default icon and alt text to use. If you do not need icons to be displayed you can set both
openindex.result.icons and openindex.result.defaultIcon to false.
openindex.result.defaultIcon =
{
url : "http://www.openindex.io/img/icons/openindex-green.png",
alt : "Openindex"
};
openindex.result.loader
Loader image to display while the search request is being processed. This image is appended to the
oi-result div and has the oi-result-loader id. This is useful in cases where a search
can take longer than 500ms to complete and you want to give feedback to your users.
openindex.result.loader = "http://www.openindex.io/img/loader.gif"
openindex.result.scrollTop
Whether to scroll back up to the top of the text box after loading a new of filtered search results page. This is useful for longer result lists with a pager control at the bottom.
openindex.result.scrollTop = true
openindex.result.scrollTopOffset
The offset in pixels of the text box to scroll back to. A negative number means above the text box.
openindex.result.scrollTopOffset = -32;
openindex.result.showAddr
Whether or not to display the host name or URL. Valid values are breadcrumb, host or
url, no value disables this feature. If enabled the address will be displayed between the title and the result snippet
encapsulated in <cite> tags. The bread crumb value is taken from the microdata breadcrumb itemprop.
openindex.result.showAddr = "";
openindex.result.addrLink
Whether the displayed host name, bread crumb or URL will be clickable.
openindex.result.addrLink = false;
openindex.result.addrLength
The maximum length of the address before being truncated.
openindex.result.addrLength = 64;
openindex.result.showImage
Whether to display an automatically extracted image in the result snippet. Images can be extracted from the page's og:image tag, a Microdata image item or somewhere from the within the content. The image is clickable and the thumbnail is served from our servers. Set to false to disable.
openindex.result.showImage = true;
openindex.result.imageNoDuplicates
Whether to display duplicate images. Note, deduplication is based on URL, not image content at this time.
openindex.result.imageNoDuplicates = false;
openindex.result.imageWidth
The width of the image. Images are automatically scaled or cropped proportionally.
openindex.result.imageWidth = 100;
openindex.result.imageHeight
The height of the image. Images are automatically scaled or cropped proportionally.
openindex.result.imageHeight = 75;
openindex.result.showTimeSince
Whether to show the time since a document was indexed or published.
openindex.result.showTimeSince = true;
openindex.result.timeSinceFormat
The format to control how the time is displayed. The time is prepended to the snippet
and encapsulated in time tags.
openindex.result.timeSinceFormat = "%AMOUNT% %UNIT% ago";
openindex.result.timeSinceMapping
The mapping of time units. The value of each pair can be used for translation.
openindex.result.timeSinceMapping =
{
"now" : "now",
"today" : "today",
"yesterday" : "yesterday",
"seconds" : "seconds",
"minutes" : "minutes",
"hours" : "hours",
"days" : "days",
"weeks" : "weeks",
"months" : "months",
"years" : "years"
};
openindex.result.snippetSize
Controls the size of the result snippet. The snippet cannot be larger than 512 characters.
openindex.result.snippetSize = 192;
openindex.result.mm
Controls the Minimum-should-Match parameter. It determines, depending on the number of search keywords are present, how many terms must match before a document is returned. It defaults to more than two keywords require one less, more than five require two less, more than six requires ninety percent of the terms to match. Set to 0% if you want to support full OR-search. For full AND-search, set to 100%. There is also a more detailed description with examples.
openindex.result.mm = "2<-1 5<-2 6<90%";
openindex.result.prefetch
The number of top results to prefetch. If enabled the top results are preloaded by supporting browsers that have this feature enabled. This is a significant speed improvement for users clicking the first few results. The prefetch is a regular HTTP request and leaves a log entry in web server logs even if the user hasn't visited the web page. Keep this option disabled if you don't want skewed log entries/statistics or (slightly) higher load. A value higher than 8 is not permitted.
openindex.result.prefetch = 0;
openindex.result.dnsPrefetch
Whether to enable DNS prefetching. If enabled the DNS records of the various hosts that make up your search result are prefetched, improving speed when results are clicked. This is only useful if you have multiple hosts in your search index.
openindex.result.dnsPrefetch = false;
openindex.result.followSingleResult
With this option enabled, the user is immediately redirected to the URL of the first result when there is exactly one result.
openindex.result.followSingleResult = false;
Text input widget options
openindex.text.keydownCallback
Callback function to call when a keyDown event on the main input field occurs, the first parameter passed is the user's query and the second is the original event object. This function call is blocking, possible errors inside the callback function are caught in a try/catch block to prevent disruption of the search service. No logging is available.
openindex.text.keydownCallback = function(q, e) { alert(q + e); };
openindex.text.keyupCallback
Callback function to call when a keyUp event on the main input field occurs, the first parameter passed is the user's query and the second is the original event object. This function call is blocking, possible errors inside the callback function are caught in a try/catch block to prevent disruption of the search service. No logging is available.
openindex.text.keydownCallback = function(q, e) { alert(q + e); };
Suggest widget options
openindex.suggest.disabled
The autosuggest widget is enabled by default. The widget takes its input directly from previous search requests so it takes some time before it is populated. Set to true to disable the suggest widget.
openindex.suggest.disabled = false;
openindex.suggest.autoStyle
The autosuggest widget styles itself by default and should fit for most cases. The CSS rules are only added
if no CSS rules on .oi-suggestions and .oi-suggestion are already defined.
openindex.suggest.autoStyle = true;
openindex.suggest.development
If this feature is enabled, the suggest engine uses dummy data to populate the suggestions. Useful for front-end developers styling the search engine.
openindex.suggest.development = false;
openindex.suggest.trending
The search suggestions know if they are trending or not, based on historical data and current events. With this option enabled, new but trending suggestions can get a higher score than the usual popular suggestions. Valid values are 0 to 9 of which 0 disables trending suggestions. Higher values mean more weight to the trending score.
openindex.suggest.trending = 1;
openindex.suggest.autoFollowSuggest
The suggest widget will show none spellchecker suggestion for misspelled input or show a list of suggestions as if the spellchecker's suggestiom was typed. Set this to false to only show the spellchecked suggestion or true to show a list of suggestions.
openindex.suggest.autoFollowSuggest = false;
openindex.suggest.fuzzy
The amount of tolerated fuzzyness. If enabled, the suggest widget is more tolerant of spelling errors while typing.
openindex.suggest.fuzzy = false;
openindex.suggest.rows
Instruct the search engine to return the specified number of suggestions. The minimum number of rows is 2, the maximum is 8.
openindex.suggest.rows = 4;
openindex.suggest.showHits
Whether to show the number of hits for a suggestion. The value of this option is appended to the suggestion inside a span with class name oi-suggestion-hits. The text allows some variables in the
format %FIELD% that are replaced with their associated value. The following variables are available:
%TOTAL%an approximation of the number of results%EXACT%the exact number of results
openindex.suggest.showHits = '';
Spellcheck widget options
openindex.spell.spellcheckFollow
Spell check header text when there is a spell check suggestion and the user's query yields no results
at all. The text allows some variables in the
format %FIELD% that are replaced with their associated value. The following variables are available:
%QUERY%the search query%SUGGEST%the spelling suggestion
openindex.spell.spellcheckFollow = "Nothing found for %QUERY%, displaying results for %SUGGEST% instead.";
openindex.spell.spellcheckSuggest
Spell check header text when there is a spell check suggestion and the user's query yields more than zero results.
openindex.spell.spellcheckSuggest = "Did you mean %SUGGEST%?";
openindex.spell.autoFollowSuggest
Whether to automatically follow a spelling suggestion when there are no results for the user's search query.
openindex.spell.autoFollowSuggest = true;
Pager widget options
openindex.pager.manyResults
Header text displayed when there more results than fit one search results page. The text allows some variables in the
format %FIELD% that are replaced with their associated value. The following variables are available:
%QUERY%the search query%TOTAL%an approximation of the number of results%EXACT%the exact number of results%START%the offset of the first result in the page%END%the offset of the last result in the page%PERPAGE%the number of results per page%ELAPSED%time it took for this search request to return results
openindex.pager.manyResults = "Displaying %START% to %END% of %TOTAL% results";
openindex.pager.fewResults
Header text displayed when there are few results for the search query meaning that there are equals or less results
then the maximum length of the page. See openindex.pager.manyResults for formatting rules.
openindex.pager.fewResults = "%TOTAL% results found";
openindex.pager.oneResult
Header text displayed when is exactly on result for the search query. See openindex.pager.manyResults for formatting rules.
openindex.pager.oneResult = "Exactly one result found";
openindex.pager.noResults
Header text displayed when there are no results for the search query. See openindex.pager.manyResults for formatting rules.
openindex.pager.noResults = "No results found for %QUERY%";
openindex.pager.prevLabel
Label text displayed on the pager's previous page button.
openindex.pager.prevLabel = "« Previous";
openindex.pager.nextLabel
Label text displayed on the pager's next page button.
openindex.pager.nextLabel = "Next »";
openindex.pager.rows
Instruct the search engine to return the specified number of rows per page. Regardless of the number of rows per page, the maximum number of pages that can be paged through remains 12.
openindex.pager.rows = 10;
Type widget options
openindex.type.header
Header text for the file type faceting widget. The header and the widget are not displayed when no constraints are available for this facet.
openindex.type.header = "File type";
openindex.type.mapping
The constraint mapping for the file type faceting widget. The constraint mapping does not apply to the filter parameters in the URL.
openindex.type.mapping =
{
"text/html" : "Webpage",
"application/pdf" : "PDF Document"
};
openindex.type.pref
Instruct the search engine to prefer or boost a specific file type. Valid values are text/html and application/pdf.
Leave this parameter empty to disable type preferences.
openindex.type.pref = "text/html";
openindex.type.restrict
Instruct the search engine to always restrict the search to the specified type. Valid values are any of the available types. You cannot use the mapped values. Leave this parameter empty to disable type restriction.
openindex.type.restrict = "";
Host widget options
openindex.host.header
Header text for the host faceting widget. The header and the widget are not displayed when no constraints are available for this facet.
openindex.host.header = "Website";
openindex.host.mapping
The constraint mapping for the host faceting widget. The constraint mapping does not apply to the filter parameters in the URL.
openindex.host.mapping =
{
"www.example.org" : "Example",
"download.example.org" : "Download"
};
openindex.host.pref
Instruct the search engine to prefer or boost a specific host. Valid values is any available hosts within your subscription. Leave this parameter empty to disable host preferences.
openindex.host.pref = "";
openindex.host.restrict
Instruct the search engine to always restrict the search to the specified host. Valid values are any of the available hosts. You cannot use the mapped values. Leave this parameter empty to disable host restriction.
openindex.host.restrict = "";
Language widget options
openindex.lang.header
Header text for the language faceting widget. The header and the widget are not displayed when no constraints are available for this facet.
openindex.lang.header = "Language";
openindex.lang.mapping
The constraint mapping for the language faceting widget. The constraint mapping does not apply to the filter parameters in the URL.
openindex.lang.mapping =
{
"af":"Afrikaans",
"ar":"العربية",
"bg":"Български",
"bn":"বাংলা",
"cs":"Česky",
"da":"Dansk",
"de":"Deutsch",
"el":"Ελληνικά",
"en":"English",
"es":"Español",
"et":"Eesti",
"fa":"فارسی",
"fi":"Suomi",
"fr":"Français",
"fy":"Frysk",
"gu":"ગુજરાતી",
"he":"עברית",
"hi":"हिन्दी",
"hr":"Hrvatski",
"hu":"Magyar",
"id":"Bahasa Indonesia",
"is":"Íslenska",
"it":"Italiano",
"ja":"日本語",
"kn":"ಕನ್ನಡ",
"ko":"한국어",
"lt":"Lietuvių",
"lv":"Latviešu",
"mk":"Македонски",
"ml":"മലയാളം",
"mr":"मराठी",
"ne":"नेपाली",
"nl":"Nederlands",
"no":"Norsk (bokmål)",
"pa":"ਪੰਜਾਬੀ",
"pl":"Polski",
"pt":"Português",
"ro":"Română",
"ru":"Русский",
"sk":"Slovenčina",
"sl":"Slovenščina",
"so":"Soomaaliga",
"sq":"Shqip",
"sv":"Svenska",
"sw":"Kiswahili",
"ta":"தமிழ்",
"te":"తెలుగు",
"th":"ไทย",
"tl":"Tagalog",
"tr":"Türkçe",
"uk":"Українська",
"ur":"اردو",
"vi":"Tiếng Việt",
"zh-cn":"中文",
"zh-tw":"國語"
};
openindex.lang.pref
Instruct the search engine to prefer or boost a specific language. Valid values is any of the above ISO 639-1 language codes, navigator,
geo or auto. If the preference is navigator the engine will defer language preference
to the browser's current language settings, geo will map a list of languages to your user's current geographical
location, countries with multiple native languages are supported. For auto the engine will pick the preferred language from either source. Leave this parameter empty to
disable language preferences.
openindex.lang.pref = "";
openindex.lang.restrict
Instruct the search engine to always restrict the search to the specified language. Valid values are any of the available languages. You cannot use the mapped values. Leave this parameter empty to disable language restriction.
openindex.lang.restrict = "";
Category widget options
openindex.cat.header
Header text for the category faceting widget. The header and the widget are not displayed when no constraints are available for this facet. See the question on how to add values from HTML metadata.
openindex.cat.header = "Category";
openindex.cat.mapping
The constraint mapping for the category faceting widget. The constraint mapping does not apply to the filter parameters in the URL. Mapping the category facet is usually not needed as the proper values are already defined in your search service, if you have enabled it. It can, however, be used to quickly rename an already configured category name without having to reindex the whole website.
openindex.cat.mapping =
{
"Category A" : "Some other category",
"Some website section" : "Renamed section"
};
openindex.cat.pref
Instruct the search engine to prefer or boost a specific category. Valid values is any available category defined within your subscription. Leave this parameter empty to disable category preferences.
openindex.cat.pref = "";
openindex.cat.restrict
Instruct the search engine to always restrict the search to the category. Valid values are any of the available categories. You cannot use the mapped values. Leave this parameter empty to disable category restriction.
openindex.cat.restrict = "";
Date range widget options
openindex.date.header
Header text for the date faceting widget. The header and the widget are not displayed when no constraints are available for this facet.
openindex.date.header = "Period";
openindex.date.mapping
The constraint mapping for the date faceting widget. The constraint mapping does not apply to the filter parameters in the URL.
openindex.date.mapping =
{
"week" : "Week",
"today" : "Today",
"month" : "Month"
};
openindex.date.pref
Date preferences work differently than the other preference settings. Instead of preferring a static value this setting acts on the notion of recency of documents. Recent documents are boosted and older documents are punished. In this example, documents younger than 50 days are boosted, older than 50 days are punished. Set to 0 to disable it.
openindex.date.pref = 50;
openindex.date.threshold
The lower threshold for punishment of older documents. A value of 1.0 means documents older than openindex.date.pref days are not punished.
openindex.date.threshold = 0.9;
openindex.date.restrict
Instruct the search engine to always restrict the search to the date range Valid values are any of the available date ranges. You cannot use the mapped values. Leave this parameter empty to disable date restriction.
openindex.date.restrict = "";
Related query widget options
openindex.queries.header
Header text for the related queries widget. The header and the widget are not displayed when no related queries are found for the user's search terms.
openindex.queries.header = "Related queries";
Page not found widget options
openindex.notfound.text
The text to display for a 404 suggestion. %LINK% is replaced by the hyperlink of the suggested page.
openindex.notfound.text = "Is this %LINK% the page you are looking for?";
openindex.notfound.defaultText
Default text that is displayed if no suggestion for a 404 could be found.
openindex.notfound.defaultText = "Unfortunately the page you are looking for does not exist (anymore). Please <a href="https://www.openindex.io/">visit our home page</a>.";
Probability filtering
openindex.probabilities.*
Openindex sitesearch classifies web pages when they are fetched and processed from your servers. These classifications help with ordering your search results, pushing less interesting pages further down the search result set. With probability filtering, you can also force the engine to only show results that are classified within a certain range. Ranges are always between 0.0 and 1.0 inclusive, and a high probability means the engine is more confident a web page is classified correctly. In general, probabilities lower than 0.7 are less useful. Check our online data extraction tool to see what our systems think of your web pages. There are three options for probability filtering:
- thread
- signifies a forum thread / discussion page
- product
- signifies a webshop product page
- article
- signifies an article page
openindex.probabilities.thread = "[0.5 TO 1.0]";
Recommended pages widget
openindex.recommendations.mode
Mode the recommender operates in. Set to user to provide user-specific recommendations. Set to document to get only document-specific recommendations.
openindex.recommendations.mode = "user";
openindex.recommendations.excludeRecentlyViewed
If enabled, recently viewed pages are not recommended to the user. This can, in some cases, cause no recommendations to be presented at all.
openindex.recommendations.excludeRecentlyViewed = true;
Related pages widget
openindex.related.sourceSelector
This parameter can contain a jQuery selector. By default, the currently viewing document is used as the source for the related pages
openindex.related.sourceSelector = null;
Miscellaneous options
openindex.recordViews
Page views are registered by default and view time is measured. Recording views is required for both topical widgets, the popular and trending page widgets. Recording views also allows to come up with better recommendations. If, for any reason, you do not want or need these features, set it to false to disable. We strongly advise you to use canonical URL's in your metatags to prevent duplicates. Views are not recorded on pages that have a robots=noindex metatag.
openindex.recordViews = true;
openindex.url
Contains the current URL. By setting this to a different URL, you can fool the search engine to find related items for the new URL when the engine operated in related mode.
openindex.url = "http..";
openindex.submitTo
Instruct the search engine to redirect the the specified URL upon submission of the search box. This option must contain the URL of your search results page on pages other than the main search results page.
openindex.submitTo = null;
openindex.safe
Instructs the search engine which safe search policy to employ. Valid values are low, normal, high and off.
openindex.safe = "off";
openindex.tls
Whether to use TLS/SSL for communication with the search service. By default the JavaScript engine will use the same transport as the page it is loaded on. So it will automatically use TLS on secured pages. All search queries, images and clicked outlinks will be using secure communication. Set this value to true to also use TLS on non-secured pages.
openindex.tls = false;
openindex.preCallback
Callback function to call just before a search request is executed, the parameter passed is the user's query. This function call is blocking, possible errors inside the callback function are caught in a try/catch block to prevent disruption of the search service. No logging is available.
openindex.preCallback = function(q) { alert(q); };
openindex.postCallback
Callback function to call after search request is executed, the parameter passed is the user's query. This function call is blocking, possible errors inside the callback function are caught in a try/catch block to prevent disruption of the search service. No logging is available.
openindex.postCallback = function(q) { alert(q); };
openindex.lease
The lease time for secure search. The value should be time in seconds since the UNIX epoch in UTC at which the lease expires. Enable this setting only if you have secure search enabled.
openindex.lease = -1;
openindex.hmac
The Base64 encoded string of the raw binary SHA1 HMAC. Enable this setting only if you have secure search enabled.
openindex.hmac = '';