Septima.Search.ClientSearcher
Extends Septima.Search.Searcher
Enables a client to add a custom searcher to Septima Search
Options
Name | Type | Mandatory | Default value | Description |
---|---|---|---|---|
singular | string | Yes | The singular form of the object type returned by the searcher, eg "Photo" | |
plural | string | Yes | The plural form of the object type returned by the searcher, eg "Photos" | |
provider | Object | Yes | searcher The provider or the global name of the provider object (provider = window[provider]) Must implement query(query, limit) |
Examples
Usage
Example
//Create a provider object, which MUST have a query method (see signature) and MAY have a get method. If results have an id attribute the get method MUST be implemented
// provider.query(query, limit) must return
// {
// status: "ok|error",
// hits: nnn,
// results: results
// }, where
// results is an array of
// {
// title: "title ",
// description: "description",
// geometry: null|geojsonobject
// }
// or a promise of such
var provider = {
"query": function(query, limit){
var results = [];
for (var i = 0;i<limit;i++){
results.push({
title: "title " + i,
description: "description " + i,
geometry: null
});
}
var result = {status: "ok", hits: 9999, results: results};
return result;
},
// The select method is optional. The controller will NOT emit SELECT in SS if defined
"select": function(result){
//Do something with result
}
};
// Create a clientSearcher
var clientSearcher = new Septima.Search.ClientSearcher({
singular: "objekt",
plural: "objekter",
provider: provider
});
// Add the searcher to septima search
controller.addSearcher(clientSearcher);