Here comes another offspring to this question: Exclude complete path from indexing and _source
What I want to achieve here is to
-exclude a field called "ignoreme" from the _source AND
-exclude the very same field from the index itself
So in the following example, I start with the following index creation:
curl -XPOST 'http://192.168.56.102:9200/test' -d '{"mappings":
{"my_type":{"_all":{"enabled":false},
"_source":{"excludes":["ignoreme"]},
"dynamic_templates":[{"skip":{"match":"ignoreme","mapping":{"type":"string","store":"no","index":"no"}}}]}}}'
The index then looks like this:
curl -XGET http://192.168.56.102:9200/test?pretty
{
"test" : {
"aliases" : { },
"mappings" : {
"my_type" : {
"_all" : {
"enabled" : false
},
"_source" : {
"excludes" : [ "ignoreme" ]
},
"dynamic_templates" : [ {
"skip" : {
"mapping" : {
"index" : "no",
"store" : "no",
"type" : "string"
},
"match" : "ignoreme"
}
} ]
}
},....
Next, I post this document:
curl -XPOST 'http://192.168.56.102:9200/test/my_type/1' -d '{"title":"Something","ignoreme":"I should not be here"}'
I now expect that "ignoreme" should not be searchable at all, but when I run a query for the word "here" in "ignoreme", I still get a result:
curl -XGET http://192.168.56.102:9200/test/my_type/_search?pretty&q=ignoreme:here
[1] 3463
ben@ben-ubuntu14:~$ {
"took" : 7,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 1.0,
"hits" : [ {
"_index" : "test",
"_type" : "my_type",
"_id" : "1",
"_score" : 1.0,
"_source":{"title":"Something"}
} ]
}
}
So what do I have to do to TRULY and COMPLETELY exclude "ignoreme"?
In addition, I am wondering whether this type of mapping is also possible for arrays and/or object types.
E.g. if I have an array of strings like this:
"messages":["Help, I need someboy","It's been a hard days night","Norwegian Wood"]
is there a way to exclude the complete array from being indexed and added to the _source?