Skip to content

Instantly share code, notes, and snippets.

@clintongormley
Created September 13, 2013 17:54
Show Gist options
  • Save clintongormley/6553910 to your computer and use it in GitHub Desktop.
Save clintongormley/6553910 to your computer and use it in GitHub Desktop.
curl -XPUT 'http://127.0.0.1:9200/foo/?pretty=1' -d '
{
"mappings" : {
"bar" : {
"properties" : {
"text" : {
"index" : "not_analyzed",
"fielddata" : {
"filter" : {
"regex" : {
"pattern" : "^abc.*"
}
}
},
"type" : "string"
}
}
}
}
}
'
curl -XPOST 'http://127.0.0.1:9200/foo/bar?pretty=1' -d '
{
"text" : "abcdef"
}
'
curl -XPOST 'http://127.0.0.1:9200/foo/bar?pretty=1' -d '
{
"text" : "bbcdef"
}
'
curl -XGET 'http://127.0.0.1:9200/foo/_search?pretty=1' -d '
{
"facets" : {
"f" : {
"terms" : {
"field" : "text"
}
}
}
}
'
# {
# "hits" : {
# "hits" : [
# {
# "_source" : {
# "text" : "abcdef"
# },
# "_score" : 1,
# "_index" : "foo",
# "_id" : "VCVMUOZSS3i9XYfWLUIt2A",
# "_type" : "bar"
# },
# {
# "_source" : {
# "text" : "bbcdef"
# },
# "_score" : 1,
# "_index" : "foo",
# "_id" : "IzSHYYquR9uSICnI9MQo-A",
# "_type" : "bar"
# }
# ],
# "max_score" : 1,
# "total" : 2
# },
# "timed_out" : false,
# "_shards" : {
# "failed" : 0,
# "successful" : 5,
# "total" : 5
# },
# "facets" : {
# "f" : {
# "other" : 0,
# "terms" : [
# {
# "count" : 1,
# "term" : "abcdef"
# }
# ],
# "missing" : 1,
# "_type" : "terms",
# "total" : 1
# }
# },
# "took" : 9
# }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment