Can I access the _score for events from an elasticsearch input in logstash?


logstash is pulling data out of elasticsearch using the following query

query => '{
  "_source": false,
  "query": { 
    "function_score": {
      "query": { "query_string": { "query": "*" } },
      "random_score": {}

Is there a way to access the _score metadata that I can see when I run the query in the Console? I tried 'add_field => { "score" => "%{[@metadata][_score]}" }' and that did not work.

(Magnus Bäck) #2

Have a look at the elasticsearch input's docinfo option.

(Magnus Bäck) #3

On second thoughts I'm not sure _score is among the metadata fields that you can extract that way.

(Mark Walkom) #4

Nope, _score is calculated at query time, it's never stored in a document as a field.


@warkolm, I get that, but it is part of the data returned by elasticsearch to logstash, so logstash could have chosen to make it available.

(Mark Walkom) #6

True, please do feel free to raise a feature request against the plugin :slight_smile:

(system) #7

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.