const http = require('http'),
qs = require('querystring');
var Suggest = exports;
Suggest.search = function (keyword) {
var data = {
qt: 'suggest',
'suggest.dictionary': 'mySuggester',
'wt': 'json',
'suggest.q': keyword
};
var content = qs.stringify(data);
var options = {
hostname: '127.0.0.1',
port: 8080,
path: '/solr/metis/suggest?' + content,
method: 'GET'
};
var result = [];
var promise = new Promise(function (resolve, reject) {
var req = http.request(options, function (res) {
res.on('data', function (chunk) {
result = convert(keyword, chunk);
resolve(result);
});
});
req.on('error', function (e) {
reject(new Error(e.message));
});
req.end();
});
return promise;
};
function convert(keyword, data) {
var result = [];
var json = JSON.parse(String(data));
var num = parseInt(json.suggest.mySuggester[keyword].numFound);
if (num > 0) {
var matcher = new RegExp("^[A-Za-z0-9]+$", "i");
var tmp = json.suggest.mySuggester[keyword].suggestions;
for (var i = 0; i < tmp.length; i++) {
var d = tmp[i]['term'].split('\|');
if (matcher.test(d[0])) {
var obj = {
label: d[0],
value: d[1]
};
result.push(obj);
} else {
result.push(d[0]);
}
}
}
return result;
}
1 svn回退版本
1)在window中选择log,根据想要回退的内容,选择revert this version或revert chanages from this version
两者的区别:
revert this version:表示回退到当前版本(该版本后的版本全部作废)
revert chanages from this versio
<!--javascript取当月最后一天-->
<script language=javascript>
var current = new Date();
var year = current.getYear();
var month = current.getMonth();
showMonthLastDay(year, mont
public class MyStack {
private long[] arr;
private int top;
public MyStack() {
arr = new long[10];
top = -1;
}
public MyStack(int maxsize) {
arr = new long[maxsize];
top
Binary search needs an ordered array so that it can use array indexing to dramatically reduce the number of compares required for each search, using the classic and venerable binary search algori