elastic / elasticsearch-mapper-attachments

Mapper Attachments Type plugin for Elasticsearch
https://www.elastic.co
Apache License 2.0
503 stars 94 forks source link

Fix mapping examples in documentation #179

Closed nhhagen closed 8 years ago

nhhagen commented 8 years ago

Request

curl -X PUT http://localhost:9200/person/person/_mapping -d '
{
    "person" : {
        "properties" : {
            "file" : {
                "type" : "attachment",
                "fields" : {
                    "file" : {"index" : "no"},
                    "title" : {"store" : "yes"},
                    "date" : {"store" : "yes"},
                    "author" : {"analyzer" : "standard"},
                    "keywords" : {"store" : "yes"},
                    "content_type" : {"store" : "yes"},
                    "content_length" : {"store" : "yes"},
                    "language" : {"store" : "yes"}
                }
            }
        }
    }
}
'

Response

{
    "error": {
        "reason": "Mapping definition for [fields] has unsupported parameters:  [file : {}]",
        "root_cause": [
            {
                "reason": "Mapping definition for [fields] has unsupported parameters:  [file : {}]",
                "type": "mapper_parsing_exception"
            }
        ],
        "type": "mapper_parsing_exception"
    },
    "status": 400
}
dadoonet commented 8 years ago

Indeed.

Here is a fix (almost a fix) for this:

curl -XDELETE http://localhost:9200/person?pretty
curl -XPUT http://localhost:9200/person/?pretty
curl -XPUT http://localhost:9200/person/person/_mapping?pretty -d '
{
    "person" : {
        "properties" : {
            "file" : {
                "type" : "attachment",
                "fields" : {
                    "title" : {"store" : "yes"},
                    "date" : {"store" : "yes"},
                    "author" : {"analyzer" : "standard"},
                    "keywords" : {"store" : "yes"},
                    "content_type" : {"store" : "yes"},
                    "content_length" : {"store" : "yes"},
                    "language" : {"store" : "yes"}
                }
            }
        }
    }
}
'

But I can't define the file inner field. When doing this I get:

{
  "error" : {
    "root_cause" : [ {
      "type" : "mapper_parsing_exception",
      "reason" : "Mapping definition for [fields] has unsupported parameters:  [file : {}]"
    } ],
    "type" : "mapper_parsing_exception",
    "reason" : "Mapping definition for [fields] has unsupported parameters:  [file : {}]"
  },
  "status" : 400
}

So to me, there is a bug in documentation for 2.0 and an actual bug in code as well.

dadoonet commented 8 years ago

Got it now. This commit 765afb655ed4051371bf9177c13a5888405747bd changed the behavior. So the file content in now in content field.

It's only a documentation issue.