Query in MongoDB reader

Hi!! Knime Experts…
Hope You are doing well.

I am facing issue in extracting data using MongoDB reader, can you correct me in writing query:

INPUT:

BUKRS BLART AMT
1100 RE 89
1200 RE 45
1101 ZE 78
1100 RE 41
1100 GE 23
1201 RF 98
1010 ZE 32
1100 RE 99

Requirement:

Just extract that much data where Column:BUKRS is 1100 & BLART: “RE”.

Output:

BUKRS BLART AMT
1100 RE 89
1100 RE 41
1100 RE 99

My Query:
I am using this query: {$or: [{“BUKRS”: “1100”}, {“BLART” : “RE”}]}

But this is satisfying only BUKRS condition, I want to satisfy both condition.

Thanks In advance.

Hi,
if you want it to satisfy both conditions, you have to use $and instead of $or.
Kind regards,
Alexander

1 Like

@AlexanderFillbrunn thanks for answer…

Will check & come back.

@AlexanderFillbrunn
After changing to below, Empty data set is coming… & i have cross check there is data
{$and: [{“BUKRS”: “1100”}, {“BLART”:“RE”},{“BLART”: “KR”}]}

Hi,
Are you sure there is no typo in the data? If $or works, I think there is just no data with exactly those values.
Kind regards,
Alexander

2 Likes

@AlexanderFillbrunn

I have checked. But $and works for 3 condition also ?

Hi,
yes, that should work: https://docs.mongodb.com/manual/reference/operator/query/and/#op._S_and.
Kind regards,
Alexander

1 Like

@AlexanderFillbrunn

Ok thanks,

will again look into data.

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