1
db.${collection=none}.find( {}, { ${key=none}: [ { $eq: "${value=none}" } ] } ).table()

When I execute the code listed above in zeppelin, It is supposed to look for a exact result in the key based on the value I enter in the ${value=none} box but it does not filter it. It just shows all the data. Any ideas why? and how to fix?

  • You might show the data now you are getting and the data you expect to get as well as the query I would think. I don't know MongoDB but this looks like JSON format type data but perhaps that's how the logic work with this language. In any case, can you provide any test data and results you get now and show results you would like instead? – Vomit IT - Chunky Mess Style Jul 20 '17 at 04:07

1 Answers1

0

The MongoDB interpreter for Zeppelin uses the same syntax as the mongo shell: db.collection.find(query, projection).

Your first parameter of {} matches all documents. The second parameter will be interpreted as a projection (although your syntax is unnecessarily complex).

Since $eq is equivalent to {field: "value"} and you only have a single value, your query can be more clearly expressed as:

db.${collection=none}.find({ ${key=none}: "${value=none}" }).table()

If your intent is to provide a more generic input form (rather than prompting for a single key/value pair) you might want to placeholder the query and projection instead, eg:

empty = {}  // Placeholder for empty documents
db.${collection=none}.find(${query=empty},${projection=empty}).table()

In this second example your query would be expressed as { field: "value" } in the Zeppelin input form. You could also specify additional query criteria and a projection for fields to include in the results.

Stennie
  • 214