Update ES mapping from Groovy/Gradle script


(Serhan Shbeita) #1

Hi
I'm trying to update mapping of one field to be not_analyzed
First I send POST to create the river and the index:

println "starting the river"
http.request(POST, JSON) { req ->
    uri.path = "_river/ffxi/_meta"
    body = [
            type: "mongodb",
            mongodb: [
                    servers: [
                            [
                                    host: "127.0.0.1",
                                    port: Integer.valueOf(mongoPort).

intValue()
]
],
options: [
secondary_read_reference: true,
exclude_fields: ["coursesOfActions"]
],
db: "tx",
collection: "indicators"
],
index: [
name: "indicators",
type: "indicator"
]
]
response.success = { resp, json ->
println "Create index response status: ${resp.statusLine}"
}
}

Then I try to send update mapping to update a field to be not_analyzed :

 http.request(PUT, JSON) { req ->
    uri.path = "indicators/indicator/%5mappings"


    body = [
            indicator: [
                    observable: [
                            value: [
                                    type: "string",
                                    index: "not_analyzed"
                            ]
                    ]
            ]
    ]


    response.success = { resp, json ->
        println "Update mappings response status: ${resp.statusLine}"
    }

The problem when doing this i tried to get the mappings of the indicators
index: http://localhost:9200/indicators/indicator/_mapping
and this what i get:

{
"indicators": {
"mappings": {
"indicator": {
"properties": {
"indicator": {
"properties": {
"observable": {
"properties": {
"value": {
"properties": {
"index": {
"type": "string"
},
"type": {
"type": "string"
}
}
}
}
}
}
}
}
}
}
}
}

Any idea? properties element added to all elements!!!
WHY!?

Thanks

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/14350df7-0f00-42f9-8bff-19d508e6be14%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(system) #2