Skip to content

Commit

Permalink
Add slop for phrase queries
Browse files Browse the repository at this point in the history
  • Loading branch information
schatzopoulos committed Jun 19, 2018
1 parent 173cc9f commit 91d2c7c
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions application/solr/searchResults.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,9 @@ const _ = require('lodash');

function getSolrParameters(params) {

params.keywords = params.keywords.trim();
params.keywords = params.queryTerms = params.keywords.trim();

// order of keywords affects score
params.queryTerms = `${params.keywords}`;
if (params.keywords !== '*:*') {
params.queryTerms += ` "${params.keywords}"`;
}
params.queryTerms = params.keywords;

// if we are searching a specific field, prepend field name
if (params.field && params.keywords !== '*:*') {
Expand Down Expand Up @@ -109,7 +105,13 @@ module.exports = {

// includes matching scores, breaks field alias
// fl: '*, score',

// queries with 2 terms or less, require all terms to match
// mm: 2,

// phrase slop; consider as phrases terms that appear up to $ps distance
ps: 2,

// expand options
expand: params.expand,
'expand.sort': 'db_id asc, db_revision_id desc',
Expand Down

0 comments on commit 91d2c7c

Please sign in to comment.