Last active
August 11, 2018 11:42
-
-
Save victortsaitw12/89b2e327a4ed5d47bd0eeb45f367685b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function ElkfetchData(elasticsearch, coin_type) { | |
| let query_body = { | |
| "query": { | |
| "function_score": { | |
| "query": { | |
| "multi_match": { | |
| "query": coin_type, | |
| "operator": "and", | |
| "fields": ["title", "content"] | |
| } | |
| }, | |
| "functions":[ | |
| { | |
| "gauss": { | |
| "time": { | |
| "origin": "now", | |
| "scale": "6h", | |
| "offset": "6h", | |
| "decay": 0.5 | |
| } | |
| }, | |
| "weight": 10 | |
| } | |
| ] | |
| } | |
| } | |
| }; | |
| return Promise.resolve().then(() => { | |
| return elasticsearch.search({ | |
| index: 'article', | |
| type: 'article', | |
| body: query_body | |
| }); | |
| }).then(function (resp) { | |
| console.log(resp); | |
| var hits = resp.hits.hits; | |
| return hits; | |
| }).catch(err => { | |
| console.log(err.stack); | |
| return []; | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment