Skip to content

Instantly share code, notes, and snippets.

@clintongormley
Created July 19, 2012 08:13
Show Gist options
  • Save clintongormley/3141520 to your computer and use it in GitHub Desktop.
Save clintongormley/3141520 to your computer and use it in GitHub Desktop.
curl -XPUT 'http://127.0.0.1:9200/test/?pretty=1' -d '
{
"mappings" : {
"path" : {
"_id" : {
"path" : "path",
"properties" : {
"path" : {
"index_name" : "filepath",
"index" : "not_analyzed",
"type" : "string"
}
}
}
}
}
}
'
curl -XPOST 'http://127.0.0.1:9200/test/path?pretty=1' -d '
{
"path" : "foo"
}
'
# [Thu Jul 19 10:11:32 2012] Response:
# {
# "ok" : true,
# "_index" : "test",
# "_id" : "foo",
# "_type" : "path",
# "_version" : 1
# }
curl -XGET 'http://127.0.0.1:9200/test/path/_search?pretty=1' -d '
{
"query" : {
"text" : {
"path" : "foo"
}
}
}
'
# {
# "hits" : {
# "hits" : [
# {
# "_source" : {
# "path" : "foo"
# },
# "_score" : 0.30685282,
# "_index" : "test",
# "_id" : "foo",
# "_type" : "path"
# }
# ],
# "max_score" : 0.30685282,
# "total" : 1
# },
# "timed_out" : false,
# "_shards" : {
# "failed" : 0,
# "successful" : 5,
# "total" : 5
# },
# "took" : 4
# }
curl -XGET 'http://127.0.0.1:9200/test/path/_search?pretty=1' -d '
{
"query" : {
"text" : {
"path.path" : "foo"
}
}
}
'
# {
# "hits" : {
# "hits" : [
# {
# "_source" : {
# "path" : "foo"
# },
# "_score" : 0.30685282,
# "_index" : "test",
# "_id" : "foo",
# "_type" : "path"
# }
# ],
# "max_score" : 0.30685282,
# "total" : 1
# },
# "timed_out" : false,
# "_shards" : {
# "failed" : 0,
# "successful" : 5,
# "total" : 5
# },
# "took" : 4
# }
curl -XGET 'http://127.0.0.1:9200/test/path/_search?pretty=1' -d '
{
"query" : {
"text" : {
"filepath" : "foo"
}
}
}
'
# {
# "hits" : {
# "hits" : [],
# "max_score" : null,
# "total" : 0
# },
# "timed_out" : false,
# "_shards" : {
# "failed" : 0,
# "successful" : 5,
# "total" : 5
# },
# "took" : 0
# }
curl -XGET 'http://127.0.0.1:9200/test/path/_search?pretty=1' -d '
{
"query" : {
"text" : {
"path.filepath" : "foo"
}
}
}
'
# {
# "hits" : {
# "hits" : [],
# "max_score" : null,
# "total" : 0
# },
# "timed_out" : false,
# "_shards" : {
# "failed" : 0,
# "successful" : 5,
# "total" : 5
# },
# "took" : 1
# }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment