Software Developer @adphorus
http://bahattincinic.com
http://github.com/bahattincinic
(2012 Yılında Kuruldu)
Cluster, Shard , Replication
Near Realtime
Node & Index & Doc Type
full-stext search, boost, filter, aggregation
Geographic information system (gis)
RESTful
Apache ürünlerine destek (spark, storm, pig, hive, hadoop). Apache lisansına sahip.
TTL (Time to live)
facetch, autocomplete (suggestion)
yaml configuation (elasticsearch.yml)
Elasticsearch | RDBMS |
---|---|
Index | Database |
Shard | Shard |
Mapping | Table |
Field | Field |
JSON Object | Tuple |
PostgreSQL => Databases => Tables => Columns/Rows
Elasticsearch => Indices => Types => Documents with Properties
Yeni index oluşturmak
$ curl -XPUT 'localhost:9200/places?pretty' -H 'Content-Type: application/json' -d'
{
"settings" : {
"index" : {
"number_of_shards" : 5,
"number_of_replicas" : 1
}
}
}
'
Mapping Güncellemek
curl -XPUT 'localhost:9200/places/_mapping/places?pretty' -H 'Content-Type: application/json' -d'
{
"properties": {
"title": {
"type": "string"
},
"point": {
"type": "geo_point"
},
"id": {
"type": "integer"
},
"category": {
"type": "string"
}
}
}
'
Veri Eklemek (Document)
curl -XPUT 'http://localhost:9200/places/places/1?pretty' -H 'Content-Type: application/json' -d'
{
"id" : 2,
"point": "41.12,-71.34",
"title": "Hipo",
"category": "Ofis"
}
'
Eklediğimiz Verinin Detayına Gitmek (Retrieve)
curl -XGET 'http://localhost:9200/places/places/1'
{
"_index":"mekanlar",
"_type":"mekanlar",
"_id":"1",
"_version":1,
"found":true,
"_source":{
"id":1,
"point":"41.12,-71.34",
"title":"Hipo",
"category":"Ofis"
}
}
Eklediğimiz tüm verileri Çekmek
curl -XGET 'http://localhost:9200/places/places/_search'
-H 'Content-Type: application/json' -d'
{
"query": {
"match_all": {}
}
}
'
{
"took":1,
"timed_out":false,
"_shards":{
"total":1,
"successful":5,
"failed":0
},
"hits":{
"total":1,
"max_score":1.0,
"hits":[
{
"_index":"mekanlar",
"_type":"mekanlar",
"_id":"1",
"_score":1.0,
"_source":{
"id":1,
"point":"41.12,-71.34",
"title":"Hipo",
"category":"Ofis"
}
},
]
}
}
Eklediğimiz Verileri Filtrelemek
curl -XGET 'http://localhost:9200/places/places/_search'
-H 'Content-Type: application/json' -d'
{
"query": {
"term": { "category": "Ofis" }
}
}
'
{
"took":1,
"timed_out":false,
"_shards":{
"total":1,
"successful":5,
"failed":0
},
"hits":{
"total":1,
"max_score":1.0,
"hits":[
{
"_index":"mekanlar",
"_type":"mekanlar",
"_id":"1",
"_score":1.0,
"_source":{
"id":1,
"point":"41.12,-71.34",
"title":"Hipo",
"category":"Ofis"
}
},
]
}
}
Client kullanmak yerine zaten RESTful oldugu icin direk requests paketini kullanarak da elasticsearch u kullanabilirsiniz
- Kendi içerisinde Auth. mekanizması barındırmıyor
- Nginx arkasına koyulabilir
- Public bir yerden erişimi yoksa private ip ile erişim sağlanabilir
https://github.com/bahattincinic/elasticsearch_demo