removeUpdateKeys should be skipping your key because it's a simple key.

private void removeUpdateKeys(String updateKeyParam, Map doc) {
    String[] parts = updateKeyParam.split(",[\\s]*");
    for (String part : parts) {
        if (part.contains(".")) {
            doc.remove(part);
        }
    }
}

Are you sure the value is just *identifiant* and not something like
*something.identifiant*?

On Mon, Jul 9, 2018 at 9:42 AM Yves HAMEL <[email protected]> wrote:

>
> Hi,
> I try to "upsert" document in a mongodb collection.
> When the document exists, PutMongo processor update the document but when
> the document doesn't exist the processor do not create it.
> Here is the setting of my PutMongo processor :
>         Mode : updateg
>         Upsert : true
>         Update Query Key : identifiant
>         Update Query : null
>         Update Mode : With Operator Enabled
>
> I have read the PutMongodb.java and notice a strange thing when preparing
> mongodb update request :
>                 if (!StringUtils.isBlank(updateKey)) {
>                     query = parseUpdateKey(updateKey, (Map)doc);
>                     removeUpdateKeys(updateKey, (Map)doc);
>                 } else {
>                     query = Document.parse(filterQuery);
>                 }
> When using updateKey, it builds the query with the updateKey and removes
> this key from the document so it creates the document without the key.
> The document is created but there is missing part of the document.
> When using update_query mode, it does remove anything form the document.
>
> I simply remove the removeUpdateKeys() method call in a test custum
> processor. And it works fine.
>
> Is that path correct ?
>
> Thank
>
> Yves HAMEL
> (Embedded image moved to file: pic07711.jpg)
>
> Yves HAMEL
> Direction Digital & Systèmes d’Information Groupe
> LM_DATA
>
> MACIF - 2 et 4, rue Pied de Fond
> <https://maps.google.com/?q=4,+rue+Pied+de+Fond&entry=gmail&source=g> -
> 79037 Niort cedex 9
> Tél. : +33 (0)5 49 09 36 06 <+33%205%2049%2009%2036%2006>
> Email : [email protected] / Pré Doyen 2 – bureau 999
>
> www.macif.fr - Appli présente sur Google Play Store & Apple Store
> (Embedded image moved to file: pic28253.jpg)

Reply via email to