Skip to content

Commit

Permalink
Add maxResults option
Browse files Browse the repository at this point in the history
  • Loading branch information
zoetrope committed Oct 17, 2020
1 parent ad2c070 commit d636e1d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ add the following plugin configurations in book.json
"elasticsearch": {
"host" : "http://your-elasticsearch:9200",
"index" : "your-index",
"apiKey" : "your-apikey"
"apiKey" : "your-apikey",
"maxResult" : 30,
}
}
}
Expand Down
7 changes: 6 additions & 1 deletion assets/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ require([
if (this.config.apiKey) {
headers["Authorization"] = "ApiKey " + this.config.apiKey
}
var maxResults = 20
if (this.config.maxResults) {
maxResults = this.config.maxResults
}

return $.Deferred(defer => {
fetch(this.config.host + "/" + this.config.index + "/_search", {
Expand All @@ -37,7 +41,8 @@ require([
"fields": {
"body": {}
}
}
},
"size": maxResults
})
})
.then(response => {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "honkit-plugin-elasticsearch",
"description": "GitBook search plugin for Elasticsearch",
"main": "index.js",
"version": "0.1.0",
"version": "0.2.0",
"engines": {
"gitbook": "*"
},
Expand Down

0 comments on commit d636e1d

Please sign in to comment.