Remove the word 'lucene' from runLuceneQuery and buildLuceneQuery.
This commit is contained in:
parent
7761c15172
commit
bc8791e91e
|
@ -343,7 +343,7 @@
|
|||
}
|
||||
|
||||
function saveFilters(key) {
|
||||
const filters = LuceneUtils.buildLuceneQuery(tempFilters)
|
||||
const filters = LuceneUtils.buildQuery(tempFilters)
|
||||
const defKey = `${key}-def`
|
||||
onChange({ detail: filters }, key)
|
||||
// need to store the builder definition in the automation
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
exportFormat = Array.isArray(options) ? options[0]?.key : []
|
||||
}
|
||||
|
||||
$: luceneFilter = LuceneUtils.buildLuceneQuery(appliedFilters)
|
||||
$: luceneFilter = LuceneUtils.buildQuery(appliedFilters)
|
||||
$: exportOpDisplay = buildExportOpDisplay(
|
||||
sorting,
|
||||
filterDisplay,
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
// We need to manage our lucene query manually as we want to allow components
|
||||
// to extend it
|
||||
$: defaultQuery = LuceneUtils.buildLuceneQuery(filter)
|
||||
$: defaultQuery = LuceneUtils.buildQuery(filter)
|
||||
$: query = extendQuery(defaultQuery, queryExtensions)
|
||||
$: fetch = createFetch(dataSource)
|
||||
$: fetch.update({
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
// Add query extension to data provider
|
||||
$: {
|
||||
if (filters?.length) {
|
||||
const queryExtension = LuceneUtils.buildLuceneQuery(filters)
|
||||
const queryExtension = LuceneUtils.buildQuery(filters)
|
||||
addExtension?.($component.id, queryExtension)
|
||||
} else {
|
||||
removeExtension?.($component.id)
|
||||
|
|
|
@ -33,8 +33,8 @@ export const getActiveConditions = conditions => {
|
|||
value: condition.referenceValue,
|
||||
}
|
||||
|
||||
const query = LuceneUtils.buildLuceneQuery([luceneCondition])
|
||||
const result = LuceneUtils.runLuceneQuery([luceneCondition], query)
|
||||
const query = LuceneUtils.buildQuery([luceneCondition])
|
||||
const result = LuceneUtils.runQuery([luceneCondition], query)
|
||||
return result.length > 0
|
||||
})
|
||||
}
|
||||
|
|
|
@ -3,8 +3,7 @@ import { cloneDeep } from "lodash/fp"
|
|||
import { LuceneUtils } from "../utils"
|
||||
import { convertJSONSchemaToTableSchema } from "../utils/json"
|
||||
|
||||
const { buildLuceneQuery, luceneLimit, runLuceneQuery, luceneSort } =
|
||||
LuceneUtils
|
||||
const { buildQuery, luceneLimit, runQuery, luceneSort } = LuceneUtils
|
||||
|
||||
/**
|
||||
* Parent class which handles the implementation of fetching data from an
|
||||
|
@ -180,7 +179,7 @@ export default class DataFetch {
|
|||
// Build the lucene query
|
||||
let query = this.options.query
|
||||
if (!query) {
|
||||
query = buildLuceneQuery(filter)
|
||||
query = buildQuery(filter)
|
||||
}
|
||||
|
||||
// Update store
|
||||
|
@ -229,7 +228,7 @@ export default class DataFetch {
|
|||
|
||||
// If we don't support searching, do a client search
|
||||
if (!this.features.supportsSearch && clientSideSearching) {
|
||||
rows = runLuceneQuery(rows, query)
|
||||
rows = runQuery(rows, query)
|
||||
}
|
||||
|
||||
// If we don't support sorting, do a client-side sort
|
||||
|
|
|
@ -31,7 +31,7 @@ export async function searchView(
|
|||
// Enrich saved query with ephemeral query params.
|
||||
// We prevent searching on any fields that are saved as part of the query, as
|
||||
// that could let users find rows they should not be allowed to access.
|
||||
let query = dataFilters.buildLuceneQuery(view.query || [])
|
||||
let query = dataFilters.buildQuery(view.query || [])
|
||||
if (body.query) {
|
||||
// Extract existing fields
|
||||
const existingFields =
|
||||
|
|
|
@ -566,7 +566,7 @@ class GoogleSheetsIntegration implements DatasourcePlus {
|
|||
query.filters.equal[`_${GOOGLE_SHEETS_PRIMARY_KEY}`] = id
|
||||
}
|
||||
}
|
||||
let filtered = dataFilters.runLuceneQuery(rows, query.filters)
|
||||
let filtered = dataFilters.runQuery(rows, query.filters)
|
||||
if (hasFilters && query.paginate) {
|
||||
filtered = filtered.slice(offset, offset + limit)
|
||||
}
|
||||
|
|
|
@ -138,10 +138,10 @@ export const removeKeyNumbering = (key: string): string => {
|
|||
}
|
||||
|
||||
/**
|
||||
* Builds a lucene JSON query from the filter structure generated in the builder
|
||||
* Builds a JSON query from the filter structure generated in the builder
|
||||
* @param filter the builder filter structure
|
||||
*/
|
||||
export const buildLuceneQuery = (filter: SearchFilter[]) => {
|
||||
export const buildQuery = (filter: SearchFilter[]) => {
|
||||
let query: SearchFilters = {
|
||||
string: {},
|
||||
fuzzy: {},
|
||||
|
@ -260,11 +260,11 @@ export const buildLuceneQuery = (filter: SearchFilter[]) => {
|
|||
}
|
||||
|
||||
/**
|
||||
* Performs a client-side lucene search on an array of data
|
||||
* Performs a client-side search on an array of data
|
||||
* @param docs the data
|
||||
* @param query the JSON lucene query
|
||||
* @param query the JSON query
|
||||
*/
|
||||
export const runLuceneQuery = (docs: any[], query?: SearchFilters) => {
|
||||
export const runQuery = (docs: any[], query?: SearchFilters) => {
|
||||
if (!docs || !Array.isArray(docs)) {
|
||||
return []
|
||||
}
|
||||
|
|
|
@ -4,9 +4,9 @@ import {
|
|||
FieldType,
|
||||
SearchFilter,
|
||||
} from "@budibase/types"
|
||||
import { buildLuceneQuery, runLuceneQuery } from "../filters"
|
||||
import { buildQuery, runQuery } from "../filters"
|
||||
|
||||
describe("runLuceneQuery", () => {
|
||||
describe("runQuery", () => {
|
||||
const docs = [
|
||||
{
|
||||
order_id: 1,
|
||||
|
@ -70,14 +70,14 @@ describe("runLuceneQuery", () => {
|
|||
}
|
||||
|
||||
it("should return input docs if no search query is provided", () => {
|
||||
expect(runLuceneQuery(docs)).toBe(docs)
|
||||
expect(runQuery(docs)).toBe(docs)
|
||||
})
|
||||
|
||||
it("should return matching rows for equal filter", () => {
|
||||
const query = buildQuery({
|
||||
equal: { order_status: 4 },
|
||||
})
|
||||
expect(runLuceneQuery(docs, query).map(row => row.order_id)).toEqual([1, 2])
|
||||
expect(runQuery(docs, query).map(row => row.order_id)).toEqual([1, 2])
|
||||
})
|
||||
|
||||
it("should return matching row for notEqual filter", () => {
|
||||
|
@ -85,12 +85,12 @@ describe("runLuceneQuery", () => {
|
|||
notEqual: { order_status: 4 },
|
||||
})
|
||||
|
||||
expect(runLuceneQuery(docs, query).map(row => row.order_id)).toEqual([3])
|
||||
expect(runQuery(docs, query).map(row => row.order_id)).toEqual([3])
|
||||
})
|
||||
|
||||
it("should return starts with matching rows for fuzzy and string filters", () => {
|
||||
expect(
|
||||
runLuceneQuery(
|
||||
runQuery(
|
||||
docs,
|
||||
buildQuery({
|
||||
fuzzy: { description: "sm" },
|
||||
|
@ -98,7 +98,7 @@ describe("runLuceneQuery", () => {
|
|||
).map(row => row.description)
|
||||
).toEqual(["Small box"])
|
||||
expect(
|
||||
runLuceneQuery(
|
||||
runQuery(
|
||||
docs,
|
||||
buildQuery({
|
||||
string: { description: "SM" },
|
||||
|
@ -117,7 +117,7 @@ describe("runLuceneQuery", () => {
|
|||
},
|
||||
})
|
||||
|
||||
expect(runLuceneQuery(docs, query).map(row => row.order_id)).toEqual([3])
|
||||
expect(runQuery(docs, query).map(row => row.order_id)).toEqual([3])
|
||||
})
|
||||
|
||||
it("should return rows with numeric strings within a range filter", () => {
|
||||
|
@ -129,7 +129,7 @@ describe("runLuceneQuery", () => {
|
|||
},
|
||||
},
|
||||
})
|
||||
expect(runLuceneQuery(docs, query).map(row => row.order_id)).toEqual([3])
|
||||
expect(runQuery(docs, query).map(row => row.order_id)).toEqual([3])
|
||||
})
|
||||
|
||||
it("should return rows with ISO date strings within a range filter", () => {
|
||||
|
@ -142,7 +142,7 @@ describe("runLuceneQuery", () => {
|
|||
},
|
||||
})
|
||||
|
||||
expect(runLuceneQuery(docs, query).map(row => row.order_id)).toEqual([2])
|
||||
expect(runQuery(docs, query).map(row => row.order_id)).toEqual([2])
|
||||
})
|
||||
|
||||
it("should return return all docs if an invalid doc value is passed into a range filter", async () => {
|
||||
|
@ -170,7 +170,7 @@ describe("runLuceneQuery", () => {
|
|||
},
|
||||
})
|
||||
|
||||
expect(runLuceneQuery(docs, query)).toEqual(docs)
|
||||
expect(runQuery(docs, query)).toEqual(docs)
|
||||
})
|
||||
|
||||
it("should return rows with matches on empty filter", () => {
|
||||
|
@ -180,7 +180,7 @@ describe("runLuceneQuery", () => {
|
|||
},
|
||||
})
|
||||
|
||||
expect(runLuceneQuery(docs, query).map(row => row.order_id)).toEqual([1])
|
||||
expect(runQuery(docs, query).map(row => row.order_id)).toEqual([1])
|
||||
})
|
||||
|
||||
it("should return rows with matches on notEmpty filter", () => {
|
||||
|
@ -190,7 +190,7 @@ describe("runLuceneQuery", () => {
|
|||
},
|
||||
})
|
||||
|
||||
expect(runLuceneQuery(docs, query).map(row => row.order_id)).toEqual([2, 3])
|
||||
expect(runQuery(docs, query).map(row => row.order_id)).toEqual([2, 3])
|
||||
})
|
||||
|
||||
it.each([[523, 259], "523,259"])(
|
||||
|
@ -202,7 +202,7 @@ describe("runLuceneQuery", () => {
|
|||
},
|
||||
})
|
||||
|
||||
expect(runLuceneQuery(docs, query).map(row => row.customer_id)).toEqual([
|
||||
expect(runQuery(docs, query).map(row => row.customer_id)).toEqual([
|
||||
259, 523,
|
||||
])
|
||||
}
|
||||
|
@ -218,7 +218,7 @@ describe("runLuceneQuery", () => {
|
|||
contains: { description: ["box"] },
|
||||
})
|
||||
|
||||
expect(runLuceneQuery(docs, query).map(row => row.order_id)).toEqual(
|
||||
expect(runQuery(docs, query).map(row => row.order_id)).toEqual(
|
||||
expectedResult
|
||||
)
|
||||
})
|
||||
|
@ -230,7 +230,7 @@ describe("runLuceneQuery", () => {
|
|||
oneOf: { label: ["FRAGILE"] },
|
||||
})
|
||||
|
||||
expect(runLuceneQuery(docs, query).map(row => row.order_id)).toEqual([1, 2])
|
||||
expect(runQuery(docs, query).map(row => row.order_id)).toEqual([1, 2])
|
||||
})
|
||||
|
||||
it("should handle when a value is null or undefined", () => {
|
||||
|
@ -240,14 +240,14 @@ describe("runLuceneQuery", () => {
|
|||
oneOf: { label: ["FRAGILE"] },
|
||||
})
|
||||
|
||||
expect(runLuceneQuery(docs, query).map(row => row.order_id)).toEqual([2])
|
||||
expect(runQuery(docs, query).map(row => row.order_id)).toEqual([2])
|
||||
})
|
||||
})
|
||||
|
||||
describe("buildLuceneQuery", () => {
|
||||
describe("buildQuery", () => {
|
||||
it("should return a basic search query template if the input is not an array", () => {
|
||||
const filter: any = "NOT_AN_ARRAY"
|
||||
expect(buildLuceneQuery(filter)).toEqual({
|
||||
expect(buildQuery(filter)).toEqual({
|
||||
string: {},
|
||||
fuzzy: {},
|
||||
range: {},
|
||||
|
@ -277,7 +277,7 @@ describe("buildLuceneQuery", () => {
|
|||
value: "1000,1212,3400",
|
||||
},
|
||||
]
|
||||
expect(buildLuceneQuery(filter)).toEqual({
|
||||
expect(buildQuery(filter)).toEqual({
|
||||
string: {},
|
||||
fuzzy: {},
|
||||
range: {},
|
||||
|
@ -311,7 +311,7 @@ describe("buildLuceneQuery", () => {
|
|||
value: "{{ list_of_customer_ids }}",
|
||||
},
|
||||
]
|
||||
expect(buildLuceneQuery(filter)).toEqual({
|
||||
expect(buildQuery(filter)).toEqual({
|
||||
string: {},
|
||||
fuzzy: {},
|
||||
range: {},
|
||||
|
@ -351,7 +351,7 @@ describe("buildLuceneQuery", () => {
|
|||
value: "true",
|
||||
},
|
||||
]
|
||||
expect(buildLuceneQuery(filter)).toEqual({
|
||||
expect(buildQuery(filter)).toEqual({
|
||||
string: {},
|
||||
fuzzy: {},
|
||||
range: {},
|
||||
|
@ -392,7 +392,7 @@ describe("buildLuceneQuery", () => {
|
|||
value: "Large box,Heavy box,Small box",
|
||||
},
|
||||
]
|
||||
expect(buildLuceneQuery(filter)).toEqual({
|
||||
expect(buildQuery(filter)).toEqual({
|
||||
string: {},
|
||||
fuzzy: {},
|
||||
range: {},
|
||||
|
|
Loading…
Reference in New Issue