add other projects
This commit is contained in:
26
apps/studio.saladeaula.digital/app/lib/meili.ts
Normal file
26
apps/studio.saladeaula.digital/app/lib/meili.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { Meilisearch, type SearchResponse } from 'meilisearch'
|
||||
|
||||
export async function createSearch({
|
||||
query,
|
||||
filter = undefined,
|
||||
index,
|
||||
sort,
|
||||
env
|
||||
}: {
|
||||
query?: string
|
||||
filter?: string
|
||||
index: string
|
||||
sort: string[]
|
||||
env: Env
|
||||
}): Promise<SearchResponse> {
|
||||
const host = env.MEILI_HOST
|
||||
const apiKey = env.MEILI_API_KEY
|
||||
const client = new Meilisearch({ host, apiKey })
|
||||
const index_ = client.index(index)
|
||||
|
||||
return index_.search(query, {
|
||||
sort,
|
||||
filter,
|
||||
limit: 100
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user