11

ElasticSearch を使用して、中心点からの距離を使用して関連性に影響を与える検索を作成しようとしています。

検索されたクエリに基づく関連性も結果に影響するようにしたいので、可能だとわかっているポイントからの距離で単純にソートしたくありません。

「コーヒー」などの検索文字列と、「38、-77」などの緯度/経度を渡して、「コーヒー」との関連性と近さの組み合わせで結果を並べ替えたいと思います。それらは「38、-77」です。

ありがとう!

4

2 に答える 2

11

The recently (0.90.4) added function_score query type adds support for ranking based on distance. This is an alternative to the custom score query type.

http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html

An example lifted from there:

"query": {
  "function_score": {
    "functions": [
      { "gauss":  { "loc":   { "origin": "51,0", "scale": "5km" }}},
    ]
  }
}

This applies a decay function (there are several) to a field ("loc") that scores against the distance from an origin given a particular scale. This is exactly what you'd want for distance ranking since it gives you a lot of flexibility to how it should rank without writing custom scripts.

于 2013-10-16T15:44:28.730 に答える
7

カスタム スコア クエリのスクリプトでdistance関数を使用して、中心点からの距離に基づいて変更できます。_score

于 2012-10-24T16:25:39.520 に答える