Today I try to $set a DBRef with $db to collection.
But server say: "not okForStorage" , so operation is failed.
ps. my mongod version is 2.2
{
"ts" : ISODate("2013-01-16T14:05:42.814Z"),
"op" : "update",
"ns" : "mydb.coll1",
"query" : {
"_id" : NumberLong("928686353793211381")
},
"updateobj" : {
"$set" : {
"ref" : {
"$db" : "db2",
"$ref" : "coll2",
"$id" : NumberLong("928686353793211381")
}
}
},
"nscanned" : 1,
"keyUpdates" : 0,
"numYield" : 0,
"lockStats" : {
"timeLockedMicros" : {
"r" : NumberLong(0),
"w" : NumberLong(200)
},
"timeAcquiringMicros" : {
"r" : NumberLong(0),
"w" : NumberLong(5)
}
},
"exception" : "not okForStorage",
"exceptionCode" : 12527,
"millis" : 0,
"client" : "10.168.89.9",
"user" : ""
}
According to the docs, the order of the fields in the DBRef matters; so you'd need to reorder your ref object as:
"ref" : {
"$ref" : "coll2",
"$id" : NumberLong("928686353793211381"),
"$db" : "db2"
}
Related
I'm integrating paypal in our shopping system.
I'm using the Java Api.
In the current form the process is the following:
The user chooses paypal as payment and clicks on "Pay Order"
The Server sends a an createOrder Request with Capture Intent.
The Server receives a response with links.
The user is redirected to the "approve" link.
After finishing paypal redirects the user to the shop page with the "thanks for your order message".
All this is working as expected.
But no payment is done / no money transfered.
What am I doing wrong here?
Thanks in advance!
For reference the request/response:
Request: {}, {
"application_context" : {
"user_action" : "PAY_NOW",
"landing_page" : "BILLING",
"return_url" : "https://www.foobar.de.localhost:8443/payment/paypal?result=ok&order_id=MGS063464&secret=2E1C1B304178...",
"brand_name" : "<removed>",
"cancel_url" : "https://www.foobar.de.localhost:8443/payment/paypal?result=cancel&order_id=MGS063464",
"shipping_preference" : "SET_PROVIDED_ADDRESS"
},
"purchase_units" : [ {
"amount" : {
"breakdown" : {
"shipping" : {
"value" : "3",
"currency_code" : "EUR"
},
"item_total" : {
"value" : "2.45",
"currency_code" : "EUR"
}
},
"value" : "5.45",
"currency_code" : "EUR"
},
"reference_id" : "MGS063464",
"shipping" : {
"address" : {
"country_code" : "DE",
"address_line_1" : "<removed>",
"admin_area_2" : "<removed>",
"postal_code" : "<removed>"
},
"name" : {
"full_name" : "<removed>"
}
},
"description" : "<removed>,
"items" : [ {
"quantity" : "1",
"name" : "<removed>",
"unit_amount" : {
"value" : "2.45",
"currency_code" : "EUR"
},
"sku" : "OCI08"
} ]
} ],
"intent" : "CAPTURE"
}
Response: {}, {
"create_time" : "2021-03-14T10:52:46Z",
"purchase_units" : [ {
"payee" : {
"email_address" : "<removed>",
"merchant_id" : "L4EC8HB5DTVSC"
},
"amount" : {
"breakdown" : {
"shipping" : {
"value" : "3.00",
"currency_code" : "EUR"
},
"item_total" : {
"value" : "2.45",
"currency_code" : "EUR"
}
},
"value" : "5.45",
"currency_code" : "EUR"
},
"reference_id" : "MGS063464",
"shipping" : {
"address" : {
"country_code" : "DE",
"address_line_1" : "<removed>",
"admin_area_2" : "<removed>",
"postal_code" : "<removed>"
},
"name" : {
"full_name" : "<removed>"
}
},
"description" : "<removed>",
"items" : [ {
"quantity" : "1",
"name" : "<removed>",
"unit_amount" : {
"value" : "2.45",
"currency_code" : "EUR"
},
"sku" : "OCI08"
} ]
} ],
"links" : [ {
"method" : "GET",
"rel" : "self",
"href" : "https://api.sandbox.paypal.com/v2/checkout/orders/5MY66978KX626104P"
}, {
"method" : "GET",
"rel" : "approve",
"href" : "https://www.sandbox.paypal.com/checkoutnow?token=5MY66978KX626104P"
}, {
"method" : "PATCH",
"rel" : "update",
"href" : "https://api.sandbox.paypal.com/v2/checkout/orders/5MY66978KX626104P"
}, {
"method" : "POST",
"rel" : "capture",
"href" : "https://api.sandbox.paypal.com/v2/checkout/orders/5MY66978KX626104P/capture"
} ],
"id" : "5MY66978KX626104P",
"intent" : "CAPTURE",
"status" : "CREATED"
}
You are missing an API call, step 5 should instead be: The Server sends a Capture Order request.
Your final Step 6 should be to thank the buyer only if the capture was successful
See 'Capture Order' in the documentation.
Redirecting to an "approve" link is an old integration method, for old websites. For a modern user experience you should keep your page loaded (not redirect away) by changing your 'Create Order' and 'Capture Order' to be two server routes that return only JSON data (no other HTML or text)
Pair those routes with the following approval flow: https://developer.paypal.com/demo/checkout/#/pattern/server
{
"merchantId" : "M168976258",
"catalogTypeId" : "catalogTypeProduct",
"items" : [
{
"name" : "Product 1",
"location" : {
"type" : "Point",
"coordinates" : [
0,
0
]
}
},
{
"name" : "Product 2",
"location" : {
"type" : "Point",
"coordinates" : [
0,
0
]
}
},
{
"name" : "Product 3",
"location" : {
"type" : "Point",
"coordinates" : [
0,
0
]
}
}
}
I able to Perfrom mongo near command on document which is having single location
using below command
db.abc.find({
location :{
$near : {
$geometry : {
index : "Point" ,
coordinates : [19.1, 72.89]
},
$maxDistance : 10000
}
}
})
but i'm not able to perform on document which having nested array can anybody help me out to find out problem
By running this query i get following error
db.catalogForAdminAndMerchant.find({
"items.location" :{
$near : {
$geometry : {
index : "Point" ,
coordinates : [19.1, 72.89]
},
$maxDistance : 10000
}
}
})
o/p is
planner returned error: unable to find index for $geoNear query
but have created the index
by running db.catalogForAdminAndMerchant.getIndexes() i get
/* 1 */
{
"v" : 1,
"key" : {
"_id" : 1
},
"name" : "_id_",
"ns" : "catalog-db.catalogForAdminAndMerchant"
},
/* 2 */
{
"v" : 1,
"key" : {
"_fts" : "text",
"_ftsx" : 1
},
"name" : "CatalogForAdminAndMerchant_TextIndex",
"ns" : "catalog-db.catalogForAdminAndMerchant",
"weights" : {
"items.name" : 3
},
"default_language" : "english",
"language_override" : "language",
"textIndexVersion" : 3
},
/* 3 */
{
"v" : 2,
"key" : {
"address.items[i].location" : "2dsphere"
},
"name" : "address.items[i].location_2dsphere",
"ns" : "catalog-db.catalogForAdminAndMerchant",
"2dsphereIndexVersion" : 3
}
I have the following code:
final String index = ElasticSearchUtils.getIndexNameForExecution(queryId);
SearchRequestBuilder query = client.prepareSearch(index);
query.setTypes(indexType.toString());
query.addAggregation(terms("errors").field("code").size(NUMBER_OF_HITS).order(Terms.Order.count(false)));
int pageStart = getFrom(page) * size;
SearchResponse response = query.setFrom(pageStart).setSize(getPageSize(size)).execute().actionGet();
return response.toString();
and part of response is:
{
"took" : 78,
"timed_out" : false,
"_shards" : {
"total" : 2,
"successful" : 2,
"failed" : 0
},
"hits" : {
"total" : 2,
"max_score" : 1.0,
"hits" : [ {
"_index" : "index_587e1e34e4b040c63c49137f",
"_type" : "ERROR",
"_id" : "AVmspgsKa7ZIkZu1p32G",
"_score" : 1.0,
"_source" : {
"agent_id" : "{8668b249-9443-e611-87c6-005056aa41d1}",
"_v" : "1",
"host" : "RHEL65-X86-DEMO",
"created_at" : "2017-01-17T13:37:58.496Z",
"qid" : "587e1e34e4b040c63c49137f",
"errors" : [ {
"code" : 769,
"module" : "FileHashing",
"function" : "FindFiles"
} ]
}
}, {
"_index" : "index_587e1e34e4b040c63c49137f",
"_type" : "ERROR",
"_id" : "AVmspgsKa7ZIkZu1p32H",
"_score" : 1.0,
"_source" : {
"agent_id" : "{7238f027-fbfc-47cf-85b0-c69838e26a2a}",
"_v" : "1",
"host" : "W8-X64-DEMO",
"created_at" : "2017-01-17T13:37:58.501Z",
"qid" : "587e1e34e4b040c63c49137f",
"errors" : [ {
"code" : 769,
"module" : "FileHashing",
"function" : "FindFiles"
} ]
}
} ]
},
"aggregations" : {
"errors" : {
"doc_count_error_upper_bound" : 0,
"sum_other_doc_count" : 0,
"buckets" : [ ]
}
}
}
And the result of search execution is:
As you can see the buckets is empty [], aggregation is not working, but any exception is throwing. This is occurring with elasticsearch 2.4.1, the same code is working with elasticsearch 1.4.1
You simply need to fix this line
query.addAggregation(terms("errors").field("errors.code").size(NUMBER_OF_HITS).order(Terms.Order.count(false)));
^
|
add this
I have my collection as shown below:
{
"_id" : NumberLong(366),
"file" : "xyz",
"clist" : {
"account" : "BFS",
"subAccount":"a"
},
},
{
"_id" : NumberLong(366),
"file" : "xyz",
"clist" : {
"account" : "BFS",
"subAccount":"b"
},
},
{
"_id" : NumberLong(366),
"file" : "xyz",
"clist" : {
"account" : "HC",
"subAccount":"c"
},
}
In that I have to group by account and count number of subAccount; for example:
{
account : "BFS",
subAccount : "b",
count : 1,
subAccount :"a",
count : 1
}
If for account BFS, subAccount b exists two times, then I should get output like this:
{
account : "BFS",
subAccount : "b",
count : 2,
subAccount : "a",
count : 1
}
May this help you...
db.coll.aggregate([ {
"$group" : {
"_id" : {
"account" : "$clist.account",
"subAccount" : "$clist.subAccount"
},
"count" : {
"$sum" : 1
}
}
}, {
$project : {
_id : 0,
"account" : "$_id.account",
"subAccount" : "$_id.subAccount",
"count" : "$count"
}
}, {
$group : {
_id : "$account",
"subaccounts" : {
"$push" : {
"subAccount" : "$subAccount",
"count" : "$count"
}
}
}
} ])
I want to get result where varifiedDate inside secondaryParents is not 0. How can I achieve this?
DB Structure:
{
"_id" : ObjectId("577a151859defb33c0f8bf4a"),
"_class" : "com.nv.tracker.db.model.User",
"parentId" : NumberLong(1000004),
"userId" : NumberLong(1000005),
"firstName" : "Pranav",
"lastName" : "Rathore",
"addr" : {
"address" : "",
"landmark" : "",
"city" : "",
"state" : "",
"country" : ""
},
"email" : "ashish.dubey#newvisionsoftware.in",
"mobile" : "7879066069",
"createdDate" : ISODate("2016-07-04T07:49:44.000Z"),
"activeStatus" : false,
"imagePath" : "http://172.20.0.210:8080/nvtracker/rest/resource/image/1000005",
"deviceId" : "78 79 066069",
"isSuperUser" : false,
"dob" : "1468348200000",
"checkAndriodOrIos" : 0,
"isLogin" : false,
"otp" : 0,
"batteryLevel" : 30,
"locationInterval" : 60,
"deviceSpeed" : 45,
"primaryMobile" : "9039101994",
"secondaryMobile1" : "9039101994",
"secondaryMobile2" : "",
"primaryEmail" : "ashish.dubey#newvisionsoftware.in",
"secondaryEmail1" : "abb#hh.con",
"secondaryEmail2" : "",
"isVerified" : false,
"currentBatteryLevel" : 0,
"currentSpeed" : 0,
"subscriptionExpDate" : NumberLong(1498132426000),
"enableNotification" : 1,
"enableTakeOffAlert" : 0,
"deleted" : false,
"hasExternalDevice" : false,
"secondaryParents" : {
"1000003" : {
"secondaryparentId" : NumberLong(1000003),
"varifiedDate" : NumberLong(14676286792586),
"addedDate" : NumberLong(1467628679286),
"secreteCode" : "18716"
},
"1000004" : {
"secondaryparentId" : NumberLong(1000004),
"varifiedDate" : NumberLong(0),
"addedDate" : NumberLong(1467628679286),
"secreteCode" : "18716"
}
}
}
I want to get the user where varifiedDate inside secondaryParents is not 0.
Please suggest how I can achieve this. Also provide the best tutorial for 'mongodb using java' with criteria API.