我爲我的Ruby on Rails應用程序使用elasticsearch-rails
和elasticsearch-model
寶石,這就像問答網站。在嵌套對象更新上更新多個文檔
我的主要問題是:當嵌套在多個文檔中的嵌套對象發生更改時,如何告知Elasticsearch要更新哪些文檔?
我有一個索引my_index
和映射question
和answer
。特別是,question
有一個user
嵌套對象:
"question": {
"properties": {
"user": {
"type": "nested",
"properties": {
"created_at": {
"type": "date",
"format": "dateOptionalTime"
},
"name": {
"type": "string"
},
"id": {
"type": "long"
},
"email": {
"type": "string"
}
}
}
...
}
}
這有可能爲用戶更改他的名字,我有鉤更新Elasticsearch用戶:
after_commit lambda { __elasticsearch__.index_document}, on: :update
但這ISN不正確地更新適當的question
對象,我不知道要傳遞給index_document
調用的內容,以確保它使用新的用戶名更新所有相應的question
。有人知道嗎?它甚至可以幫助我看看RESTful/curl請求應該是什麼樣子?
任何幫助,將不勝感激!
嘿,斯隆,所以這確實讓查詢變得更加困難。特別是,我試圖建立祖父母和孫子女(像https://www.elastic.co/guide/en/elasticsearch/guide/current/grandparents.html),但似乎'inner_hits'停止工作。 ..你有什麼想法,爲什麼可能會發生? – user5243421