temp
This commit is contained in:
13
src/data/download.ts
Normal file
13
src/data/download.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
const link = 'https://milli-benchmarks.fra1.digitaloceanspaces.com/bench/datasets/movies.json';
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
|
||||
const movieFilePath = path.join(process.cwd(),'dist', 'movies.json');
|
||||
|
||||
const download = async () => {
|
||||
const response = await fetch(link);
|
||||
const data = await response.json();
|
||||
fs.writeFileSync(movieFilePath, JSON.stringify(data));
|
||||
return data;
|
||||
};
|
||||
await download();
|
||||
1
src/get-stat-json.ts
Normal file
1
src/get-stat-json.ts
Normal file
@@ -0,0 +1 @@
|
||||
import FastGlob from 'fast-glob';
|
||||
68
src/index.ts
Normal file
68
src/index.ts
Normal file
@@ -0,0 +1,68 @@
|
||||
import { MeiliSearch } from 'meilisearch';
|
||||
// {
|
||||
// name: null,
|
||||
// description: "Movies",
|
||||
// key: "bd853c831279b8eaa0799f512e07d0aa703405790c780446c26718e2be1e814f",
|
||||
// uid: "fbb9b3d0-1d88-4386-9b84-d959a533fcc7",
|
||||
// actions: [ "documents.get", "documents.add", "search" ],
|
||||
// indexes: [ "movies" ],
|
||||
// expiresAt: "2026-01-01T00:00:00Z",
|
||||
// createdAt: "2025-05-10T15:27:31.073736Z",
|
||||
// updatedAt: "2025-05-10T15:27:31.073736Z",
|
||||
// }
|
||||
const client = new MeiliSearch({
|
||||
host: 'http://localhost:7700',
|
||||
// apiKey: 'aSampleMasterKey',
|
||||
apiKey: 'bd853c831279b8eaa0799f512e07d0aa703405790c780446c26718e2be1e814f'
|
||||
});
|
||||
const moviesIndex = client.index('movies');
|
||||
// await moviesIndex.deleteAllDocuments()
|
||||
// const searhcRes = await moviesIndex.search('American ninja "Julian makes a lucrative living as an escort to older women in the Los Angeles area"');
|
||||
const searhcRes = await moviesIndex.search('"https://image.tmdb.org/t/p/w500/zrsOgLFiFXYzleX9p3tp8eNUruk.jpg"',{
|
||||
showRankingScore: true
|
||||
});
|
||||
console.log(searhcRes);
|
||||
|
||||
// moviesIndex.getSettings().then((settings) => {
|
||||
// console.log(settings);
|
||||
// });
|
||||
|
||||
// moviesIndex.searchSimilarDocuments({
|
||||
// id: '1',
|
||||
// embedder: 'apple',
|
||||
// });
|
||||
|
||||
// moviesIndex.updateEmbedders({
|
||||
// siliconflow: {
|
||||
// source: 'ollama',
|
||||
// apiKey: 'SILICONFLOW_API_KEY',
|
||||
// url: 'https://api.siliconflow.cn/v1/embeddings',
|
||||
// model: 'BAAI/bge-m3',
|
||||
// },
|
||||
// });
|
||||
|
||||
// moviesIndex.getEmbedders().then((embedders) => {
|
||||
// console.log(embedders);
|
||||
// });
|
||||
|
||||
// client
|
||||
// .getKeys()
|
||||
// .then((keys) => {
|
||||
// console.log(keys);
|
||||
// })
|
||||
// .catch((err) => {});
|
||||
|
||||
// client.getKey('movies').then((key) => {
|
||||
// console.log(key);
|
||||
// });
|
||||
// client
|
||||
// .createKey({
|
||||
// description: 'Movies',
|
||||
// actions: ['documents.get', 'documents.add', 'search'],
|
||||
// indexes: ['movies'],
|
||||
// expiresAt: new Date('2026-01-01T00:00:00Z'),
|
||||
// })
|
||||
// .then((key) => {
|
||||
// console.log(key);
|
||||
// });
|
||||
// client.deleteKey('57d828fa84d48786c6370034c02d92dafa712f5823ac1b35ef5afc3a1ea4cadc')
|
||||
14
src/movies/add.ts
Normal file
14
src/movies/add.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { MeiliSearch } from 'meilisearch';
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
|
||||
const movieFile = fs.readFileSync(path.join(process.cwd(), 'dist','movies.json'), 'utf-8');
|
||||
const movies = JSON.parse(movieFile);
|
||||
const client = new MeiliSearch({
|
||||
host: 'http://localhost:7700',
|
||||
apiKey: 'aSampleMasterKey',
|
||||
});
|
||||
client
|
||||
.index('movies')
|
||||
.addDocuments(movies)
|
||||
.then((res) => console.log(res));
|
||||
Reference in New Issue
Block a user