Skip to content

Instantly share code, notes, and snippets.

@clintongormley
Created January 16, 2012 10:17
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save clintongormley/1620128 to your computer and use it in GitHub Desktop.
Save clintongormley/1620128 to your computer and use it in GitHub Desktop.
# [Mon Jan 16 11:23:14 2012] Protocol: http, Server: 192.168.5.10:9200
curl -XPUT 'http://127.0.0.1:9200/users/?pretty=1' -d '
{
"mappings" : {
"info" : {
"_all" : {
"type" : "string",
"analyzer" : "uax_url_email"
},
"properties" : {
"email" : {
"type" : "string",
"analyzer" : "keyword"
},
"name" : {
"fields" : {
"untouched" : {
"index" : "not_analyzed",
"type" : "string"
},
"name" : {
"type" : "string"
}
},
"type" : "multi_field"
}
}
}
},
"settings" : {
"analysis" : {
"analyzer" : {
"uax_url_email" : {
"filter" : [
"standard",
"lowercase",
"stop"
],
"tokenizer" : "uax_url_email"
}
}
}
}
}
'
# [Mon Jan 16 11:23:14 2012] Response:
# {
# "ok" : true,
# "acknowledged" : true
# }
# [Mon Jan 16 11:23:16 2012] Protocol: http, Server: 192.168.5.10:9200
curl -XPOST 'http://127.0.0.1:9200/users/info?pretty=1' -d '
{
"email" : "joe@foo.com",
"name" : "Joe Bloggs"
}
'
# [Mon Jan 16 11:23:16 2012] Response:
# {
# "ok" : true,
# "_index" : "users",
# "_id" : "NXgTmd3kT0-fEnzdDvXFxA",
# "_type" : "info",
# "_version" : 1
# }
# [Mon Jan 16 11:23:19 2012] Protocol: http, Server: 192.168.5.10:9200
curl -XGET 'http://127.0.0.1:9200/users/_search?pretty=1' -d '
{
"query" : {
"term" : {
"_all" : "joe@foo.com"
}
},
"facets" : {
"email" : {
"terms" : {
"field" : "email"
}
},
"name" : {
"terms" : {
"field" : "name"
}
},
"all" : {
"terms" : {
"field" : "_all"
}
}
}
}
'
# [Mon Jan 16 11:23:19 2012] Response:
# {
# "hits" : {
# "hits" : [
# {
# "_source" : {
# "email" : "joe@foo.com",
# "name" : "Joe Bloggs"
# },
# "_score" : 0.10848885,
# "_index" : "users",
# "_id" : "NXgTmd3kT0-fEnzdDvXFxA",
# "_type" : "info"
# }
# ],
# "max_score" : 0.10848885,
# "total" : 1
# },
# "timed_out" : false,
# "_shards" : {
# "failed" : 0,
# "successful" : 5,
# "total" : 5
# },
# "facets" : {
# "email" : {
# "other" : 0,
# "terms" : [
# {
# "count" : 1,
# "term" : "joe@foo.com"
# }
# ],
# "missing" : 0,
# "_type" : "terms",
# "total" : 1
# },
# "name" : {
# "other" : 0,
# "terms" : [
# {
# "count" : 1,
# "term" : "joe"
# },
# {
# "count" : 1,
# "term" : "bloggs"
# }
# ],
# "missing" : 0,
# "_type" : "terms",
# "total" : 2
# },
# "all" : {
# "other" : 0,
# "terms" : [
# {
# "count" : 1,
# "term" : "joe@foo.com"
# },
# {
# "count" : 1,
# "term" : "joe"
# },
# {
# "count" : 1,
# "term" : "bloggs"
# }
# ],
# "missing" : 0,
# "_type" : "terms",
# "total" : 3
# }
# },
# "took" : 3
# }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment