ElasticSearch を使用して、中心点からの距離を使用して関連性に影響を与える検索を作成しようとしています。
検索されたクエリに基づく関連性も結果に影響するようにしたいので、可能だとわかっているポイントからの距離で単純にソートしたくありません。
「コーヒー」などの検索文字列と、「38、-77」などの緯度/経度を渡して、「コーヒー」との関連性と近さの組み合わせで結果を並べ替えたいと思います。それらは「38、-77」です。
ありがとう!
ElasticSearch を使用して、中心点からの距離を使用して関連性に影響を与える検索を作成しようとしています。
検索されたクエリに基づく関連性も結果に影響するようにしたいので、可能だとわかっているポイントからの距離で単純にソートしたくありません。
「コーヒー」などの検索文字列と、「38、-77」などの緯度/経度を渡して、「コーヒー」との関連性と近さの組み合わせで結果を並べ替えたいと思います。それらは「38、-77」です。
ありがとう!
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.
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.
カスタム スコア クエリのスクリプトでdistance
関数を使用して、中心点からの距離に基づいて変更できます。_score