@orama/orama
Advanced tools
@@ -44,2 +44,30 @@ import { getFacets } from '../components/facets.js'; | ||
| uniqueDocsIDs = orama.index.search(index, term || '', orama.tokenizer, language, propertiesToSearch, params.exact || false, params.tolerance || 0, params.boost || {}, applyDefault(params.relevance), docsCount, whereFiltersIDs, threshold); | ||
| // When exact is true and we have a term, filter results to only include documents | ||
| // where the original text contains the exact search term (case-sensitive). | ||
| // This is a highly requested feature and although Orama is not case-sensitive by design, | ||
| // this is a reasonable compromise. | ||
| if (params.exact && term) { | ||
| const searchTerms = term.trim().split(/\s+/); | ||
| uniqueDocsIDs = uniqueDocsIDs.filter(([docId]) => { | ||
| const doc = orama.documentsStore.get(orama.data.docs, docId); | ||
| if (!doc) | ||
| return false; | ||
| // Check if any of the specified properties contain the exact search term | ||
| for (const prop of propertiesToSearch) { | ||
| const propValue = getPropValue(doc, prop); | ||
| if (typeof propValue === 'string') { | ||
| // Check if all search terms appear as complete words in the property value | ||
| const hasAllTerms = searchTerms.every((searchTerm) => { | ||
| // Create a regex that matches the term as a complete word (case-sensitive) | ||
| const regex = new RegExp(`\\b${escapeRegex(searchTerm)}\\b`); | ||
| return regex.test(propValue); | ||
| }); | ||
| if (hasAllTerms) { | ||
| return true; | ||
| } | ||
| } | ||
| } | ||
| return false; | ||
| }); | ||
| } | ||
| } | ||
@@ -68,2 +96,20 @@ else { | ||
| } | ||
| // Helper function to escape regex special characters | ||
| function escapeRegex(str) { | ||
| return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); | ||
| } | ||
| // Helper function to get nested property value | ||
| function getPropValue(obj, path) { | ||
| const keys = path.split('.'); | ||
| let value = obj; | ||
| for (const key of keys) { | ||
| if (value && typeof value === 'object' && key in value) { | ||
| value = value[key]; | ||
| } | ||
| else { | ||
| return undefined; | ||
| } | ||
| } | ||
| return value; | ||
| } | ||
| export function fullTextSearch(orama, params, language) { | ||
@@ -70,0 +116,0 @@ const timeStart = getNanosecondsTime(); |
@@ -49,2 +49,30 @@ "use strict"; | ||
| uniqueDocsIDs = orama.index.search(index, term || '', orama.tokenizer, language, propertiesToSearch, params.exact || false, params.tolerance || 0, params.boost || {}, applyDefault(params.relevance), docsCount, whereFiltersIDs, threshold); | ||
| // When exact is true and we have a term, filter results to only include documents | ||
| // where the original text contains the exact search term (case-sensitive). | ||
| // This is a highly requested feature and although Orama is not case-sensitive by design, | ||
| // this is a reasonable compromise. | ||
| if (params.exact && term) { | ||
| const searchTerms = term.trim().split(/\s+/); | ||
| uniqueDocsIDs = uniqueDocsIDs.filter(([docId]) => { | ||
| const doc = orama.documentsStore.get(orama.data.docs, docId); | ||
| if (!doc) | ||
| return false; | ||
| // Check if any of the specified properties contain the exact search term | ||
| for (const prop of propertiesToSearch) { | ||
| const propValue = getPropValue(doc, prop); | ||
| if (typeof propValue === 'string') { | ||
| // Check if all search terms appear as complete words in the property value | ||
| const hasAllTerms = searchTerms.every((searchTerm) => { | ||
| // Create a regex that matches the term as a complete word (case-sensitive) | ||
| const regex = new RegExp(`\\b${escapeRegex(searchTerm)}\\b`); | ||
| return regex.test(propValue); | ||
| }); | ||
| if (hasAllTerms) { | ||
| return true; | ||
| } | ||
| } | ||
| } | ||
| return false; | ||
| }); | ||
| } | ||
| } | ||
@@ -73,2 +101,20 @@ else { | ||
| } | ||
| // Helper function to escape regex special characters | ||
| function escapeRegex(str) { | ||
| return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); | ||
| } | ||
| // Helper function to get nested property value | ||
| function getPropValue(obj, path) { | ||
| const keys = path.split('.'); | ||
| let value = obj; | ||
| for (const key of keys) { | ||
| if (value && typeof value === 'object' && key in value) { | ||
| value = value[key]; | ||
| } | ||
| else { | ||
| return undefined; | ||
| } | ||
| } | ||
| return value; | ||
| } | ||
| function fullTextSearch(orama, params, language) { | ||
@@ -75,0 +121,0 @@ const timeStart = (0, utils_js_1.getNanosecondsTime)(); |
@@ -44,2 +44,30 @@ import { getFacets } from '../components/facets.js'; | ||
| uniqueDocsIDs = orama.index.search(index, term || '', orama.tokenizer, language, propertiesToSearch, params.exact || false, params.tolerance || 0, params.boost || {}, applyDefault(params.relevance), docsCount, whereFiltersIDs, threshold); | ||
| // When exact is true and we have a term, filter results to only include documents | ||
| // where the original text contains the exact search term (case-sensitive). | ||
| // This is a highly requested feature and although Orama is not case-sensitive by design, | ||
| // this is a reasonable compromise. | ||
| if (params.exact && term) { | ||
| const searchTerms = term.trim().split(/\s+/); | ||
| uniqueDocsIDs = uniqueDocsIDs.filter(([docId]) => { | ||
| const doc = orama.documentsStore.get(orama.data.docs, docId); | ||
| if (!doc) | ||
| return false; | ||
| // Check if any of the specified properties contain the exact search term | ||
| for (const prop of propertiesToSearch) { | ||
| const propValue = getPropValue(doc, prop); | ||
| if (typeof propValue === 'string') { | ||
| // Check if all search terms appear as complete words in the property value | ||
| const hasAllTerms = searchTerms.every((searchTerm) => { | ||
| // Create a regex that matches the term as a complete word (case-sensitive) | ||
| const regex = new RegExp(`\\b${escapeRegex(searchTerm)}\\b`); | ||
| return regex.test(propValue); | ||
| }); | ||
| if (hasAllTerms) { | ||
| return true; | ||
| } | ||
| } | ||
| } | ||
| return false; | ||
| }); | ||
| } | ||
| } | ||
@@ -68,2 +96,20 @@ else { | ||
| } | ||
| // Helper function to escape regex special characters | ||
| function escapeRegex(str) { | ||
| return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); | ||
| } | ||
| // Helper function to get nested property value | ||
| function getPropValue(obj, path) { | ||
| const keys = path.split('.'); | ||
| let value = obj; | ||
| for (const key of keys) { | ||
| if (value && typeof value === 'object' && key in value) { | ||
| value = value[key]; | ||
| } | ||
| else { | ||
| return undefined; | ||
| } | ||
| } | ||
| return value; | ||
| } | ||
| export function fullTextSearch(orama, params, language) { | ||
@@ -70,0 +116,0 @@ const timeStart = getNanosecondsTime(); |
@@ -44,2 +44,30 @@ import { getFacets } from '../components/facets.js'; | ||
| uniqueDocsIDs = orama.index.search(index, term || '', orama.tokenizer, language, propertiesToSearch, params.exact || false, params.tolerance || 0, params.boost || {}, applyDefault(params.relevance), docsCount, whereFiltersIDs, threshold); | ||
| // When exact is true and we have a term, filter results to only include documents | ||
| // where the original text contains the exact search term (case-sensitive). | ||
| // This is a highly requested feature and although Orama is not case-sensitive by design, | ||
| // this is a reasonable compromise. | ||
| if (params.exact && term) { | ||
| const searchTerms = term.trim().split(/\s+/); | ||
| uniqueDocsIDs = uniqueDocsIDs.filter(([docId]) => { | ||
| const doc = orama.documentsStore.get(orama.data.docs, docId); | ||
| if (!doc) | ||
| return false; | ||
| // Check if any of the specified properties contain the exact search term | ||
| for (const prop of propertiesToSearch) { | ||
| const propValue = getPropValue(doc, prop); | ||
| if (typeof propValue === 'string') { | ||
| // Check if all search terms appear as complete words in the property value | ||
| const hasAllTerms = searchTerms.every((searchTerm) => { | ||
| // Create a regex that matches the term as a complete word (case-sensitive) | ||
| const regex = new RegExp(`\\b${escapeRegex(searchTerm)}\\b`); | ||
| return regex.test(propValue); | ||
| }); | ||
| if (hasAllTerms) { | ||
| return true; | ||
| } | ||
| } | ||
| } | ||
| return false; | ||
| }); | ||
| } | ||
| } | ||
@@ -68,2 +96,20 @@ else { | ||
| } | ||
| // Helper function to escape regex special characters | ||
| function escapeRegex(str) { | ||
| return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); | ||
| } | ||
| // Helper function to get nested property value | ||
| function getPropValue(obj, path) { | ||
| const keys = path.split('.'); | ||
| let value = obj; | ||
| for (const key of keys) { | ||
| if (value && typeof value === 'object' && key in value) { | ||
| value = value[key]; | ||
| } | ||
| else { | ||
| return undefined; | ||
| } | ||
| } | ||
| return value; | ||
| } | ||
| export function fullTextSearch(orama, params, language) { | ||
@@ -70,0 +116,0 @@ const timeStart = getNanosecondsTime(); |
+3
-3
| { | ||
| "name": "@orama/orama", | ||
| "version": "3.1.14", | ||
| "version": "3.1.15", | ||
| "type": "module", | ||
@@ -144,4 +144,4 @@ "description": "A complete search engine and RAG pipeline in your browser, server, or edge network with support for full-text, vector, and hybrid search in less than 2kb.", | ||
| "typescript": "^5.0.0", | ||
| "@orama/stemmers": "3.1.14", | ||
| "@orama/stopwords": "3.1.14" | ||
| "@orama/stemmers": "3.1.15", | ||
| "@orama/stopwords": "3.1.15" | ||
| }, | ||
@@ -148,0 +148,0 @@ "engines": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
2090294
0.66%30937
0.6%