js-solr-highlighter
Advanced tools
Comparing version 0.6.2 to 0.6.3
@@ -6,3 +6,5 @@ "use strict"; | ||
}); | ||
exports.default = highlightByQuery; | ||
exports.hasNonStopWords = hasNonStopWords; | ||
exports.highlightByQuery = highlightByQuery; | ||
exports.STOP_WORDS = void 0; | ||
@@ -14,3 +16,8 @@ var _textAnnotator = _interopRequireDefault(require("text-annotator")); | ||
const STOP_WORDS = ['a', 'an', 'and', 'are', 'as', 'at', 'be', 'but', 'by', 'for', 'if', 'in', 'into', 'is', 'it', 'no', 'not', 'of', 'on', 'or', 's', 'such', 't', 'that', 'the', 'their', 'then', 'there', 'these', 'they', 'this', 'to', 'was', 'will', 'with']; | ||
exports.STOP_WORDS = STOP_WORDS; | ||
function hasNonStopWords(string) { | ||
return STOP_WORDS.includes(string); | ||
} | ||
function highlightByQuery(query, content, options = {}) { | ||
@@ -123,3 +130,3 @@ const excludedFields = options.excludedFields === undefined ? [] : options.excludedFields; | ||
words = words.filter(word => word.length && !STOP_WORDS.includes(word.toLowerCase()) && !['AND', 'OR', 'NOT'].includes(word)); | ||
words = words.filter(word => word.length && !hasNonStopWords(word.toLowerCase()) && !['AND', 'OR', 'NOT'].includes(word)); | ||
let newContent = content; | ||
@@ -126,0 +133,0 @@ |
{ | ||
"name": "js-solr-highlighter", | ||
"version": "0.6.2", | ||
"version": "0.6.3", | ||
"description": "A JavaScript library for highlighting HTML text based on the query in the lucene/solr query syntax", | ||
@@ -5,0 +5,0 @@ "main": "build/index.js", |
33833
723