|
|
@@ -18,6 +18,7 @@ function SearchClient(crowi, esUri) {
|
|
|
|
|
|
this.client = new elasticsearch.Client({
|
|
|
host: this.host,
|
|
|
+ requestTimeout: 5000,
|
|
|
});
|
|
|
|
|
|
this.mappingFile = crowi.resourceDir + 'search/mappings.json';
|
|
|
@@ -94,6 +95,7 @@ SearchClient.prototype.prepareBodyForCreate = function(body, page) {
|
|
|
body: page.revision.body,
|
|
|
username: page.creator.username,
|
|
|
comment_count: page.commentCount,
|
|
|
+ bookmark_count: 0, // todo
|
|
|
like_count: page.liker.length || 0,
|
|
|
created_at: page.createdAt,
|
|
|
updated_at: page.updatedAt,
|
|
|
@@ -180,12 +182,16 @@ SearchClient.prototype.search = function(query)
|
|
|
return new Promise(function(resolve, reject) {
|
|
|
self.client.search(query)
|
|
|
.then(function(data) {
|
|
|
- var result = {};
|
|
|
- result.total = data.hits.total;
|
|
|
- result.results = data.hits.hits.length;
|
|
|
- result.data = data.hits.hits.map(function(elm) {
|
|
|
- return {_id: elm._id, _score: elm._score};
|
|
|
- });
|
|
|
+ var result = {
|
|
|
+ meta: {
|
|
|
+ took: data.took,
|
|
|
+ total: data.hits.total,
|
|
|
+ results: data.hits.hits.length,
|
|
|
+ },
|
|
|
+ data: data.hits.hits.map(function(elm) {
|
|
|
+ return {_id: elm._id, _score: elm._score};
|
|
|
+ })
|
|
|
+ };
|
|
|
|
|
|
resolve(result);
|
|
|
}).catch(function(err) {
|
|
|
@@ -260,7 +266,7 @@ SearchClient.prototype.appendCriteriaForKeywordContains = function(query, keywor
|
|
|
multi_match: {
|
|
|
query: keyword,
|
|
|
fields: [
|
|
|
- "path.ja",
|
|
|
+ "path.ja^2", // ためしに。
|
|
|
"body.ja"
|
|
|
],
|
|
|
operator: "and"
|