Skip to content

Instantly share code, notes, and snippets.

@missinglink
Created March 15, 2016 17:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save missinglink/8ccf248e57042082184f to your computer and use it in GitHub Desktop.
Save missinglink/8ccf248e57042082184f to your computer and use it in GitHub Desktop.
complex field name and type name collision
{
"status" : 200,
"name" : "Lacuna",
"cluster_name" : "elasticsearch",
"version" : {
"number" : "1.7.2",
"build_hash" : "e43676b1385b8125d647f593f7202acbd816e8ec",
"build_timestamp" : "2015-09-14T09:49:53Z",
"build_snapshot" : false,
"lucene_version" : "4.10.4"
},
"tagline" : "You Know, for Search"
}
{
"acknowledged" : true
}
{
"acknowledged" : true
}
{
"cluster_name" : "elasticsearch",
"status" : "yellow",
"timed_out" : false,
"number_of_nodes" : 1,
"number_of_data_nodes" : 1,
"active_primary_shards" : 21,
"active_shards" : 21,
"relocating_shards" : 0,
"initializing_shards" : 0,
"unassigned_shards" : 20,
"delayed_unassigned_shards" : 0,
"number_of_pending_tasks" : 1,
"number_of_in_flight_fetch" : 0
}
{
"_index" : "testindex",
"_type" : "guest",
"_id" : "1",
"_version" : 1,
"created" : true
}
{
"_shards" : {
"total" : 1,
"successful" : 1,
"failed" : 0
}
}
{
"took" : 2,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 0.30685282,
"hits" : [ {
"_index" : "testindex",
"_type" : "guest",
"_id" : "1",
"_score" : 0.30685282,
"_source":{"user":{"name":"john"}}
} ]
}
}
{
"_index" : "testindex",
"_type" : "user",
"_id" : "1",
"_version" : 1,
"created" : true
}
{
"_shards" : {
"total" : 1,
"successful" : 1,
"failed" : 0
}
}
{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 0.5945348,
"hits" : [ {
"_index" : "testindex",
"_type" : "user",
"_id" : "1",
"_score" : 0.5945348,
"_source":{"user":{"name":"john"}}
} ]
}
}
{
"_index" : "testindex",
"_type" : "user",
"_id" : "2",
"_version" : 1,
"created" : true
}
{
"_shards" : {
"total" : 1,
"successful" : 1,
"failed" : 0
}
}
{
"took" : 2,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 1.4054651,
"hits" : [ {
"_index" : "testindex",
"_type" : "user",
"_id" : "2",
"_score" : 1.4054651,
"_source":{"name":"john"}
} ]
}
}
{
"took" : 3,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"failed" : 0
},
"hits" : {
"total" : 2,
"max_score" : 1.0,
"hits" : [ {
"_index" : "testindex",
"_type" : "guest",
"_id" : "1",
"_score" : 1.0,
"_source":{"user":{"name":"john"}}
}, {
"_index" : "testindex",
"_type" : "user",
"_id" : "1",
"_score" : 1.0,
"_source":{"user":{"name":"john"}}
} ]
}
}
# Print ES Version
curl 'http://localhost:9200/?pretty'
setup() {
# Delete the index `testindex`
curl -XDELETE 'http://localhost:9200/testindex?pretty'
# Create the index `testindex`
curl -XPUT 'http://localhost:9200/testindex?pretty' -d '{
"settings" : {
"index" : {
"number_of_shards" : 1,
"number_of_replicas" : 0
}
}
}'
# Wait for yellow
curl -XGET 'http://localhost:9200/_cluster/health?wait_for_status=yellow&pretty'
}
refresh() {
curl -XPOST 'http://localhost:9200/testindex/_refresh?pretty'
}
# query the whole `testindex` index
search() {
curl -XGET 'http://localhost:9200/testindex/_search?pretty' -d '{
"query": {
"match": {
"user.name": "john"
}
},
"size": 100
}'
}
# run setup
setup;
# index "guest/1"
curl -XPUT 'http://localhost:9200/testindex/guest/1?pretty' -d '{"user":{"name":"john"}}'
refresh;
search;
# index "user/1"
curl -XPUT 'http://localhost:9200/testindex/user/1?pretty' -d '{"user":{"name":"john"}}'
refresh;
search;
# index "user/2"
curl -XPUT 'http://localhost:9200/testindex/user/2?pretty' -d '{"name":"john"}'
refresh;
search;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment