Browse Source

Move query admin weights to own config file.

(config/queryAdminWeights, query/search).js
	-Move the admin-level weights defined in `query/search` into a
	config file, addressing
	332597c653 (commitcomment-10892650).
search-all-admins
Severyn Kozak 10 years ago
parent
commit
b6f0c1c797
  1. 15
      config/queryAdminWeights.js
  2. 12
      query/search.js

15
config/queryAdminWeights.js

@ -0,0 +1,15 @@
/**
* Configurable weights that influence how, for a query with an admin value
* present, a match on any given admin value affects a document's overall
* score.
*/
module.exports = {
admin0: 20,
alpha3: 20,
admin1: 10,
admin1_abbr: 10,
admin2: 5,
locality: 1,
local_admin: 1
};

12
query/search.js

@ -2,7 +2,8 @@
var logger = require('../src/logger'), var logger = require('../src/logger'),
queries = require('geopipes-elasticsearch-backend').queries, queries = require('geopipes-elasticsearch-backend').queries,
get_layers = require('../helper/layers'), get_layers = require('../helper/layers'),
sort = require('../query/sort'); sort = require('../query/sort'),
adminFieldWeights = require( '../config/queryAdminWeights' );
function generate( params ){ function generate( params ){
@ -39,15 +40,6 @@ function generate( params ){
* levels (admin0 carries more weight than locality, for instance). * levels (admin0 carries more weight than locality, for instance).
*/ */
if (params.input_admin) { if (params.input_admin) {
var adminFieldWeights = {
admin0: 20,
alpha3: 20,
admin1: 10,
admin1_abbr: 10,
admin2: 5,
locality: 1,
local_admin: 1
};
query.query.filtered.query.bool.should = Object.keys( adminFieldWeights ).map( function ( field ){ query.query.filtered.query.bool.should = Object.keys( adminFieldWeights ).map( function ( field ){
var boostFactor = adminFieldWeights[ field ]; var boostFactor = adminFieldWeights[ field ];
var shouldClause = { match: { } }; var shouldClause = { match: { } };

Loading…
Cancel
Save