Query in MongoDB Reader

Hi!! Knime Experts…

Hope You are doing well.

I want to create query in MongoDB Reader, where I want to select Specific Column from Specified Table, Can you guide how to prepare query…

Ex: I want to Select :“ZW” , “AW”, “ZT”, column from table name as: “BUKRS”

Thanks in Advance.

Hi,
you have to list those fields in the projection field of the MongoDB Reader node. The table name is the collection in MongoDB.
Kind regards,
Alexander

1 Like

@AlexanderFillbrunn Thanks for your answer,

After applying your suggestion, I am facing this issue, pls check…

Hi,
The query does not need to contain the collection name. You have to specify that in the field above. Please see here for how the queries have to look like: https://jongo.org.
Kind regards,
Alexander

1 Like

Hello,
as stated on the linked website, this is how you do projection:

Projection or Field selection

Field selection aka. partial loading is not written as in Mongo shell: Jongo exposes a projection(..) method. A json selector must be provided: {field: 1} to include it, {field: 0} to exclude it.

So for you this means: {"ZW": 1 , "AW": 1, "ZT": 1}

Kind regards,
Alexander

1 Like

@AlexanderFillbrunn Thanks for quick response… let me try

@AlexanderFillbrunn It worked!!! :smiley:

@AlexanderFillbrunn,

Can i ask 1 more doubts ?

If Case is like…

In table-MSEG , column-BUKRS, rows- “ZW”,“AZ”,“ZT”

Bring that much data only from MSEG table, where in Column name"BUKRS", is having “ZW”,“AZ”,“ZT”…

Input data or Database or inventory:

BUKRS KUNNR ZALAT QWERTY
ZW 50 98 114
AZ 45 78 36
ZT 78 98 24
NA 89 64 65
ZT 756 344 445
AZ 89 77 12
QW 77 99 32

Output Required:

BUKRS KUNNR ZALAT QWERTY
ZW 50 98 114
AZ 45 78 36
ZT 78 98 24
ZT 756 344 445
AZ 89 77 12

See here i can use row filter node after bringing all data, but as i am having space issue in server , i just want to bring filtered data…

Please guide.
Thanks in advance!! :smiley:

Hi,
In that case ZW, AZ, and ZT must be in the query, like this:

{ $or: [ {"BUKRS": "ZW" }, {"BUKRS": "AZ" }, {"BUKRS": "ZT" } ] }

BUKRS, KUNNR, ZALAT, and QWERTY have to be in the projection then.
Kind regards,
Alexander

4 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.