0Pricing
Elasticsearch & Full Text Search Systems · Ders

Coğrafi Konum Arama Yetenekleri

Konum tabanlı aramalar, yakınlık sorguları ve coğrafi konum toplamaları gerçekleştirmek için coğrafi nokta ve coğrafi şekil eşlemelerini uygulayın.

Coğrafi Konum Arama Yetenekleri, CoddyKit'te ücretsiz bir Elasticsearch & Full Text Search Systems dersidir. Bu, 4 dersinin 1. dersidir. Aşağıdan dersin tamamını ücretsiz okuyabilir, sonra tarayıcıda yerleşik kod editörü ve 7/24 yapay zeka koçu ile uygulamalı olarak pratik yapabilirsin. Bu, Elasticsearch & Full Text Search Systems öğrenme yolunun bir parçasıdır ve ilerlemeniz web ve CoddyKit uygulaması arasında senkronize olur. Elasticsearch & Full Text Search Systems kursu toplamda 4 dersten oluşur.

Bu dersin bazı bölümleri henüz çevrilmemiş olup İngilizce olarak gösterilmektedir.

Location-Aware Search

Welcome to Geospatial Search! Many modern applications rely on location data, from finding nearby restaurants to tracking delivery vehicles.

Elasticsearch provides powerful features to index, search, and analyze geographic information efficiently.

The `geo_point` Field

The most common way to store a single geographical location in Elasticsearch is using the geo_point data type.

It represents a specific point on Earth using its latitude and longitude coordinates.

  • Latitude: North-South position (e.g., 48.8584)
  • Longitude: East-West position (e.g., 2.2945)

Mapping `geo_point` Data

Before indexing documents with location data, you need to define a geo_point field in your index mapping. This tells Elasticsearch how to interpret the coordinates.

Try setting up an index named places with a location field of type geo_point:

curl -X PUT "localhost:9200/places?pretty" -H 'Content-Type: application/json' -d'
{
  "mappings": {
    "properties": {
      "location": {
        "type": "geo_point"
      },
      "name": {
        "type": "text"
      }
    }
  }
}'

Adding Geo-Tagged Documents

Now that our places index is mapped, we can index documents containing geo_point data. The location field can accept an object with lat and lon properties.

Index the Eiffel Tower's location:

curl -X PUT "localhost:9200/places/_doc/1?pretty" -H 'Content-Type: application/json' -d'
{
  "name": "Eiffel Tower",
  "location": {
    "lat": 48.8584,
    "lon": 2.2945
  }
}'

Searching by Distance: `geo_distance`

One of the most common geospatial queries is finding documents within a certain radius of a central point. This is achieved using the geo_distance query.

You specify a distance and the reference point, and Elasticsearch returns all matching documents.

`geo_distance` Query Example

Let's find all places within 5 kilometers of the Eiffel Tower's coordinates. This query is perfect for 'find restaurants near me' features.

Run this query:

curl -X GET "localhost:9200/places/_search?pretty" -H 'Content-Type: application/json' -d'
{
  "query": {
    "geo_distance": {
      "distance": "5km",
      "location": {
        "lat": 48.8584,
        "lon": 2.2945
      }
    }
  }
}'

Bounding Box Search (`geo_bounding_box`)

Another useful query is geo_bounding_box, which allows you to find all documents whose geo_point falls within a specified rectangular area.

You define the box by providing its top_left and bottom_right coordinates.

`geo_bounding_box` Query Example

Imagine you have a map view and only want to show results within the current screen. A geo_bounding_box query is ideal for this scenario.

Here's an example searching within a small area around Paris:

curl -X GET "localhost:9200/places/_search?pretty" -H 'Content-Type: application/json' -d'
{
  "query": {
    "geo_bounding_box": {
      "location": {
        "top_left": {
          "lat": 49,
          "lon": 2
        },
        "bottom_right": {
          "lat": 48,
          "lon": 3
        }
      }
    }
  }
}'

Beyond Points: `geo_shape`

While geo_point is great for single locations, what if you need to represent complex geometries like a park boundary, a river, or a country's outline?

