-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsearchHelper.js
More file actions
27 lines (26 loc) · 1.12 KB
/
Copy pathsearchHelper.js
File metadata and controls
27 lines (26 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
const request = require('request');
const conf = require('./config.js')
var AZURE_SEARCH_NAME = "vjpackagesearch";
var AZURE_INDEX_NAME = "temp";
var AZURE_SEARCH_KEY = "A76FC746FEA3B4E1E3FECA8DF94E97B2";
//queryString = 'https://' + searchName + '.search.windows.net/indexes/' + indexName + '/docs?api-key=' + searchKey + '&api-version=2015-02-28&';
const rootQueryString = `https://${AZURE_SEARCH_NAME}.search.windows.net/indexes/${AZURE_INDEX_NAME}/docs?api-key=${AZURE_SEARCH_KEY}&api-version=2016-09-01`
console.log('rootQuery: '+rootQueryString);
module.exports = {
searchQuery: (keyword, callback) => {
const queryString = `${rootQueryString}&search=${keyword}`;
console.log('Query String: '+rootQueryString);
request(queryString, (error, response, body) => {
if(error) {
callback(error, null);
} else {
const result = JSON.parse(body);
if(result && result.value) {
callback(null, result.value);
} else {
callback(null, null);
}
}
});
}
}