Skip to content

Instantly share code, notes, and snippets.

@clintongormley
Created March 10, 2011 13:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clintongormley/864115 to your computer and use it in GitHub Desktop.
Save clintongormley/864115 to your computer and use it in GitHub Desktop.
ElasticSearch - not_analyzed array
# [Thu Mar 10 14:48:46 2011] Protocol: http, Server: 127.0.0.1:9200
curl -XPUT 'http://127.0.0.1:9200/foo/' -d '
{}
'
# [Thu Mar 10 14:48:46 2011] Response:
# {
# "ok" : true,
# "acknowledged" : true
# }
# [Thu Mar 10 14:48:52 2011] Protocol: http, Server: 127.0.0.1:9200
curl -XPUT 'http://127.0.0.1:9200/foo/bar/_mapping' -d '
{
"bar" : {
"properties" : {
"field" : {
"index" : "not_analyzed",
"type" : "string"
}
}
}
}
'
# [Thu Mar 10 14:48:52 2011] Response:
# {
# "ok" : true,
# "acknowledged" : true
# }
# [Thu Mar 10 14:48:55 2011] Protocol: http, Server: 127.0.0.1:9200
curl -XPUT 'http://127.0.0.1:9200/foo/bar/1' -d '
{
"field" : [
"Val1",
"Val2",
"Val3"
]
}
'
# [Thu Mar 10 14:48:55 2011] Response:
# {
# "ok" : true,
# "_index" : "foo",
# "_id" : "1",
# "_type" : "bar",
# "_version" : 1
# }
# [Thu Mar 10 14:48:58 2011] Protocol: http, Server: 127.0.0.1:9200
curl -XGET 'http://127.0.0.1:9200/foo/_search' -d '
{
"query" : {
"constant_score" : {
"filter" : {
"term" : {
"field" : "Val1"
}
}
}
}
}
'
# [Thu Mar 10 14:48:58 2011] Response:
# {
# "hits" : {
# "hits" : [
# {
# "_source" : {
# "field" : [
# "Val1",
# "Val2",
# "Val3"
# ]
# },
# "_score" : 1,
# "_index" : "foo",
# "_id" : "1",
# "_type" : "bar"
# }
# ],
# "max_score" : 1,
# "total" : 1
# },
# "timed_out" : false,
# "_shards" : {
# "failed" : 0,
# "successful" : 5,
# "total" : 5
# },
# "took" : 3
# }
# [Thu Mar 10 15:56:56 2011] Protocol: http, Server: 127.0.0.1:9200
curl -XGET 'http://127.0.0.1:9200/foo/_search' -d '
{
"query" : {
"filtered" : {
"query" : {
"query_string" : {
"query" : "*"
}
},
"filter" : {
"term" : {
"field" : "Val1"
}
}
}
}
}
'
# [Thu Mar 10 15:56:56 2011] Response:
# {
# "hits" : {
# "hits" : [
# {
# "_source" : {
# "field" : [
# "Val1",
# "Val2",
# "Val3"
# ]
# },
# "_score" : 1,
# "_index" : "foo",
# "_id" : "1",
# "_type" : "bar"
# }
# ],
# "max_score" : 1,
# "total" : 1
# },
# "timed_out" : false,
# "_shards" : {
# "failed" : 0,
# "successful" : 5,
# "total" : 5
# },
# "took" : 2
# }
@coleslaw
Copy link

Would it work if I have "index" : "no" (i.e: just store the array in exact order).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment