Closed woonjjang closed 3 years ago
[검색 JS를 사용한다. ]
[검색엔진 elastic-search ]
[검색엔진 typesense-search ]
[검색 JS를 사용한다. ]
- 현재버전
- fuseJS
[검색엔진 elastic-search ]
- hugo에 https://bonsai.io/ 를 붙여보려고 하다가, AWS 세팅하고, elastic 띄워주고 돈받는 것 같아서 ~
- https://db-engines.com/en/ranking/search+engine
- https://www.elastic.co/kr | - https://www.elastic.co/kr/downloads/elasticsearch | - Free Trial 시작해서, 사이트 긁고, indexing 완료
[검색엔진 typesense-search ]
- https://typesense.org
- https://github.com/typesense/showcase-ecommerce-store -> 이 정도만 구성되도, 초기 이슈는 없을 것으로 보임.
- https://ecommerce-store.typesense.org/
@suncrud
{
"name": "books",
"fields": [
{"name": "title", "type": "string" },
{"name": "author", "type": "string[]", "facet": true },
{"name": "ratings", "type": "int32" }
],
"default_sorting_field": "ratings"
}
모델 설계
[진행]
[typesense - server]
indexing 하는 js - populateTypesenseIndex.js
require('dotenv').config();
const Typesense = require("typesense");
module.exports = (async () => {
// Create a client
const typesense = new Typesense.Client({
nodes: [
{
host: process.env.TYPESENSE_HOST,
port: process.env.TYPESENSE_PORT,
protocol: process.env.TYPESENSE_PROTOCOL
}
],
apiKey: process.env.TYPESENSE_ADMIN_API_KEY
});
const schema = {
name: "items",
num_documents: 0,
fields: [
{
name: "reference_code",
type: "string",
facet: false
},
{
name: "rg",
type: "string",
facet: false
},
{
name: "weight",
type: "string",
facet: false
},
{
name: "series",
type: "string",
facet: false
},
{
name: "file",
type: "string",
facet: false
},
{
name: "file_number",
type: "string",
facet: false
},
{
name: "local_identifier",
type: "string",
facet: false
},
{
name: "date",
type: "string",
facet: false
},
{
name: "creators",
type: "string",
facet: true
},
{
name: "sources",
type: "string",
facet: true
},
{
name: "venues",
type: "string",
facet: true
},
{
name: "title",
type: "string",
facet: false
},
{
name: "description",
type: "string",
facet: false
},
{
name: "shotlist",
type: "string",
facet: false
},
{
name: "link",
type: "string",
facet: false
},
{
name: "components",
type: "string",
facet: false
},
{
name: "media_type",
type: "string",
facet: true
},
],
};
console.log("Populating index in Typesense");
const items = require("./data/items.json");
let reindexNeeded = false;
try {
const collection = await typesense.collections("items").retrieve();
console.log("Found existing schema");
// console.log(JSON.stringify(collection, null, 2));
if (
collection.num_documents !== items.length ||
process.env.FORCE_REINDEX === "true"
) {
console.log("Deleting existing schema");
reindexNeeded = true;
await typesense.collections("items").delete();
}
} catch (e) {
reindexNeeded = true;
}
if (!reindexNeeded) {
return true;
}
console.log("Creating schema: ");
console.log(JSON.stringify(schema, null, 2));
await typesense.collections().create(schema);
// const collectionRetrieved = await typesense
// .collections("items")
// .retrieve();
// console.log("Retrieving created schema: ");
// console.log(JSON.stringify(collectionRetrieved, null, 2));
console.log("Adding records: ");
// Bulk Import
try {
const returnData = await typesense
.collections("items")
.documents()
.import(items);
console.log(returnData);
console.log("Done indexing.");
const failedItems = returnData.filter(item => item.success === false);
if (failedItems.length > 0) {
throw new Error(
`Error indexing items ${JSON.stringify(failedItems, null, 2)}`
);
}
return returnData;
} catch (error) {
console.log(error);
}
})();
[Contents Params]
[Taxonomy Term]
[Sources Type/Media Type]
방법은 아직 모르겠음. 검색 파라미터부터 확인 CCWSP에서는 이런 검색을 결국 원할 것 같음.