Browse Source

ensure that problematic single grams are removed from the query

pull/526/head
missinglink 9 years ago
parent
commit
979aab1ac3
  1. 15
      query/autocomplete.js
  2. 16
      query/view/pop_subquery.js

15
query/autocomplete.js

@ -74,11 +74,16 @@ function generateQuery( clean ){
// input text
vs.var( 'input:name', clean.text );
// if the input parser has run and suggested a 'parsed_text.name' to use.
if( clean.hasOwnProperty('parsed_text') && clean.parsed_text.hasOwnProperty('name') ){
// use 'parsed_text.name' instead of 'clean.text'.
vs.var( 'input:name', clean.parsed_text.name );
// if the tokenizer has run then we set 'input:name' to as the combination of the
// 'complete' tokens with the 'incomplete' tokens, the resuting array differs
// slightly from the 'input:name:tokens' array as some tokens might have been
// removed in the process; such as single grams which are not present in then
// ngrams index.
if( check.array( clean.tokens_complete ) && check.array( clean.tokens_incomplete ) ){
var combined = clean.tokens_complete.concat( clean.tokens_incomplete );
if( combined.length ){
vs.var( 'input:name', combined.join(' ') );
}
}
// focus point

16
query/view/pop_subquery.js

@ -13,21 +13,5 @@ module.exports = function( vs ){
view.match['name.default'].analyzer = vs.var('phrase:analyzer');
delete view.match['name.default'].boost;
// only use complete tokens against the phase index (where possible).
var completeTokens = vs.var('input:name:tokens_complete').get(),
incompleteTokens = vs.var('input:name:tokens_incomplete').get();
// if the tokenizer has run (autocomplete only) then we will combine the
// 'complete' tokens with the 'incomplete' tokens, the resuting array differs
// slightly from the 'input:name:tokens' array as some tokens might have been
// removed in the process; such as single grams which are not present in then
// ngrams index.
if( check.array( completeTokens ) && check.array( incompleteTokens ) ){
var combined = completeTokens.concat( incompleteTokens );
if( combined.length ){
view.match['name.default'].query = combined.join(' ');
}
}
return view;
};

Loading…
Cancel
Save