Created
December 11, 2012 16:53
-
-
Save telvis07/4260232 to your computer and use it in GitHub Desktop.
multi-field in a nested document
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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