IMPORTANT: No additional bug fixes or documentation updates
will be released for this version. For the latest information, see the
current release documentation.
Querying or accessing metadata
editQuerying or accessing metadata
editIf you need to query on metadata fields, use the attachment field name dot the metadata field. For example:
PUT /test PUT /test/person/_mapping { "person": { "properties": { "file": { "type": "attachment", "fields": { "content_type": { "type": "text", "store": true } } } } } } PUT /test/person/1?refresh=true { "file": "IkdvZCBTYXZlIHRoZSBRdWVlbiIgKGFsdGVybmF0aXZlbHkgIkdvZCBTYXZlIHRoZSBLaW5nIg==" } GET /test/person/_search { "stored_fields": [ "file.content_type" ], "query": { "match": { "file.content_type": "text plain" } } }
Will give you:
{ "took": 2, "timed_out": false, "_shards": { "total": 5, "successful": 5, "failed": 0 }, "hits": { "total": 1, "max_score": 0.53484553, "hits": [ { "_index": "test", "_type": "person", "_id": "1", "_score": 0.53484553, "fields": { "file.content_type": [ "text/plain; charset=ISO-8859-1" ] } } ] } }