Skip to content

Instantly share code, notes, and snippets.

@telvis07
Created December 11, 2012 16:53
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 telvis07/4260232 to your computer and use it in GitHub Desktop.
Save telvis07/4260232 to your computer and use it in GitHub Desktop.
multi-field in a nested document
curl -XDELETE localhost:9200/test
curl -XPOST localhost:9200/test -d '
{
"mappings": {
"type1": {
"properties": {
"message": {
"index": "analyzed",
"type": "string"
},
"depart": {
"properties": {
"city": {
"type": "multi_field",
"fields": {
"city": {
"index": "not_analyzed",
"type": "string"
},
"city_auto": {
"index": "analyzed",
"type": "string",
"analyzer": "AutoAnalyzer",
"store": "yes"
}
}
}
}
}
}
}
},
"settings": {
"number_of_shards": 1,
"analysis": {
"tokenizer": {
"nGramTokenizer": {
"max_gram": 3,
"type": "nGram",
"min_gram": 3
}
},
"analyzer": {
"AutoAnalyzer": {
"filter": "lowercase",
"type": "custom",
"tokenizer": "nGramTokenizer"
}
}
}
}
}'
curl -XPUT 'localhost:9200/test/type1/1' -d '
{
"message" : "something blue",
"depart":{"city":"saopaulo"}
}
'
curl -XPUT 'localhost:9200/test/type1/2' -d '
{
"message" : "something green",
"depart": {"city":"newyork"}
}
'
curl -XPOST 'localhost:9200/_refresh'
echo ""
echo "Query with typed navigation notation for multi-field in a nested document. Works!"
curl -XPOST 'localhost:9200/test/_search?pretty=true' -d '
{
"query": {
"query_string": {
"query": "depart.city.city_auto:new"
}
}
}
'
echo ""
echo "Query with navigation notation for multi-field in a nested document. No bueno!"
curl -XPOST 'localhost:9200/test/_search?pretty=true' -d '
{
"query": {
"query_string": {
"query": "depart.city_auto:new"
}
}
}
'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment