These are chat archives for getredash/redash

6th
Jul 2015
j0t3x
@j0t3x
Jul 06 2015 03:26
hey guys i got a connection to mongodb database with my redash
but the problem is everytime i make a query i get this message
Error running query: Invalid query format. The query is not a valid JSON.
hello
Arik Fraimovich
@arikfr
Jul 06 2015 03:32
@j0t3x can you give an example for a query you're trying to run?
j0t3x
@j0t3x
Jul 06 2015 03:43
yeah sure
db.persons.aggregate([
  {$unwind: "$personal.stat"}
      ])
j0t3x
@j0t3x
Jul 06 2015 04:03
@arikfr still there?
Arik Fraimovich
@arikfr
Jul 06 2015 04:10
@j0t3x taking my daughter to the kindergarten... Will be back in 30m or so.
j0t3x
@j0t3x
Jul 06 2015 04:10
ok thanks
Arik Fraimovich
@arikfr
Jul 06 2015 04:58
@j0t3x I never used mongo in redash myself, but looking at the documentation comments in the code, it seems the query needs to be a json "description" of the query:
# Simple query example:
#
# {
#     "collection" : "my_collection",
#     "query" : {
#         "date" : {
#             "$gt" : "ISODate(\"2015-01-15 11:41\")",
#         },
#         "type" : 1
#     },
#     "fields" : {
#         "_id" : 1,
#         "name" : 2
#     },
#     "sort" : [
#        {
#             "name" : "date",
#             "direction" : -1
#        }
#     ]
#
# }
#
#
# Aggregation
# ===========
# Uses a syntax similar to the one used in PyMongo, however to support the
# correct order of sorting, it uses a regular list for the "$sort" operation
# that converts into a SON (sorted dictionary) object before execution.
#
# Aggregation query example:
#
# {
#     "collection" : "things",
#     "aggregate" : [
#         {
#             "$unwind" : "$tags"
#         },
#         {
#             "$group" : {
#                 "_id" : "$tags",
#                 "count" : { "$sum" : 1 }
#             }
#         },
#         {
#             "$sort" : [
#                 {
#                     "name" : "count",
#                     "direction" : -1
#                 },
#                 {
#                     "name" : "_id",
#                     "direction" : -1
#                 }
#             ]
#         }
#     ]
# }
j0t3x
@j0t3x
Jul 06 2015 06:07
Great man! Totally different to a normal mongo query, that should work, ill test it tomorrow and tell you how it went
Arik Fraimovich
@arikfr
Jul 06 2015 07:09
@j0t3x :+1: