102 lines
3.5 KiB
JavaScript
102 lines
3.5 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
// Demo script showing different ODMDB query types with real data
|
|
import fs from "node:fs";
|
|
|
|
console.log("🚀 ODMDB NL to Query Demo");
|
|
console.log("=".repeat(50));
|
|
|
|
// Sample queries to demonstrate
|
|
const queries = [
|
|
{
|
|
nl: "show me seekers with status startasap and their email and experience",
|
|
description: "Status-based filtering with field selection",
|
|
expectedCondition: "idx.seekstatus_alias(startasap)",
|
|
expectedFields: ["email", "seekworkingyear"],
|
|
},
|
|
{
|
|
nl: "find seekers looking for jobs urgently with salary expectations",
|
|
description: "Status synonym mapping + salary field",
|
|
expectedCondition: "idx.seekstatus_alias(startasap)",
|
|
expectedFields: ["salaryexpectation", "salaryunit"],
|
|
},
|
|
{
|
|
nl: "give me seekers from last month with their locations",
|
|
description: "Date-based filtering + location fields",
|
|
expectedCondition: "prop.dt_create(>=:2025-09-14)",
|
|
expectedFields: ["seeklocation"],
|
|
},
|
|
];
|
|
|
|
console.log("📋 Demo Queries:");
|
|
queries.forEach((query, i) => {
|
|
console.log(`\n${i + 1}. "${query.nl}"`);
|
|
console.log(` Purpose: ${query.description}`);
|
|
console.log(` Expected DSL: ${query.expectedCondition}`);
|
|
console.log(` Expected Fields: ${query.expectedFields.join(", ")}`);
|
|
});
|
|
|
|
console.log("\n💡 To test these queries:");
|
|
console.log("1. Edit the NL_QUERY constant in poc.js");
|
|
console.log("2. Run: EXECUTE_QUERY=true npm start");
|
|
|
|
console.log("\n📊 Current ODMDB Status:");
|
|
|
|
// Check if ODMDB data is accessible
|
|
const seekersPath = "../smatchitObjectOdmdb/objects/seekers/itm";
|
|
try {
|
|
if (fs.existsSync(seekersPath)) {
|
|
const files = fs
|
|
.readdirSync(seekersPath)
|
|
.filter((f) => f.endsWith(".json") && f !== "backup");
|
|
console.log(`✅ Found ${files.length} seeker files in ${seekersPath}`);
|
|
|
|
// Sample a few files to show data types
|
|
const sampleFile = files[0];
|
|
const sampleData = JSON.parse(
|
|
fs.readFileSync(`${seekersPath}/${sampleFile}`, "utf-8")
|
|
);
|
|
console.log(`📄 Sample seeker data (${sampleFile}):`);
|
|
console.log(` - alias: ${sampleData.alias}`);
|
|
console.log(` - email: ${sampleData.email}`);
|
|
console.log(` - seekstatus: ${sampleData.seekstatus}`);
|
|
console.log(` - seekworkingyear: ${sampleData.seekworkingyear}`);
|
|
console.log(` - dt_create: ${sampleData.dt_create}`);
|
|
} else {
|
|
console.log(`❌ ODMDB data not found at ${seekersPath}`);
|
|
}
|
|
} catch (error) {
|
|
console.log(`❌ Error accessing ODMDB data: ${error.message}`);
|
|
}
|
|
|
|
const schemaPath = "../smatchitObjectOdmdb/schema/seekers.json";
|
|
try {
|
|
if (fs.existsSync(schemaPath)) {
|
|
const schema = JSON.parse(fs.readFileSync(schemaPath, "utf-8"));
|
|
const fieldCount = Object.keys(schema.properties || {}).length;
|
|
console.log(`✅ Loaded seekers schema with ${fieldCount} properties`);
|
|
|
|
// Show access rights info
|
|
if (schema.apxaccessrights?.recruiters?.R) {
|
|
console.log(
|
|
`📋 Recruiter-readable fields: ${schema.apxaccessrights.recruiters.R.slice(
|
|
0,
|
|
5
|
|
).join(", ")}... (${schema.apxaccessrights.recruiters.R.length} total)`
|
|
);
|
|
}
|
|
|
|
// Show available indexes
|
|
if (schema.apxidx) {
|
|
const indexes = schema.apxidx.map((idx) => idx.name);
|
|
console.log(`🔍 Available indexes: ${indexes.join(", ")}`);
|
|
}
|
|
} else {
|
|
console.log(`❌ Schema not found at ${schemaPath}`);
|
|
}
|
|
} catch (error) {
|
|
console.log(`❌ Error loading schema: ${error.message}`);
|
|
}
|
|
|
|
console.log("\n✅ Demo complete!");
|