Skip to content

Instantly share code, notes, and snippets.

@dadoonet
Created December 5, 2013 07:56
Show Gist options
  • Save dadoonet/7801691 to your computer and use it in GitHub Desktop.
Save dadoonet/7801691 to your computer and use it in GitHub Desktop.
Facet on IP address V4
curl -XPOST http://localhost:9200/foo; echo
curl -XPUT http://localhost:9200/foo/bar/_mapping -d '{
"bar":{
"properties":{
"clientip":{
"type":"multi_field",
"fields":{
"clientip":{
"type":"ip"
},
"clientip_facet":{
"type":"string",
"index":"not_analyzed"
}
}
}
}
}
}'; echo
curl -XPUT http://localhost:9200/foo/bar/1 -d '{"clientip":"192.168.0.1"}'; echo
curl -XPUT http://localhost:9200/foo/bar/2 -d '{"clientip":"192.168.0.2"}'; echo
curl -XPUT http://localhost:9200/foo/bar/3 -d '{"clientip":"192.168.0.3"}'; echo
curl -XPUT http://localhost:9200/foo/bar/4?refresh -d '{"clientip":"192.168.0.4"}'; echo
curl -XGET http://localhost:9200/foo/bar/_search?pretty -d '{
"facets":{
"pie":{
"terms":{
"field":"clientip",
"size":10
}
}
}
}'; echo
curl -XGET http://localhost:9200/foo/bar/_search?pretty -d '{
"facets":{
"pie":{
"terms":{
"field":"clientip_facet",
"size":10
}
}
}
}'; echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment