Kendo ui grid server-side pagination not working? - kendo-ui

I'm trying to implement server-side pagination with kendo-ui grid. This is my datasource configuration.
"dataSource": {
"serverPaging": true,
"pageSize": 10,
"schema":{
"data": "data",
"total": "total"
},
"transport": {
"read": {
"url": "http://localhost:9001/category/widget/kendoGridTest/trigger/data",
"dataType": "json",
"type": "GET"
}
}
}
When I run it, it continuously sending server requests but nothing happening. The sending requests are correct and getting the expected response too. No data-binding on the grid happening.
Anyone has idea what has gone wrong here??
Edit: Server Response
{
"data": [
{
"CustomerID": "ALFKI",
"CompanyName": "Alfreds Futterkiste",
"ContactName": "Maria Anders",
"ContactTitle": "Sales Representative",
"Address": "Obere Str. 57",
"City": "Berlin"
},
{
"CustomerID": "YUI",
"CompanyName": "Alfreds Futterkiste",
"ContactName": "Maria Anders",
"ContactTitle": "Sales Representative",
"Address": "Obere Str. 57",
"City": "Berlin"
},
{
"CustomerID": "PKY",
"CompanyName": "Alfreds Futterkiste",
"ContactName": "Maria Anders",
"ContactTitle": "Sales Representative",
"Address": "Obere Str. 57",
"City": "Berlin"
},
{
"CustomerID": "PNY",
"CompanyName": "Alfreds Futterkiste",
"ContactName": "Maria Anders",
"ContactTitle": "Sales Representative",
"Address": "Obere Str. 57",
"City": "Berlin"
},
{
"CustomerID": "WSI",
"CompanyName": "Alfreds Futterkiste",
"ContactName": "Maria Anders",
"ContactTitle": "Sales Representative",
"Address": "Obere Str. 57",
"City": "Berlin"
},
{
"CustomerID": "FGH",
"CompanyName": "Alfreds Futterkiste",
"ContactName": "Maria Anders",
"ContactTitle": "Sales Representative",
"Address": "Obere Str. 57",
"City": "Berlin"
},
{
"CustomerID": "NMV",
"CompanyName": "Alfreds Futterkiste",
"ContactName": "Maria Anders",
"ContactTitle": "Sales Representative",
"Address": "Obere Str. 57",
"City": "Berlin"
}
],
"total": 7
}

Related

Elastic search query - all objects of nested array should have specific value

I want to write Elasticsearch query where I am able to look into a nested array, and check a key for all those elements inside the array, if all of them have that value then the root document should be selected.
this is a sample data :
[
{
"_index": "allproperties",
"_type": "_doc",
"_id": "5241050",
"_score": 0.0,
"_source": {
"id": 5241050,
"type": "HOUSE",
"state": "NSW",
"agency": {
"id": 31,
"code": "AU_LNT",
"name": "Luthor Properties",
"config": "{}"
},
"branch": {
"id": 89,
"name": "Luthor Sales Unit Trust",
"tradingName": "Luthor Properties",
"internalCode": "AU_LNT_G"
},
"images": null,
"leases": [
{
"id": 26439,
"bond": 2000,
"leased": true,
"source": "PORTAL",
"status": "SIGNED",
"endDate": "2022-11-06T00:00:00",
"tenants": [
{
"id": 11106,
"role": "TENANT",
"user": {
"id": 38817,
"dob": "1900-01-01",
"name": "Liam",
"email": "tempo#tempo.com",
"phone": "+61400000000",
"surname": "Tempo",
"salutation": "Mr.",
"invitations": null,
"lastInAppActivity": null
},
"address": "45675 Bruce Hwy, Coolbie QLD 4850, Australia",
"extendedData": "{\"rentSplitAmount\":22.62}",
"roleAdjective": "PRIMARY",
"addressComponents": {
"state": "QLD",
"suburb": "Coolbie",
"country": "Australia",
"postcode": "4850",
"streetName": "Bruce Hwy",
"unitNumber": null,
"poboxNumber": null,
"streetNumber": "45675",
"addressComponentsUnavailable": null
}
}
],
"signDate": "2022-10-05T04:58:08.887",
"startDate": "2022-10-06T00:00:00",
"moveInDate": "2022-10-06T00:00:00",
"appointments": [
{
"id": 3506,
"type": "REMOTE",
"date_time": "2022-10-12T04:56:00+00:00",
"createdBy": "Lex Luthor",
"createdDate": "2022-10-05T04:56:52.936",
"lastModifiedBy": "Lex Luthor",
"lastModifiedDate": "2022-10-05T04:56:53.51"
}
],
"createdDate": "2022-10-05T04:55:42.247",
"rentalAmount": 500,
"dateAvailable": null,
"extendedData": {
"last_rent_adjustment_date": 1665014400000
},
"leaseDuration": 32,
"rentalFrequency": "2",
"signedManually": false
}
],
"refId": "b66326eb-a6b2-42b6-b058-b46847e13399",
"source": "PT",
"status": null,
"suburb": "Hurstville",
"address": "456 Forest Road Hurstville NSW AUSTRALIA 2220",
"country": "Australia",
"bedrooms": 3,
"category": null,
"pmsCode": "84c34d15-a0ab-4791-b9e3-1bdac215b99c",
"postcode": "2220",
"agencyId": 31,
"bathrooms": 3,
"branchId": 89,
"carspaces": 3,
"createdBy": "system",
"streetname": "Forest Road",
"unitnumber": null,
"description": null,
"createdDate": "2022-10-05T04:51:12.619",
"entitlements": [
{
"id": 3453799,
"role": "LANDLORD",
"user": {
"id": 22855,
"dob": null,
"name": "please enter ownership name",
"email": "mag.m#rr.com.au",
"phone": "0400000000",
"surname": "",
"salutation": null,
"lastInAppActivity": null
},
"company": {
"id": 137,
"abn": "",
"acn": "",
"phone": "0400000000",
"address": "1234 Park Avenue New York NY USA 10037-1702",
"companyName": "please enter ownership name",
"displayName": "please enter ownership name",
"email": "mag.m#rr.com.au"
},
"roleAdjective": "GROUP"
},
{
"id": 3453800,
"role": "AGENT",
"user": {
"id": 20054,
"dob": null,
"name": "Paul",
"email": "p.b#mr.com",
"phone": "+61403084232",
"surname": "Botti",
"salutation": null,
"lastInAppActivity": null
},
"company": null,
"roleAdjective": "MANAGING"
},
{
"id": 3453801,
"role": "AGENT",
"user": {
"id": 20054,
"dob": null,
"name": "Paul",
"email": "p.b#mr.com",
"phone": "+61403084232",
"surname": "Botti",
"salutation": null,
"lastInAppActivity": null
},
"company": null,
"roleAdjective": "LEASING"
}
],
"streetnumber": "456",
"advertised": false,
"commission_type": null,
"lastModifiedBy": "system",
"lastModifiedDate": "2022-10-05T04:58:09.043",
"_meta": {
"branches": {
"id": [
89
]
},
"agencies": {
"id": [
31
]
},
"user_property_entitlement": {
"id": [
3453799,
3453800,
3453801
]
},
"users": {
"id": [
20054,
22855,
38817
]
},
"companies": {
"id": [
137
]
},
"leases": {
"id": [
26439
]
},
"user_lease_entitlement": {
"id": [
11106
]
},
"appointments": {
"id": [
3506
]
}
}
},
"sort": [
1664945472619,
0.0
]
}
]
In this particular case, leases is a nested document, I want to select the documents where all the leases are in cancelled state or leases is null, i.e; either all of the objects inside leases should have status as CANCELLED or the leases key should be null.
Already went through this question, but did'nt quite get it as its an old answer from 2015 and methods used in this got deprecated.
Try this query:
GET idx_test/_search?filter_path=hits.hits
{
"query": {
"bool": {
"must_not": [
{
"nested": {
"path": "leases",
"query": {
"bool": {
"must_not": [
{
"bool": {
"should": [
{
"term": {
"leases.status.keyword": "CANCELLED"
}
},
{
"bool": {
"must_not": [
{
"exists": {
"field": "leases"
}
}
]
}
}
]
}
}
]
}
}
}
}
]
}
}
}

Elasticsearch document sorting based on nested values

I have the following data indexed in my elasticsearch version 7.4.
[
{
"users": [
{
"age": "31",
"dept": "IT",
"city": "Chennai"
},
{
"age": "25",
"dept": "Accounts",
"city": "Bengaluru"
},
{
"age": "26",
"dept": "Finance",
"city": "Kochi"
}
],
"isActive": true
},
{
"users": [
{
"age": "23",
"dept": "IT",
"city": "Chennai"
},
{
"age": "22",
"dept": "Finance",
"city": "Kochi"
},
{
"age": "21",
"dept": "Accounts",
"city": "Bengaluru"
}
],
"isActive": true
},
{
"users": [
{
"age": "28",
"dept": "IT",
"city": "Chennai"
},
{
"age": "22",
"dept": "Finance",
"city": "Kochi"
},
{
"age": "21",
"dept": "Accounts",
"city": "Bengaluru"
}
],
"isActive": true
},
{
"users": [
{
"age": "31",
"dept": "IT",
"city": "Kochi"
},
{
"age": "25",
"dept": "Finance",
"city": "Bengaluru"
},
{
"age": "26",
"dept": "Accounts",
"city": "Chennai"
}
],
"isActive": true
},
{
"users": [
{
"age": "21",
"dept": "IT",
"city": "Kochi"
},
{
"age": "45",
"dept": "Accounts",
"city": "Bengaluru"
},
{
"age": "26",
"dept": "Finance",
"city": "Chennai"
}
],
"isActive": false
}
]
the users is nested type
I want to sort the documents based on the following condition
isActive == true && users.dept == "IT" && users.city == "Chennai" with the age sorts in ascending
I am expecting the following result
[
{
"users": [
{
"age": "23",
"dept": "IT",
"city": "Chennai"
},
{
"age": "22",
"dept": "Finance",
"city": "Kochi"
},
{
"age": "21",
"dept": "Accounts",
"city": "Bengaluru"
}
],
"isActive": true
},
{
"users": [
{
"age": "28",
"dept": "IT",
"city": "Chennai"
},
{
"age": "22",
"dept": "Finance",
"city": "Kochi"
},
{
"age": "21",
"dept": "Accounts",
"city": "Bengaluru"
}
],
"isActive": true
},
{
"users": [
{
"age": "31",
"dept": "IT",
"city": "Chennai"
},
{
"age": "25",
"dept": "Accounts",
"city": "Bengaluru"
},
{
"age": "26",
"dept": "Finance",
"city": "Kochi"
}
],
"isActive": true
},
{
"users": [
{
"age": "31",
"dept": "IT",
"city": "Kochi"
},
{
"age": "25",
"dept": "Finance",
"city": "Bengaluru"
},
{
"age": "26",
"dept": "Accounts",
"city": "Chennai"
}
],
"isActive": true
}
]
I tried with script based sorting, I couldn't able to achieve the result.
Please help me to sort this out.
Thanks in advance.

Magento 2 Rest api: unable to place order. getting error

Fatal error: Uncaught GuzzleHttp\Exception\ClientException: Client error: PUT http://magento.localhost.com/rest/V1/carts/4/order resulted in a 400 Bad Request response: {"message":"Please specify a shipping method."}
My codes:
$shipBill = '{
"addressInformation": {
"shipping_address": {
"id": 60,
"customer_id": 1,
"region": "Arkansas",
"region_id": 5,
"country_id": "US",
"street": [
"Whitefield,New York"
],
"company": "IBM",
"telephone": "94354545",
"postcode": "234533",
"city": "New York",
"firstname": "test",
"lastname": "test",
"prefix": "address_",
"region_code": "AR"
},
"billing_address": {
"id": 60,
"customer_id": 1,
"region": "Arkansas",
"region_id": 5,
"country_id": "US",
"street": ["Whitefield,New York"],
"company": "IBM",
"telephone": "94354545",
"postcode": "234533",
"city": "New York",
"firstname": "test",
"lastname": "test",
"prefix": "address_",
"region_code": "AR"
},
"shipping_method_code": "flatrate",
"shipping_carrier_code": "flatrate"
}
}';
$checkout = $magento->createShippingAndBilling($quoteId, $shipBill)->getInArray();
$payment = '
{
"paymentMethod": {
"method": "checkmo"
}
}';
$order = $magento->orderCreate($quoteId, $payment)->getInArray();
I have added items on a cart by the rest API. Everything is working only when I tried to place an order I am getting this error.

Query string for nested field in elasticsearch ( how to make AND work?)

I am trying to hit a query string on a nested field abc.answer which does not use any analyzer. Here is the query I am using:
{
"query": {
"nested":{
"path": "abc",
"query":{
"query_string": {
"query": "photo AND delhi",
"fields": ["answer"]
}
},
"inner_hits": {
"explain": true
}
}
},
"explain" : true,
"sort" : [ {
"_score" : { }
} ]
}
I want to search for the document which has both dtp operator and bangalore in the nested field abc. But it is not showing any results.
My nested field structure :
"abc": [
{
"updatedAt": 1452073190000,
"questionId": 1,
"labelOriginal": "name",
"createdAt": 1452073190000,
"answerOriginal": "wexe",
"answer": "wexe",
"answerId": 0,
"label": "name",
"question": "what is your name?"
},
{
"updatedAt": 1452073190000,
"questionId": 2,
"labelOriginal": "mobile",
"createdAt": 1452073190000,
"answerOriginal": "9000000000",
"answer": "9000000000",
"answerId": 0,
"label": "mobile",
"question": "What is your mobile number?"
},
{
"updatedAt": 1452073190000,
"questionId": 3,
"labelOriginal": "email id",
"createdAt": 1452073190000,
"answerOriginal": "legallss#yahoo.com",
"answer": "legallss#yahoo.com",
"answerId": 0,
"label": "email Id",
"question": "What is your e-mail id ?"
},
{
"updatedAt": 1452073190000,
"questionId": 4,
"labelOriginal": "current role",
"createdAt": 1452073190000,
"answerOriginal": "dtp operator",
"answer": "DTP Operator",
"answerId": 597,
"label": "current role",
"question": "What is your current role?"
},
{
"updatedAt": 1452073190000,
"questionId": 5,
"labelOriginal": "city",
"createdAt": 1452073190000,
"answerOriginal": "bangalore",
"answer": "Bangalore",
"answerId": 23,
"label": "city",
"question": "Which city do you live in ?"
},
{
"updatedAt": 1452073190000,
"questionId": 6,
"labelOriginal": "locality",
"createdAt": 1452073190000,
"answerOriginal": "80 ft. road",
"answer": "80 Ft. Road",
"answerId": 0,
"label": "locality",
"question": "Which locality do you live in ?"
},
{
"updatedAt": 1452073190000,
"questionId": 13,
"labelOriginal": "job type",
"createdAt": 1452073190000,
"answerOriginal": "part time jobs",
"answer": "Part Time Jobs",
"answerId": 64,
"label": "Job Type",
"question": "Are you comfortable with working Full Time or Part Time?"
},
{
"labelOriginal": "userDesiredCity",
"answerOriginal": "bangalore",
"answer": "Bangalore",
"answerId": 23,
"label": "userDesiredCity"
}
You don't need a nested functionality for this kind of query, but the flat structure of a simple array.
Make your rsa field to have include_in_parent: true:
"rsa": {
"type": "nested",
"include_in_parent": true,
"properties": {
Re-index the test documents and then use a query like this one (no nested query):
"query": {
"query_string": {
"query": "dtp operator AND bangalore",
"fields": [
"rsa.answer"
]
}
}

REQL to match string expression

I have the following json:
{
"release": {
"genres": {
"genre": "Electronic"
},
"identifiers": {
"identifier": [
{
"description": "Text",
"value": "5 709498 101026",
"type": "Barcode"
},
{
"description": "String",
"value": 5709498101026,
"type": "Barcode"
}
]
},
"status": "Accepted",
"videos": {
"video": [
{
"title": "Future 3 - Renaldo",
"duration": 446,
"description": "Future 3 - Renaldo",
"src": "http://www.youtube.com/watch?v=hpc9aQpnUjc",
"embed": true
},
{
"title": "Future 3 - Silver M from album We are the Future / 1995 Denmark / Archivos de Kraftwerkmusik",
"duration": 461,
"description": "Future 3 - Silver M from album We are the Future / 1995 Denmark / Archivos de Kraftwerkmusik",
"src": "http://www.youtube.com/watch?v=nlcHRI8iV4g",
"embed": true
},
{
"title": "Future 3 - Bubbles At Dawn",
"duration": 710,
"description": "Future 3 - Bubbles At Dawn",
"src": "http://www.youtube.com/watch?v=ABBCyvGMOFw",
"embed": true
}
]
},
"labels": {
"label": {
"catno": "APR 010CD",
"name": "April Records"
}
},
"companies": {
"company": {
"id": 26184,
"catno": "",
"name": "Voices Of Wonder",
"entity_type_name": "Published By",
"resource_url": "http://api.discogs.com/labels/26184",
"entity_type": 21
}
},
"styles": {
"style": [
"Abstract",
"IDM",
"Downtempo"
]
},
"formats": {
"format": {
"text": "",
"name": "CD",
"qty": 1,
"descriptions": {
"description": "Album"
}
}
},
"country": "Denmark",
"id": 5375,
"released": "1995-00-00",
"artists": {
"artist": {
"id": 5139,
"anv": "",
"name": "Future 3",
"role": "",
"tracks": "",
"join": ""
}
},
"title": "We Are The Future 3",
"master_id": 638422,
"tracklist": {
"track": [
{
"position": 1,
"duration": "8:04",
"title": "Future 3"
},
{
"position": 2,
"duration": "7:38",
"title": "Silver M"
},
{
"position": 3,
"duration": "7:27",
"title": "Renaldo"
},
{
"position": 4,
"duration": "6:04",
"title": "B.O.Y.D."
},
{
"position": 5,
"duration": "6:12",
"title": "Fumble"
},
{
"position": 6,
"duration": "6:12",
"title": "Dawn"
},
{
"position": 7,
"duration": "11:54",
"title": "Bubbles At Dawn"
},
{
"position": 8,
"duration": "6:03",
"title": "D.A.W.N. At 6"
},
{
"position": 9,
"duration": "8:50",
"title": 4684351684651
}
]
},
"data_quality": "Needs Vote",
"extraartists": {
"artist": [
{
"id": 2647642,
"anv": "",
"name": "Danesadwork",
"role": "Cover",
"tracks": "",
"join": ""
},
{
"id": 2647647,
"anv": "",
"name": "Djon Edvard Petersen",
"role": "Photography By",
"tracks": "",
"join": ""
},
{
"id": 114164,
"anv": "",
"name": "Anders Remmer",
"role": "Written-By",
"tracks": "",
"join": ""
},
{
"id": 435979,
"anv": "",
"name": "Jesper Skaaning",
"role": "Written-By",
"tracks": "",
"join": ""
},
{
"id": 15691,
"anv": "",
"name": "Thomas Knak",
"role": "Written-By",
"tracks": "",
"join": ""
}
]
},
"notes": "© 1995 April Records APS ℗ 1995 April Records APS"
}
}
I am trying to get those titles which end with 'At Dawn'.
I am using the following command
r.db("discogs1").table("releases").filter(function(doc){ return doc('release')('title').match('At Dawn$')})
But I get errors as follows:
RqlRuntimeError: Expected type STRING but found NUMBER in:r.db("discogs1").table("releases").filter(function(var_24) { return var_24("release")("title").match("At Dawn$"); })
I tried different combinations but I can't seem to get it to work
It seems that some of your documents don't have a row('release')('title') property that is a string. Some of them are numbers, so when you try to call .match on them, they throw an error because .match only works on strings.
To see if this is true, try the following:
r.db("discogs1").table("releases")
.filter(r.row('release')('title').typeOf().ne('STRING'))
.count()
Ideally, the result of this should be 0, since no document should have a title property that's not a string. If it's higher than 0, that's why you're getting an error.
If you want to only get documents where the title is a string, you can do the following:
r.db("discogs1").table("releases")
.filter(r.row('release')('title').typeOf().eq('STRING'))
.filter(function(doc){ return doc('release')('title').match('At Dawn$')})
This query will work, because it will filter our all documents where the title is not a string.
If you want to coerce all title into strings, you can do the following:
r.db("discogs1").table("releases")
.filter(r.row('release')('title').typeOf().ne('STRING'))
.merge(function (row) {
return {
'title': row('title').coerceTo('string')
}
})
If you want to delete all documents where the title is not a string, you can do this:
r.db("discogs1").table("releases")
.filter(r.row('release')('title').typeOf().ne('STRING'))
.delete()

Resources