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

时间:2015-10-12 09:54:26

标签: 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,
        - occurrences: Long,
        - tfidf: Double
    }]

对于每个新学期(例如:" ES rock"),我想:

- 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 ?!)

我想发表批量请求"更新 - >脚本 - > UPSERT"但在更新之前没有得到文件。

您认为选择映射是否可行?我无法找到一个好的解决方案......

0 个答案:

没有答案