elasticsearch,Groovy,elasticsearch" /> elasticsearch,Groovy,elasticsearch" />

Groovy 用于批量/更新文档而不获取文档的复杂脚本

Groovy 用于批量/更新文档而不获取文档的复杂脚本,groovy,elasticsearch,Groovy,elasticsearch,对于我的项目,我有以下ES映射表示: - BOOK - label: String, - active: Boolean - total_term_occ: Long - TERMS - label: String, - ngram: Byte, - tot_occurrences: Long, - books [{ - id: String, - label: String, - occu

对于我的项目,我有以下ES映射表示:

- BOOK
    - label: String,
    - active: Boolean
    - total_term_occ: Long

- TERMS
    - label: String,
    - ngram: Byte,
    - tot_occurrences: Long,
    - books [{
        - id: String,
        - label: String,
        - occurrences: Long,
        - tfidf: Double
    }]
对于每个新学期(例如:“ES rocks”),我想:

- Update the total occurrence in the "TERMS" doc
OR 
- Create the new term if not exists
AND (if term already exists)
- BOOK :
    - Create a new object if the book does not already exist with "occurrences" to 0 and "tfidf" to NULL
    OR
    - Update the "occurrences" field if the book exists (with a loop ?!)
我想批量请求“更新->脚本->升级”,但在更新之前不获取文档

您认为选择映射是否可行?我找不到好的解决办法