Hi, I've read through the Update API and read advice elsewhere, but it's still not clear to me how to update a specific nested object.
Here's the mappings and settings I'm using for the index, which I've also created an alias of "asset" for:
// PUT localhost:9200/asset_en_v1
{
"settings": {
"analysis": {
"char_filter": {
"&_to_and": {
"type": "mapping",
"mappings": [ "&=> and "]
}
},
"filter": {
"asset_en_stopwords": {
"type": "stop",
"stopwords": [ "_english_" ]
},
"asset_en_stemmer": {
"type": "stemmer",
"name": "english"
},
"asset_en_shingle": {
"type": "shingle",
"max_shingle_size": 5,
"min_shingle_size": 2,
"output_unigrams": false,
"output_unigrams_if_no_shingles": true
}
},
"analyzer": {
"asset_en_analyzer": {
"type": "custom",
"char_filter": [ "html_strip", "&_to_and" ],
"tokenizer": "standard",
"filter": [ "asset_en_stopwords", "asset_en_stemmer", "lowercase", "asset_en_shingle", "asciifolding" ]
}
}
}
},
"mappings": {
"note": {
"_all": {
"enabled": false
},
"properties": {
"creation": {
"type": "date",
"format": "date_hour_minute_second"
},
"deleted": {
"type": "integer"
},
"favourite": {
"type": "integer"
},
"modification": {
"type": "date",
"format": "date_hour_minute_second"
},
"note": {
"type": "text",
"analyzer": "english",
"fields": {
"std": {
"type": "text",
"analyzer": "asset_en_analyzer",
"fields": {
"std": {
"type": "text",
"analyzer": "standard"
}
}
}
}
},
"title": {
"type": "text",
"analyzer": "english",
"fields": {
"std": {
"type": "text",
"analyzer": "asset_en_analyzer",
"fields": {
"std": {
"type": "text",
"analyzer": "standard"
}
}
}
}
},
"links": {
"type": "nested",
"include_in_parent": true,
"properties": {
"note_link_id": {
"type": "long"
},
"user_id": {
"type": "long"
},
"creation": {
"type": "date",
"format": "date_hour_minute_second"
},
"modification": {
"type": "date",
"format": "date_hour_minute_second"
},
"to_asset": {
"type": "long"
},
"from_asset": {
"type": "long"
},
"comment": {
"type": "long",
"analyzer": "english",
"fields": {
"std": {
"type": "text",
"analyzer": "asset_en_analyzer",
"fields": {
"std": {
"type": "text",
"analyzer": "standard"
}
}
}
}
}
}
},
"user_id": {
"type": "long"
}
}
}
}
What's relevant here is the "links" nested object, for example:
{
"_index": "asset_en_v1",
"_type": "note",
"_id": "99",
"_version": 2,
"found": true,
"_source": {
"user_id": "11",
"title": "Title",
"note": "Note.",
"creation": "2016-11-15T10:45:34",
"modification": "2016-11-15T10:49:36",
"links": [
[
{
"note_link_id": "1",
"user_id": "11",
"creation": "2016-11-15T11:21:10",
"modification": "2016-11-15T13:38:04",
"to_asset": "100",
"from_asset": "99",
"comment": "Comment 1."
},
{
"note_link_id": "2",
"user_id": "11",
"creation": "2016-11-15T13:37:04",
"modification": "2016-11-15T13:37:27",
"to_asset": "101",
"from_asset": "99",
"comment": "Comment 2."
},
{
"note_link_id": "3",
"user_id": "11",
"creation": "2016-11-15T14:01:27",
"modification": "2016-11-15T14:02:52",
"to_asset": "102",
"from_asset": "99",
"comment": "Comment 3."
}
]
],
"favourite": 0,
"deleted": "0"
}
}
Over time, a user:
- adds a link;
- deletes a link;
- updates the comment on a link.
I have an understanding of the adding and deleting, but the update is where things go wrong.
Any assistance would be much appreciated!