diff --git a/controller/search.js b/controller/search.js index bf4cf75fd..b5657a7f6 100644 --- a/controller/search.js +++ b/controller/search.js @@ -1,9 +1,6 @@ const _ = require('lodash'); -const querystring = require('querystring'); - -const logger = require('pelias-logger').get('api'); - const searchService = require('../service/search'); +const logger = require('pelias-logger').get('api'); const logging = require( '../helper/logging' ); const retry = require('retry'); const Debug = require('../helper/debug'); @@ -136,25 +133,6 @@ function setup( peliasConfig, esclient, query, should_execute ){ // be results. if there are no results from this ES call, don't overwrite // what's already there from a previous call. if (!_.isEmpty(docs)) { - if (req.clean.exposeInternalDebugTools && req.clean.enableDebug) { - - // Add an ES explain link to each document - docs.forEach((doc) => { - const docDebugInfo = {}; - if (req.headers.host) { - const requestPath = `${req.path}?${ querystring.stringify({ - ...req.query, - restrictIds: doc._id, - debug: 'explain' - }) }`; - - docDebugInfo.esExplainUrl = `${ req.secure ? 'https' : 'http' }://${req.headers.host}${requestPath}`; - } - - doc.debug = [docDebugInfo]; - }); - } - res.data = docs; res.meta = meta || {}; // store the query_type for subsequent middleware diff --git a/query/autocomplete_defaults.js b/query/autocomplete_defaults.js index 1350a215b..6708cd831 100644 --- a/query/autocomplete_defaults.js +++ b/query/autocomplete_defaults.js @@ -27,6 +27,7 @@ module.exports = _.merge({}, peliasQuery.defaults, { 'phrase:boost': 1, 'phrase:slop': 3, 'phrase:cutoff_frequency': 0.01, + 'phrase:minimum_should_match': '1<-1 3<-50%', 'focus:function': 'exp', 'focus:offset': '0km', diff --git a/query/view/phrase_first_all_tokens_only.js b/query/view/phrase_first_all_tokens_only.js index b58f42484..57920c72b 100644 --- a/query/view/phrase_first_all_tokens_only.js +++ b/query/view/phrase_first_all_tokens_only.js @@ -3,33 +3,34 @@ const toMultiFields = require('./helper').toMultiFields; const _ = require('lodash'); module.exports = function (vs) { - console.log(vs.var('input:name:raw_tokens').get(), vs.var('input:name:tokens').get()); - console.log(_.eq(vs.var('input:name:raw_tokens').get(), vs.var('input:name:tokens').get())); - console.log(vs.var('input:name:raw_tokens').get() === vs.var('input:name:tokens').get()); - if (vs.var('input:name:raw_tokens').get().length === vs.var('input:name:tokens').get().length) { + const view_name = 'first_all_tokens_only'; + // get a copy of the *complete* tokens produced from the input:name + const raw_complete_tokens = vs.var('input:name:raw_tokens_complete').get(); + + // if the parsed tokens (what's going to be searched in the must), are the same as the raw tokens + // don't use this query since it will be redundant + if (raw_complete_tokens.length === vs.var('input:name:tokens').get().length) { + return null; + } + + // if there's a housenumber and a street, don't do this because it might + // make housenumber matching way too lenient + if (vs.isset('input:housenumber') && vs.isset('input:street')) { return null; } - const view_name = 'first_all_tokens_only'; - // get a copy of the *complete* tokens produced from the input:name - console.log(vs.var('input:name:raw_tokens').get()); - const tokens = vs.var('input:name:raw_tokens_complete').get(); - console.log('all tokens only', { tokens }); // no valid tokens to use, fail now, don't render this view. - if (!tokens || tokens.length < 1) { + if (!raw_complete_tokens || raw_complete_tokens.length < 1) { return null; } // set the 'input' variable to all but the last token - vs.var(`match:${view_name}:input`).set(tokens.join(' ')); + vs.var(`match:${view_name}:input`).set(raw_complete_tokens.join(' ')); vs.var(`match:${view_name}:field`).set(vs.var('phrase:field').get()); vs.var(`match:${view_name}:analyzer`).set(vs.var('phrase:analyzer').get()); - vs.var(`match:${view_name}:boost`).set(vs.var('phrase:boost').get()); - - // vs.var(`match:${view_name}:minimum_should_match`).set(vs.var('ngram:minimum_should_match').get()); - vs.var(`match:${view_name}:minimum_should_match`).set('1<-1 3<-25%'); + vs.var(`match:${view_name}:minimum_should_match`).set(vs.var('phrase:minimum_should_match').get()); return peliasQuery.view.leaf.match(view_name)(vs); }; diff --git a/sanitizer/_debug.js b/sanitizer/_debug.js index 4666bce90..673540d36 100644 --- a/sanitizer/_debug.js +++ b/sanitizer/_debug.js @@ -50,14 +50,6 @@ function _setup(exposeInternalDebugTools) { } } - if (raw.restrictIds) { - if (exposeInternalDebugTools) { - clean.restrictIds = raw.restrictIds.split(','); - } else { - messages.errors.push('restrictIds not enabled, must enable exposeInternalDebugTools in pelias config'); - } - } - return messages; },