lucene-query-builder
Advanced tools
Comparing version 0.7.5 to 0.7.6
@@ -15,13 +15,7 @@ "use strict"; | ||
return '*:*'; | ||
phrase = phrase.trim(); | ||
let words = phrase.split(/\s+/); | ||
// Single word - apply fuzzy search or append wildcard | ||
if (words.length === 1) | ||
return `"${words[0]}"*`; | ||
// Multiple words - apply fuzzy and proximity search | ||
words = words.map((word) => { | ||
return word.length >= fuzzyLetters ? `${word}~${fuzzyLevel}` : word; | ||
const words = phrase.trim().split(/\s+/).map((word, index) => { | ||
return word.length >= fuzzyLetters ? `${word}~` : word; | ||
}); | ||
return `"${words.join(' ')}"~${proximity}`; | ||
return `${words.join('+')}`; | ||
}; | ||
exports.processPhrase = processPhrase; |
@@ -11,4 +11,4 @@ "use strict"; | ||
const query = ({ phrase = '', and = [], not = [], dates, options = {}, } = {}) => { | ||
const { fuzzyLetters, fuzzyLevel, urlEncoded } = options; | ||
const phraseQuery = (0, processPhrase_1.processPhrase)(phrase, { fuzzyLetters, fuzzyLevel }); | ||
const { fuzzyLetters, fuzzyLevel, urlEncoded, proximity } = options; | ||
const phraseQuery = (0, processPhrase_1.processPhrase)(phrase, { fuzzyLetters, fuzzyLevel, proximity }); | ||
const andQuery = (0, processTerms_1.processTerms)(and, 'AND'); | ||
@@ -15,0 +15,0 @@ const notQuery = (0, processTerms_1.processTerms)(not, 'NOT'); |
@@ -12,12 +12,6 @@ import { defaultValues } from '../constants/defaultValues'; | ||
return '*:*'; | ||
phrase = phrase.trim(); | ||
let words = phrase.split(/\s+/); | ||
// Single word - apply fuzzy search or append wildcard | ||
if (words.length === 1) | ||
return `"${words[0]}"*`; | ||
// Multiple words - apply fuzzy and proximity search | ||
words = words.map((word) => { | ||
return word.length >= fuzzyLetters ? `${word}~${fuzzyLevel}` : word; | ||
const words = phrase.trim().split(/\s+/).map((word, index) => { | ||
return word.length >= fuzzyLetters ? `${word}~` : word; | ||
}); | ||
return `"${words.join(' ')}"~${proximity}`; | ||
return `${words.join('+')}`; | ||
}; |
@@ -8,4 +8,4 @@ import { processPhrase } from './functions/processPhrase'; | ||
export const query = ({ phrase = '', and = [], not = [], dates, options = {}, } = {}) => { | ||
const { fuzzyLetters, fuzzyLevel, urlEncoded } = options; | ||
const phraseQuery = processPhrase(phrase, { fuzzyLetters, fuzzyLevel }); | ||
const { fuzzyLetters, fuzzyLevel, urlEncoded, proximity } = options; | ||
const phraseQuery = processPhrase(phrase, { fuzzyLetters, fuzzyLevel, proximity }); | ||
const andQuery = processTerms(and, 'AND'); | ||
@@ -12,0 +12,0 @@ const notQuery = processTerms(not, 'NOT'); |
{ | ||
"name": "lucene-query-builder", | ||
"version": "0.7.5", | ||
"version": "0.7.6", | ||
"description": "Library to build lucene queries in a typescript friendly way", | ||
@@ -5,0 +5,0 @@ "main": "lib/cjs/index.js", |
45176
868