mirror of https://github.com/pelias/api.git
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.
190 lines
4.7 KiB
190 lines
4.7 KiB
|
|
var peliasQuery = require('pelias-query'), |
|
vs = new peliasQuery.Vars( peliasQuery.defaults ); |
|
|
|
module.exports = { |
|
'query': { |
|
'filtered': { |
|
'query': { |
|
'bool': { |
|
'must': [{ |
|
'match': { |
|
'name.default': { |
|
'query': '1 water st', |
|
'analyzer': 'peliasOneEdgeGram', |
|
'boost': 1 |
|
} |
|
} |
|
}], |
|
'should': [{ |
|
'match': { |
|
'phrase.default': { |
|
'query': '1 water st', |
|
'analyzer': 'peliasPhrase', |
|
'type': 'phrase', |
|
'slop': 2, |
|
'boost': 1 |
|
} |
|
} |
|
},{ |
|
'match': { |
|
'address.number': { |
|
'query': 1, |
|
'boost': vs.var('address:housenumber:boost').get(), |
|
'analyzer': vs.var('address:housenumber:analyzer').get() |
|
} |
|
} |
|
}, { |
|
'match': { |
|
'address.street': { |
|
'query': 'water st', |
|
'boost': vs.var('address:street:boost').get(), |
|
'analyzer': vs.var('address:street:analyzer').get() |
|
} |
|
} |
|
}, { |
|
'match': { |
|
'admin0': { |
|
'query': 'manhattan', |
|
'boost': vs.var('admin:admin0:boost').get(), |
|
'analyzer': vs.var('admin:admin0:analyzer').get() |
|
} |
|
} |
|
}, { |
|
'match': { |
|
'admin1': { |
|
'query': 'manhattan', |
|
'boost': vs.var('admin:admin1:boost').get(), |
|
'analyzer': vs.var('admin:admin1:analyzer').get() |
|
} |
|
} |
|
}, { |
|
'match': { |
|
'admin1_abbr': { |
|
'query': 'NY', |
|
'boost': vs.var('admin:admin1_abbr:boost').get(), |
|
'analyzer': vs.var('admin:admin1_abbr:analyzer').get() |
|
} |
|
} |
|
}, { |
|
'match': { |
|
'admin2': { |
|
'query': 'manhattan', |
|
'boost': vs.var('admin:admin2:boost').get(), |
|
'analyzer': vs.var('admin:admin2:analyzer').get() |
|
} |
|
} |
|
}, { |
|
'match': { |
|
'local_admin': { |
|
'query': 'manhattan', |
|
'boost': vs.var('admin:local_admin:boost').get(), |
|
'analyzer': vs.var('admin:local_admin:analyzer').get() |
|
} |
|
} |
|
}, { |
|
'match': { |
|
'locality': { |
|
'query': 'manhattan', |
|
'boost': vs.var('admin:locality:boost').get(), |
|
'analyzer': vs.var('admin:locality:analyzer').get() |
|
} |
|
} |
|
}, { |
|
'match': { |
|
'neighborhood': { |
|
'query': 'manhattan', |
|
'boost': vs.var('admin:neighborhood:boost').get(), |
|
'analyzer': vs.var('admin:neighborhood:analyzer').get() |
|
} |
|
} |
|
}] |
|
} |
|
}, |
|
'filter': { |
|
'bool': { |
|
'must': [] |
|
} |
|
} |
|
} |
|
}, |
|
'size': 10, |
|
'sort': [ |
|
'_score', |
|
{ |
|
'_script': { |
|
'file': 'admin_boost', |
|
'type': 'number', |
|
'order': 'desc' |
|
} |
|
}, |
|
{ |
|
'_script': { |
|
'file': 'popularity', |
|
'type': 'number', |
|
'order': 'desc' |
|
} |
|
}, |
|
{ |
|
'_script': { |
|
'file': 'population', |
|
'type': 'number', |
|
'order': 'desc' |
|
} |
|
}, |
|
{ |
|
'_script': { |
|
'params': { |
|
'weights': { |
|
'admin0': 4, |
|
'admin1': 3, |
|
'admin2': 2, |
|
'local_admin': 1, |
|
'locality': 1, |
|
'neighborhood': 1 |
|
} |
|
}, |
|
'file': 'weights', |
|
'type': 'number', |
|
'order': 'desc' |
|
} |
|
}, |
|
{ |
|
'_script': { |
|
'params': { |
|
'category_weights': { |
|
'transport:air': 2, |
|
'transport:air:aerodrome': 2, |
|
'transport:air:airport': 2 |
|
} |
|
}, |
|
'file': 'category', |
|
'type': 'number', |
|
'order': 'desc' |
|
} |
|
}, |
|
{ |
|
'_script': { |
|
'params': { |
|
'weights': { |
|
'geoname': 0, |
|
'address': 4, |
|
'osmnode': 6, |
|
'osmway': 6, |
|
'poi-address': 8, |
|
'neighborhood': 10, |
|
'local_admin': 12, |
|
'locality': 12, |
|
'admin2': 12, |
|
'admin1': 14, |
|
'admin0': 2 |
|
} |
|
}, |
|
'file': 'weights', |
|
'type': 'number', |
|
'order': 'desc' |
|
} |
|
} |
|
], |
|
'track_scores': true |
|
}; |