Sean's Blog

心之所向,身之所往。

[Elasticsearch] Function score query

By reading the official document of the Function score query, I still couldn’t get a sense of how to use it correctly. After reading through more articles written by others, here’s how I interpret it with the formula of the newly computed score:

function_score = min(score_mode(f1_score, f2_score, ...), max_boost)
_score = boost_mode(boost*query_score, function_score)

Example 1:

{
  "query": {
      "function_score": {
        "query": { "match_all": {} },
        "boost": "5",
        "random_score": {}, 
        "boost_mode": "multiply"
      }
   }
}

Score:


[Prometheus] What is the difference between rate and irate

Here are the definitions from the official document for rate() and irate(). But if you still don’t quite understand, check the examples below.

In this example, I select all the values I have recorded within the last 1 minute for all time series that have the metric name prometheus_http_requests_total and a handler label set to /metrics:

prometheus_http_requests_total{handler=”/metrics”}[1m]

Output from the Prometheus UI:

# Element
prometheus_http_requests_total{code="200",handler="/metrics",instance="localhost:9090",job="prometheus"}
# ValueHere are the definitions from the official document for rate() and irate(). But if you still don’t quite understand, check the examples below.

In this example, I select all the values I have recorded within the last 1 minute for all time series that have the metric name prometheus_http_requests_total and a handler label set to /metrics:


Useful commands for zsh

Moving the cursor

  • Ctrl+A: To move to the beginning of the current line.
  • Ctrl+E: To move to the end of the current line.

Manipulating your typing

  • Ctrl+W: To delete the word in front of the cursor.
  • Ctrl+U: To clear the entire line.
  • Ctrl+K: To clear the characters on the line after the current cursor position.

How to cherry-pick a commit from another git repository?

# Adding (as "other") the repo from we want to cherry-pick
$ git remote add other git://github.com/username/repo.git

# Fetch the "other" branch
$ git fetch other

# Cherry-pick the commit we need
$ git cherry-pick 0549522