|
@@ -19,6 +19,7 @@ function SearchClient(crowi, esUri) {
|
|
|
this.client = new elasticsearch.Client({
|
|
this.client = new elasticsearch.Client({
|
|
|
host: this.host,
|
|
host: this.host,
|
|
|
requestTimeout: 5000,
|
|
requestTimeout: 5000,
|
|
|
|
|
+ //log: 'debug',
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
this.registerUpdateEvent();
|
|
this.registerUpdateEvent();
|
|
@@ -276,7 +277,7 @@ SearchClient.prototype.search = function(query)
|
|
|
SearchClient.prototype.createSearchQuerySortedByUpdatedAt = function(option)
|
|
SearchClient.prototype.createSearchQuerySortedByUpdatedAt = function(option)
|
|
|
{
|
|
{
|
|
|
// getting path by default is almost for debug
|
|
// getting path by default is almost for debug
|
|
|
- var fields = ['path', '_id'];
|
|
|
|
|
|
|
+ var fields = ['path'];
|
|
|
if (option) {
|
|
if (option) {
|
|
|
fields = option.fields || fields;
|
|
fields = option.fields || fields;
|
|
|
}
|
|
}
|
|
@@ -286,9 +287,9 @@ SearchClient.prototype.createSearchQuerySortedByUpdatedAt = function(option)
|
|
|
index: this.index_name,
|
|
index: this.index_name,
|
|
|
type: 'pages',
|
|
type: 'pages',
|
|
|
body: {
|
|
body: {
|
|
|
- fields: fields,
|
|
|
|
|
sort: [{ updated_at: { order: 'desc'}}],
|
|
sort: [{ updated_at: { order: 'desc'}}],
|
|
|
query: {}, // query
|
|
query: {}, // query
|
|
|
|
|
+ _source: fields,
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
this.appendResultSize(query);
|
|
this.appendResultSize(query);
|
|
@@ -298,7 +299,7 @@ SearchClient.prototype.createSearchQuerySortedByUpdatedAt = function(option)
|
|
|
|
|
|
|
|
SearchClient.prototype.createSearchQuerySortedByScore = function(option)
|
|
SearchClient.prototype.createSearchQuerySortedByScore = function(option)
|
|
|
{
|
|
{
|
|
|
- var fields = ['path', '_id'];
|
|
|
|
|
|
|
+ var fields = ['path'];
|
|
|
if (option) {
|
|
if (option) {
|
|
|
fields = option.fields || fields;
|
|
fields = option.fields || fields;
|
|
|
}
|
|
}
|
|
@@ -308,9 +309,9 @@ SearchClient.prototype.createSearchQuerySortedByScore = function(option)
|
|
|
index: this.index_name,
|
|
index: this.index_name,
|
|
|
type: 'pages',
|
|
type: 'pages',
|
|
|
body: {
|
|
body: {
|
|
|
- fields: fields,
|
|
|
|
|
sort: [ {_score: { order: 'desc'} }],
|
|
sort: [ {_score: { order: 'desc'} }],
|
|
|
query: {}, // query
|
|
query: {}, // query
|
|
|
|
|
+ _source: fields,
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
this.appendResultSize(query);
|
|
this.appendResultSize(query);
|
|
@@ -338,9 +339,12 @@ SearchClient.prototype.appendCriteriaForKeywordContains = function(query, keywor
|
|
|
query.body.query.bool.must.push({
|
|
query.body.query.bool.must.push({
|
|
|
multi_match: {
|
|
multi_match: {
|
|
|
query: keyword,
|
|
query: keyword,
|
|
|
|
|
+ // TODO: By user's i18n setting, change boost or search target fields
|
|
|
fields: [
|
|
fields: [
|
|
|
- "path.ja^2", // ためしに。
|
|
|
|
|
- "body.ja"
|
|
|
|
|
|
|
+ "path_ja^2",
|
|
|
|
|
+ "body_ja",
|
|
|
|
|
+ // "path_en",
|
|
|
|
|
+ // "body_en",
|
|
|
],
|
|
],
|
|
|
operator: "and"
|
|
operator: "and"
|
|
|
}
|
|
}
|