Query mongoDb with REST interface -


this collections:

{   "offset" : 0,   "rows": [      {       "_id" : { "$oid" : "5199e109f456aab938b304de" },        "type" : "cluster",        "id" : "1",        "vertices_transformation" : [ [ 1, 0, 0 ], [ 0, 1, 0 ], [ 0, 0, 1 ] ],        "vertices" : [ [ 1, 0, 0 ], [ 0, 1, 0 ], [ 0, 0, 1 ] ],        "v_attributes" : [[0.5,0.8,1], [0.6,0.9,1], [0.44,0.8,0.7],[0,1,0]]     },     {       "_id" : { "$oid" : "5199d8f8f456aab938b304db" },        "type" : "model",        "id" : "modello1",        "name" : "modello 1",        "description" : "1 modello di prova",        "clusters" : [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 ],        "clusters_tree" : [ 1, 2, 3, [ 4, 5, 6, 7 ], [ 8, 9, 10, 11 ] ]      }   ],   "total_rows" : 2,   "query" : { "type" : "cluster", "id" : 1 } ,   "millis" : 1 } 

i want filter type , after id, query:

http://xxxx/db/collections/?filter_type=cluster&filter_id=1 

but result of query 0 rows,but if query type ,the row succesfully returned. why query not work id?

thanks in advance help.

the reason type mismatch:

// record: "id" : "1" // id string  // query "id" : 1   // id number 

apparently, rest interface implicit conversion on query parameters number. don't know how can prevent happening, though.

edit: httpie can send query json, in message body. works:

$ http 'http://127.0.0.1:28017/db/collection/' 'filter_id=678'  ... {   "filter_id": "678" // id sent string } ... "total_rows" : 1     // , matched record 

i don't know client you're using, try sending query json in body (but make get request, when use post mongodb things you're creating record).


Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -