numo-labs / taggable-searcher

:mag: Helper library to query the tag system
2 stars 0 forks source link

Perform include and exclude filtering at the elasticsearch query level #56

Closed lennym closed 8 years ago

lennym commented 8 years ago

This means that any pagination parameters will be respected irrespective of filters that were subsequently applied. By not having to iterate over the full result set in memory we might see an additional performance improvement also.

Fixes numo-labs/isearch-ui#389

lennym commented 8 years ago

Example script I used to test locally:

require('env2')('.env');

const suggest = require('./lib/suggest');

suggest({
  text: 'london',
  exclude: ['hotel']
}, (err, result) => {
  if (err) throw err;
  console.log(result.data.hits.hit.map(hit => hit.fields.tagid));
});

suggest({
  text: 'london',
  include: ['geo', 'tile']
}, (err, result) => {
  if (err) throw err;
  console.log(result.data.hits.hit.map(hit => hit.fields.tagid));
});