Spaces:
Paused
Paused
Update commons/queryBuilder.js
Browse files- commons/queryBuilder.js +5 -13
commons/queryBuilder.js
CHANGED
|
@@ -7,7 +7,6 @@ const { convert } = require('lucene-query-generator');
|
|
| 7 |
module.exports = (args) => {
|
| 8 |
const query = {};
|
| 9 |
|
| 10 |
-
// Log the incoming args to see if we're getting the correct structure
|
| 11 |
console.log("Incoming arguments for queryBuilder:", args);
|
| 12 |
|
| 13 |
if (args.extra) {
|
|
@@ -20,22 +19,15 @@ module.exports = (args) => {
|
|
| 20 |
});
|
| 21 |
}
|
| 22 |
|
| 23 |
-
// Log the constructed query
|
| 24 |
console.log("Query constructed:", query);
|
| 25 |
|
| 26 |
// Generate the Lucene query using a field-focused structure
|
| 27 |
-
const
|
| 28 |
-
title: query.genre || '', // Ensure we handle the case if genre is not present
|
| 29 |
-
subject: query.genre || '',
|
| 30 |
-
description: query.genre || '',
|
| 31 |
-
collection: query.genre || '',
|
| 32 |
-
});
|
| 33 |
|
| 34 |
-
|
|
|
|
| 35 |
|
| 36 |
-
|
| 37 |
-
return `(${formattedQuery}) AND !collection:(podcasts OR radio OR uspto)`;
|
| 38 |
-
}
|
| 39 |
|
| 40 |
-
return
|
| 41 |
};
|
|
|
|
| 7 |
module.exports = (args) => {
|
| 8 |
const query = {};
|
| 9 |
|
|
|
|
| 10 |
console.log("Incoming arguments for queryBuilder:", args);
|
| 11 |
|
| 12 |
if (args.extra) {
|
|
|
|
| 19 |
});
|
| 20 |
}
|
| 21 |
|
|
|
|
| 22 |
console.log("Query constructed:", query);
|
| 23 |
|
| 24 |
// Generate the Lucene query using a field-focused structure
|
| 25 |
+
const genre = query.genre || ''; // Get the genre or empty string if not present
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
+
// Construct a more complex query based on your example
|
| 28 |
+
const formattedQuery = `((title:${genre}^100 OR salients:${genre}^50 OR subject:${genre}^25 OR description:${genre}^15 OR collection:${genre}^10 OR language:${genre}^10 OR text:${genre}^1) AND !collection:(podcasts OR radio OR uspto))`;
|
| 29 |
|
| 30 |
+
console.log("Formatted Lucene Query:", formattedQuery);
|
|
|
|
|
|
|
| 31 |
|
| 32 |
+
return formattedQuery; // Return the constructed query directly
|
| 33 |
};
|