For this, Elasticsearch offers the geo_shape data type, which supports various GeoJSON shapes (polygons, lines, multi-points, etc.).

`geo_shape` Mapping & Indexing

To use geo_shape, you first map the field as geo_shape. Then, you can index documents with complex geometries, typically in GeoJSON format. Here's how to map and index a simple polygon representing a district:

curl -X PUT "localhost:9200/regions?pretty" -H 'Content-Type: application/json' -d'
{
  "mappings": {
    "properties": {
      "area": {
        "type": "geo_shape"
      },
      "name": {
        "type": "keyword"
      }
    }
  }
}'

curl -X PUT "localhost:9200/regions/_doc/1?pretty" -H 'Content-Type: application/json' -d'
{
  "name": "Paris District",
  "area": {
    "type": "polygon",
    "coordinates": [
      [
        [2.2, 48.8],
        [2.3, 48.8],
        [2.3, 48.9],
        [2.2, 48.9],
        [2.2, 48.8]
      ]
    ]
  }
}'

Geo Query Challenge

You want to find all restaurants located within the boundaries of a specific park. The park's boundaries are complex and not a simple rectangle.

Geospatial Search Recap

You've explored Elasticsearch's powerful geospatial capabilities!

  • We learned about the geo_point type for single locations (latitude, longitude).
  • We used geo_distance for proximity searches and geo_bounding_box for rectangular area searches.
  • We also introduced the advanced geo_shape type for complex geometries like polygons.

These tools are essential for building sophisticated location-aware applications.

Sıkça Sorulan Sorular

“Coğrafi Konum Arama Yetenekleri” dersi ücretsiz mi?

Evet — “Coğrafi Konum Arama Yetenekleri” dersin tüm metni burada web'de ücretsiz olarak okunabilir. Etkileşimli olarak pratik yapmak (yerleşik kod editörü ve 7/24 yapay zeka koçu) ve Elasticsearch & Full Text Search Systems kursunun geri kalanını açmak için CoddyKit PRO'ya yükselt. Elasticsearch & Full Text Search Systems kursu toplamda 4 dersten oluşur.

“Coğrafi Konum Arama Yetenekleri” dersinde ne öğreneceğim?

Konum tabanlı aramalar, yakınlık sorguları ve coğrafi konum toplamaları gerçekleştirmek için coğrafi nokta ve coğrafi şekil eşlemelerini uygulayın. Elasticsearch & Full Text Search Systems ile uygulamalı kodu tarayıcıda doğrudan çalıştırarak pratik yaparsın ve 7/24 yapay zeka koçu dersi çalışırken sorularını yanıtlar.

Elasticsearch & Full Text Search Systems öğrenmeye başlamak için deneyim gerekli mi?

Önceden deneyim gerekmez. CoddyKit'te Elasticsearch & Full Text Search Systems, başlangıçtan ileri seviyeye kadar yapılandırıldığı için buradan başlayabilir veya başından başlayıp kendi hızında ilerleme yapabilirsin. Bu, 4 dersinin 1. dersidir.

“Coğrafi Konum Arama Yetenekleri” dersi ne kadar sürer?

Çoğu CoddyKit dersi yaklaşık 5–10 dakika sürer. Her biri kısa ve etkileşimli olduğu için sabit ilerleme yaparsın ve web ile uygulama arasında tam olarak bıraktığın yerden devam edebilirsin.

Bu Elasticsearch & Full Text Search Systems dersinde kod yazıp çalıştırabilir miyim?

Evet. Her Elasticsearch & Full Text Search Systems dersi yerleşik bir kod editörü içerir, bu sayede tarayıcıda gerçek kod yazıp çalıştırabilir ve anlık yapay zeka geri bildirimi alırsın — yerel kurulum gerekli değildir.

Bu kursun tüm dersleri

  1. Coğrafi Konum Arama Yetenekleri
  2. Zaman Serisi Verilerini Yönetme
  3. Üretim Ortamına Dağıtım Stratejileri
  4. İndeks Yaşam Döngüsü Yönetimi
← Elasticsearch & Full Text Search Systems Sayfasına Dön