Created
November 18, 2013 07:41
-
-
Save johtani/7524077 to your computer and use it in GitHub Desktop.
I execute "sample_exec.json" step by step.
I receive response both requests: no prefix and exists prefix.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# create index | |
curl -XPUT "http://localhost:9200/restful" | |
# post mapping | |
curl -XPOST "http://localhost:9200/restful/events/_mapping" -d' | |
{ | |
"events" : { | |
"dynamic_templates" : [ { | |
"template_string" : { | |
"mapping" : { | |
"type" : "multi_field", | |
"fields" : { | |
"str" : { | |
"index_analyzer" : "simple", | |
"type" : "string" | |
}, | |
"{name}" : { | |
"index_analyzer" : "verbatim", | |
"type" : "string" | |
} | |
} | |
}, | |
"match" : "*", | |
"match_mapping_type" : "string" | |
} | |
}, { | |
"template_integer" : { | |
"mapping" : { | |
"type" : "multi_field", | |
"fields" : { | |
"str" : { | |
"index_analyzer" : "simple", | |
"type" : "string" | |
}, | |
"{name}" : { | |
"type" : "{dynamic_type}" | |
} | |
} | |
}, | |
"match" : "*", | |
"match_mapping_type" : "integer" | |
} | |
}, { | |
"template_long" : { | |
"mapping" : { | |
"type" : "multi_field", | |
"fields" : { | |
"str" : { | |
"index_analyzer" : "simple", | |
"type" : "string" | |
}, | |
"{name}" : { | |
"type" : "{dynamic_type}" | |
} | |
} | |
}, | |
"match" : "*", | |
"match_mapping_type" : "long" | |
} | |
}, { | |
"template_double" : { | |
"mapping" : { | |
"type" : "multi_field", | |
"fields" : { | |
"str" : { | |
"index_analyzer" : "simple", | |
"type" : "string" | |
}, | |
"{name}" : { | |
"type" : "{dynamic_type}" | |
} | |
} | |
}, | |
"match" : "*", | |
"match_mapping_type" : "double" | |
} | |
}, { | |
"template_date" : { | |
"mapping" : { | |
"type" : "multi_field", | |
"fields" : { | |
"str" : { | |
"index_analyzer" : "simple", | |
"type" : "string" | |
}, | |
"{name}" : { | |
"type" : "{dynamic_type}" | |
} | |
} | |
}, | |
"match" : "*", | |
"match_mapping_type" : "date" | |
} | |
}, { | |
"template_boolean" : { | |
"mapping" : { | |
"type" : "multi_field", | |
"fields" : { | |
"str" : { | |
"index_analyzer" : "simple", | |
"type" : "string" | |
}, | |
"{name}" : { | |
"type" : "{dynamic_type}" | |
} | |
} | |
}, | |
"match" : "*", | |
"match_mapping_type" : "boolean" | |
} | |
} ], | |
"properties" : { | |
"id" : { | |
"type" : "multi_field", | |
"fields" : { | |
"id" : { | |
"type" : "long" | |
}, | |
"str" : { | |
"type" : "string", | |
"index_analyzer" : "simple", | |
"include_in_all" : false | |
} | |
} | |
}, | |
"timestamp" : { | |
"type" : "multi_field", | |
"fields" : { | |
"timestamp" : { | |
"type" : "double" | |
}, | |
"str" : { | |
"type" : "string", | |
"index_analyzer" : "simple", | |
"include_in_all" : false | |
} | |
} | |
} | |
} | |
} | |
}' | |
# post doc #1 | |
curl -XPOST "http://localhost:9200/restful/events/1" -d' | |
{ | |
"id" : 123456, | |
"timestamp" : 1383467659 | |
}' | |
# post doc #2 | |
curl -XPOST "http://localhost:9200/restful/events/2" -d' | |
{ | |
"timestamp" : 1383467425.0, | |
"id" : 2 | |
}' | |
# search no prefix | |
curl -XGET http://localhost:9200/restful/_search?pretty -d '{ "query": {"bool": {"must": [{"term": {"_type": "events"}}, {"range": { "events.timestamp": {"to": 1383467660, "include_upper": false }}}]}}}' | |
{ | |
"took" : 57, | |
"timed_out" : false, | |
"_shards" : { | |
"total" : 5, | |
"successful" : 5, | |
"failed" : 0 | |
}, | |
"hits" : { | |
"total" : 2, | |
"max_score" : 1.4142135, | |
"hits" : [ { | |
"_index" : "restful", | |
"_type" : "events", | |
"_id" : "1", | |
"_score" : 1.4142135, "_source" : { | |
"id" : 123456, | |
"timestamp" : 1383467659 | |
} | |
}, { | |
"_index" : "restful", | |
"_type" : "events", | |
"_id" : "2", | |
"_score" : 1.4142135, "_source" : { | |
"timestamp" : 1383467425.0, | |
"id" : 2 | |
} | |
} ] | |
} | |
} | |
# search exist prefix | |
curl -XGET http://localhost:9200/restful/_search?pretty -d '{ "query": {"bool": {"must": [{"term": {"_type": "events"}}, {"range": { "timestamp": {"to": 1383467660, "include_upper": false }}}]}}}' | |
{ | |
"took" : 29, | |
"timed_out" : false, | |
"_shards" : { | |
"total" : 5, | |
"successful" : 5, | |
"failed" : 0 | |
}, | |
"hits" : { | |
"total" : 2, | |
"max_score" : 1.4142135, | |
"hits" : [ { | |
"_index" : "restful", | |
"_type" : "events", | |
"_id" : "1", | |
"_score" : 1.4142135, "_source" : { | |
"id" : 123456, | |
"timestamp" : 1383467659 | |
} | |
}, { | |
"_index" : "restful", | |
"_type" : "events", | |
"_id" : "2", | |
"_score" : 1.4142135, "_source" : { | |
"timestamp" : 1383467425.0, | |
"id" : 2 | |
} | |
} ] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment