You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
var peliasQuery = require('pelias-query');
|
|
|
|
|
|
|
|
/**
|
|
|
|
Ngrams view with the additional properties to enable:
|
|
|
|
type:phrase -> tokens MUST appear in the same order in BOTH query and index
|
|
|
|
operator:and -> ALL tokens are mandatory, missing any single token will cause
|
|
|
|
a query failure.
|
|
|
|
**/
|
|
|
|
|
|
|
|
module.exports = function( vs ){
|
|
|
|
|
|
|
|
// validate required params
|
|
|
|
if( !vs.isset('phrase:slop') ){
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
var view = peliasQuery.view.ngrams( vs );
|
|
|
|
|
|
|
|
view.match['name.default'].type = 'phrase';
|
|
|
|
view.match['name.default'].operator = 'and';
|
|
|
|
view.match['name.default'].slop = vs.var('phrase:slop');
|
|
|
|
|
|
|
|
return view;
|
|
|
|
};
|