{
"settings" : {
"number_of_shards" : 1
},
"mappings" : {
"ihale" : {
"_source" : { "enabled" : false },
"_type" : {"index" : "no"},
"_id" : {
"index" : "not_analyzed",
"store" : true
},
"properties" : {
"id" : { "type" : "long", "index" : "not_analyzed" },
"konusu" : { "type" : "string", "index" : "not_analyzed" }
}
}
}
}
--------------------------------------------------------------------------------------------------------
PUT http://localhost:9200/diviner_log/ HTTP/1.1
User-Agent: Fiddler
Host: localhost:9200
Content-Length: 404
{
"settings" : {
"number_of_shards" : 1
},
"mappings" : {
"ihale" : {
"_source" : { "enabled" : false },
"_type" : {"index" : "no"},
"properties" : {
"id" : { "type" : "long", "index" : "not_analyzed" },
"konusu" : { "type" : "string", "index" : "not_analyzed" }
}
}
}
}
HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
Content-Length: 21
{"acknowledged":true}
--------------------------------------------------------------------------------------------------------
:9200/index/_type/_id
index için > GET http://localhost:9200/diviner_log/_mappings
_type için > GET http://localhost:9200/diviner_log/tweet/_mapping
--------------------------------------------------------------------------------------------------------
MAPPINGS vs MAPPING
PUT http://localhost:9200/diviner_log/tweet/_mapping HTTP/1.1 // _mapping ile tek bir
User-Agent: Fiddler
Host: localhost:9200
Content-Length: 402
{
"_source" : { "enabled" : false },
"_type" : {"index" : "no"},
"_id" : { "path" : "tarihi" }, // :9200/index/_type/_id > _id değerini "tarihi" özelliğinden alacak
"properties" : {
"id" : { "type" : "long", "index" : "not_analyzed" },
"konusu" : { "type" : "string", "index" : "not_analyzed" },
"tarihi":{ "type" : "date", "index" : "not_analyzed" } // "tarihi" özelliğinin tipinin date olduğunu belirtelim ki;
// kibana'da süzme işlemleri kolay olsun
}
}
İhale için mapping:
PUT http://localhost:9200/diviner_log/ihale/_mapping
{
"ihale": {
"_id": {
"path": "tarihi"
},
"properties": {
"id": {
"type": "long"
},
"konusu": {
"type": "string"
},
"tarihi": {
"type": "date"
}
}
}
}
Mapping sonucunu görelim:
GET http://localhost:9200/diviner_log/ihale/_mapping
{
"diviner_log": {
"mappings": {
"ihale": {
"_id": {
"path": "tarihi"
},
"properties": {
"id": {
"type": "long"
},
"konusu": {
"type": "string"
},
"tarihi": {
"type": "date",
"format": "dateOptionalTime"
}
}
}
}
}
}
--------------------------------------------------------------------------------------------------------
CLEAR CACHE - ELASTICSEARCH
$ curl -XPOST 'http://localhost:9200/twitter/_cache/clear'
--------------------------------------------------------------------------------------------------------
AUTO CREATE ID
POST http://localhost:9200/diviner_log/tweet/ HTTP/1.1 // PUT yerine POST ile gönderince otomatik ID üretecektir
User-Agent: Fiddler
Host: localhost:9200
Content-Length: 74
{id:1, konusu:"Cemin deneme tahtasındaki ilk konu", tarihi:1426086937374}
HTTP/1.1 201 Created
Content-Type: application/json; charset=UTF-8
Content-Length: 97
{"_index":"diviner_log","_type":"tweet","_id":"AUwM_9mGuoX-zfkMiNtf","_version":1,"created":true}
--------------------------------------------------------------------------------------------------------