Skip to main content
Solved

How does one apply a filter to the MongoDB reader to limit results?

  • April 5, 2017
  • 2 replies
  • 41 views

andrew_r
Contributor
Forum|alt.badge.img+4

I'm a GIS guy and new to MongoDB. I'm trying to use FME to read and analyze data in a Mongo database. The collection I'm trying to read has 10 million plus records so I'd like to be able to filter that down to a subset for testing. If this was an Oracle or ArcGIS reader I'd place a SQL whereclause on the reader to limit what FME starts with. On the MongoDB reader I don't see a whereclause option. I see a Collection Qualifer and a JSON query parameter on the Feature Type window, so is this where I would apply a MongoDB filter? I tried entering so MongoDB'ish find() code in this but it doesn't work, so maybe I'm entering it wrong.

To simplify an example, here's what I'd like to do on my reader in SQL:

select * from MyTable where MyStringField = 'MyClassification'

And here's the Mongo translation of the same thing:

db.MyTable.find({ "MyStringField": "MyClassification" });

Now I'm left figuring out how to apply that same filter in the FME world

Thanks for any help you can provide

Best answer by jakemolnar

You found the right field: the JSON Query parameter.

If you enter:

{ "MyStringField": "MyClassification" }

into the field, then you should get the result you're looking for.

This will be added to future version of the MongoDB reader documentation.

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

2 replies

jakemolnar
Forum|alt.badge.img
  • Best Answer
  • April 14, 2017

You found the right field: the JSON Query parameter.

If you enter:

{ "MyStringField": "MyClassification" }

into the field, then you should get the result you're looking for.

This will be added to future version of the MongoDB reader documentation.


andrew_r
Contributor
Forum|alt.badge.img+4
  • Author
  • Contributor
  • April 20, 2017

You found the right field: the JSON Query parameter.

If you enter:

{ "MyStringField": "MyClassification" }

into the field, then you should get the result you're looking for.

This will be added to future version of the MongoDB reader documentation.

Thank you!