How to use pelias-schema - 1 common examples

To help you get started, we’ve selected a few pelias-schema examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pelias / api / query / view / temp_ngrams_strip_housenumbers.js View on Github external
It is intended to strip housenumbers from input text BUT
  should only apply to the ngrams analysis and not affect
  the other textual analysis.
  eg: 'phrase' matching should still include the housenumber

  This file can go away once the peliasOneEdgeGram and peliasTwoEdgeGram
  analysers have been modified in pelias/schema, but as would require
  a full re-index and (potentially) break backwards compatibily with the
  v0 legacy codebase it, unfortunately, has to wait until that legacy
  service has been fully decomissioned.
**/

var _ = require('lodash'),
    peliasQuery = require('pelias-query'),
    stopWords = require('pelias-schema/street_suffix').terms;

module.exports = function( vs ){

  // clone the $vs so we can modify this copy without
  // mutating the 'actual' query variables which get shared
  // with the other views.
  var vsClone = new peliasQuery.Vars( vs.export() );

  // set 'input:name' to the result of removeHouseNumber($name);
  if( vsClone.isset('input:name') ){
    var nameVar = vsClone.var('input:name');
    nameVar.set( removeHouseNumber( nameVar.get() ) );
  }

  // run the original ngram view but with the modified input:name' var
  return peliasQuery.view.ngrams( vsClone );

pelias-schema

Elasticsearch schema files and tooling for Pelias

MIT
Latest version published 3 months ago

Package Health Score

61 / 100
Full package analysis

Popular pelias-schema functions