Skip to content

Instantly share code, notes, and snippets.

@clintongormley
Created February 14, 2012 09:38
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clintongormley/1825357 to your computer and use it in GitHub Desktop.
Save clintongormley/1825357 to your computer and use it in GitHub Desktop.
# [Tue Feb 14 10:37:36 2012] Protocol: http, Server: 192.168.5.10:9200
curl -XPUT 'http://127.0.0.1:9200/foo/?pretty=1' -d '
{
"settings" : {
"analysis" : {
"analyzer" : {
"lc" : {
"filter" : [
"lowercase"
],
"type" : "custom",
"tokenizer" : "keyword"
}
}
}
},
"mappings" : {
"user" : {
"properties" : {
"email" : {
"type" : "multi_field",
"fields" : {
"email" : {
"type" : "string",
"analyzer" : "simple"
},
"lc" : {
"type" : "string",
"analyzer" : "lc"
}
}
}
}
}
}
}
'
curl -XPOST 'http://127.0.0.1:9200/foo/user?pretty=1' -d '
{
"email" : "Clint@TravelJury.COM"
}
'
curl -XGET 'http://127.0.0.1:9200/foo/_search?pretty=1' -d '
{
"facets" : {
"email" : {
"terms" : {
"field" : "email"
}
},
"lc" : {
"terms" : {
"field" : "email.lc"
}
}
}
}
'
# [Tue Feb 14 10:37:41 2012] Response:
# {
# "hits" : {
# "hits" : [
# {
# "_source" : {
# "email" : "Clint@TravelJury.COM"
# },
# "_score" : 1,
# "_index" : "foo",
# "_id" : "HpIOWUc2SI6Zxw0bPxt-kQ",
# "_type" : "user"
# }
# ],
# "max_score" : 1,
# "total" : 1
# },
# "timed_out" : false,
# "_shards" : {
# "failed" : 0,
# "successful" : 5,
# "total" : 5
# },
# "facets" : {
# "email" : {
# "other" : 0,
# "terms" : [
# {
# "count" : 1,
# "term" : "traveljury"
# },
# {
# "count" : 1,
# "term" : "com"
# },
# {
# "count" : 1,
# "term" : "clint"
# }
# ],
# "missing" : 0,
# "_type" : "terms",
# "total" : 3
# },
# "lc" : {
# "other" : 0,
# "terms" : [
# {
# "count" : 1,
# "term" : "clint@traveljury.com"
# }
# ],
# "missing" : 0,
# "_type" : "terms",
# "total" : 1
# }
# },
# "took" : 2
# }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment