summaryrefslogtreecommitdiff
path: root/src/pages/api/shop/searchkey.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/pages/api/shop/searchkey.js')
-rw-r--r--src/pages/api/shop/searchkey.js31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/pages/api/shop/searchkey.js b/src/pages/api/shop/searchkey.js
new file mode 100644
index 00000000..e8b535e7
--- /dev/null
+++ b/src/pages/api/shop/searchkey.js
@@ -0,0 +1,31 @@
+import axios from 'axios';
+
+export default async function handler(req, res) {
+ const { url = '', page = 1, limit = 30 } = req.query;
+
+ let offset = (page - 1) * limit;
+
+ const params = [
+ `q.op=AND`,
+ `q=keywords_s:"${url}"`,
+ `indent=true`,
+ `rows=${limit}`,
+ `start=${offset}`,
+ ];
+
+ try {
+ // let result = await axios(
+ // process.env.SOLR_HOST + `/solr/searchkey/select?` + params.join('&')
+ // );
+ let result = await axios.post(
+ process.env.SOLR_HOST + `/solr/searchkey/select`,
+ params.join('&'),
+ { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }
+ );
+
+ console.log(result.data);
+ res.status(200).json(result.data);
+ } catch (error) {
+ res.status(500).json({ error: 'Internal Server Error' });
+ }
+}