Schema.org isConsumableFor Property in JSON - schema.org

Trying to sort out how to use the schema.org property isConsumableFor with JSON. I set the main product as "Raspberry Pi 4" and the isConsumableFor product "Power Supply".
The JSON snippet is built for "Raspberry Pi 4":
{
"#context":"http://schema.org/",
"#type":"Product",
"name":"Raspberry Pi 4",
"image":[
"raspberry-pi-4-model-b.jpg",
"raspberry-pi-4-model-b-2.jpg",
],
"description":"Raspberry Pi 4 ...",
"offers":{
"#type":"AggregateOffer",
"offerCount":1,
"highPrice":"40.00 ",
"lowPrice":"40.00 ",
"priceCurrency":"EUR",
"offers":[
{
"#type":"Offer",
"priceCurrency":"EUR",
"priceValidUntil":"2019-11-09T21:50:32+01:00",
"url":"Raspberry-Pi-4-Model-B",
"price":"40.00 ",
"itemCondition":"http://schema.org/New",
"availability":"http://schema.org/InStock",
}
]
}
}
On the page of Raspberry Pi 4 where do I have to kick the property "isConsumableFor"?
To Raspberry Pi 4 or to Power Supply?
{
"#context": "http://schema.org/",
"#type": "Product",
"isConsumableFor":{
"#context":"http://schema.org/",
"#type":"Product",
"name":"Raspberry Pi 4",
"url":"example.com",
},
}
or that way but if there are more consumable products available for Raspberry Pi 4 than it will repeat all the time the Raspberry Pi 4 where one time should be enough for all accessories:
{
"#context":"http://schema.org/",
"#type":"Product",
"name":"Power Supply",
"image":[
"psu.jpg",
"psu-2.jpg",
],
"description":"Power Supply ...",
"offers":{
"#type":"AggregateOffer",
"offerCount":1,
"highPrice":"8.00 ",
"lowPrice":"8.00 ",
"priceCurrency":"EUR",
"offers":[
{
"#type":"Offer",
"priceCurrency":"EUR",
"priceValidUntil":"2019-11-09T21:50:32+01:00",
"url":"powersupply",
"price":"8.00 ",
"itemCondition":"http://schema.org/New",
"availability":"http://schema.org/InStock",
}
]
},
"isConsumableFor":{
"#context":"http://schema.org/",
"#type":"Product",
"name":"Raspberry Pi 4",
}
}

Modifying your JSON-LD to the below will make it valid as far as the Structured Data Testing Tool is concerned, but there are a couple of caveats to this approach depending on how you generate your content.
I believe the best approach would be to take advantage of a global identifier (id):
Raspberry Pi
{
"#context":"http://schema.org/",
"#type":"Product",
"id":"https://example.com/raspberrypi4",
"name":"Raspberry Pi 4",
"price":"49"
...
}
Power Supply
{
"#context":"http://schema.org/",
"#type":"Product",
"name":"Power Supply",
"image":[
"psu.jpg",
"psu-2.jpg"
],
"description":"Power Supply ...",
"offers":{
"#type":"AggregateOffer",
"offerCount":1,
"highPrice":"8.00 ",
"lowPrice":"8.00 ",
"priceCurrency":"EUR",
"offers":[
{
"#type":"Offer",
"priceCurrency":"EUR",
"priceValidUntil":"2019-11-09T21:50:32+01:00",
"url":"powersupply",
"price":"8.00 ",
"itemCondition":"http://schema.org/New",
"availability":"http://schema.org/InStock"
}
]
},
"isConsumableFor":{
"#type":"Product",
"name":"Raspberry Pi 4",
"id":"https://example.com/raspberrypi4",
"offers":[{
"#type":"Offer",
"price":"49"
}]
}
}
As you can see because isConsumableFor requires a Product - that Product will still require offers, Review, or aggregateRating - so you would at least need to provide one of those properties (in this example I'm using Offer with price).
Unfortunately isConsumableFor is not very well documented on schema.org - and as of this this writing - this SO question is actually in the top four Google results for the property.
Personally I feel requiring an id or url for a nested Product should appease the requirements for Offer/aggregateRating/Review. I chalk it up to the fact that Schema is still ever growing.
With that said, the larger question might be - What are you using this Schema for? If you're looking to use it to improve Google results - I personally believe you won't find much benefit, regardless of how you use it. If you're trying to connect your data through another system via JSON-LD, then I wouldn't take the Structured Data Testing tool too seriously.

Related

mongodb: sorting by maximum values fields and exclude some values

I'm looking for right way to sort my mongodb collection by max values of lendprojectcost fields and exclude documents the value of the field countryname does not contain [East Asia and Pacific,Africa,Pacific Islands].
My code is:
db.collection.find({countryname: {$ne: 'Africa', 'East Asia and Pacific'}, {lendprojectcost: 1}})
But it doesn't work
Sample document
{
"_id":"52b213b38594d8a2be17c780",
"approvalfy":1999,
"board_approval_month":"November",
"boardapprovaldate":"2013-11-12T00:00:00Z",
"borrower":"FEDERAL DEMOCRATIC REPUBLIC OF ETHIOPIA",
"closingdate":"2018-07-07T00:00:00Z",
"country_namecode":"Federal Democratic Republic of Ethiopia!$!ET",
"countrycode":"ET",
"countryname":"Federal Democratic Republic of Ethiopia",
"countryshortname":"Ethiopia",
"docty":"Project Information Document,Indigenous Peoples Plan,Project Information Document",
"envassesmentcategorycode":"C",
"grantamt":0,
"ibrdcommamt":0,
"id":"P129828",
"idacommamt":130000000,
"impagency":"MINISTRY OF EDUCATION",
"lendinginstr":"Investment Project Financing",
"lendinginstrtype":"IN",
"lendprojectcost":550000000,
"majorsector_percent":[
{
"Name":"Education",
"Percent":46
},
{
"Name":"Education",
"Percent":26
},
{
"Name":"Public Administration, Law, and Justice",
"Percent":16
},
{
"Name":"Education",
"Percent":12
}
],
"mjsector_namecode":[
{
"name":"Education",
"code":"EX"
},
{
"name":"Education",
"code":"EX"
},
{
"name":"Public Administration, Law, and Justice",
"code":"BX"
},
{
"name":"Education",
"code":"EX"
}
],
"mjtheme":[
"Human development"
],
"mjtheme_namecode":[
{
"name":"Human development",
"code":"8"
},
{
"name":"",
"code":"11"
}
],
"mjthemecode":"8,11",
"prodline":"PE",
"prodlinetext":"IBRD/IDA",
"productlinetype":"L",
"project_abstract":{
"cdata":"The development objective of the Second Phase of General Education Quality Improvement Project for Ethiopia is to improve learning conditions in primary and secondary schools and strengthen institutions at different levels of educational administration. The project has six components. The first component is curriculum, textbooks, assessment, examinations, and inspection. This component will support improvement of learning conditions in grades KG-12 by providing increased access to teaching and learning materials and through improvements to the curriculum by assessing the strengths and weaknesses of the current curriculum. This component has following four sub-components: (i) curriculum reform and implementation; (ii) teaching and learning materials; (iii) assessment and examinations; and (iv) inspection. The second component is teacher development program (TDP). This component will support improvements in learning conditions in both primary and secondary schools by advancing the quality of teaching in general education through: (a) enhancing the training of pre-service teachers in teacher education institutions; and (b) improving the quality of in-service teacher training. This component has following three sub-components: (i) pre-service teacher training; (ii) in-service teacher training; and (iii) licensing and relicensing of teachers and school leaders. The third component is school improvement plan. This component will support the strengthening of school planning in order to improve learning outcomes, and to partly fund the school improvement plans through school grants. It has following two sub-components: (i) school improvement plan; and (ii) school grants. The fourth component is management and capacity building, including education management information systems (EMIS). This component will support management and capacity building aspect of the project. This component has following three sub-components: (i) capacity building for education planning and management; (ii) capacity building for school planning and management; and (iii) EMIS. The fifth component is improving the quality of learning and teaching in secondary schools and universities through the use of information and communications technology (ICT). It has following five sub-components: (i) national policy and institution for ICT in general education; (ii) national ICT infrastructure improvement plan for general education; (iii) develop an integrated monitoring, evaluation, and learning system specifically for the ICT component; (iv) teacher professional development in the use of ICT; and (v) provision of limited number of e-Braille display readers with the possibility to scale up to all secondary education schools based on the successful implementation and usage of the readers. The sixth component is program coordination, monitoring and evaluation, and communication. It will support institutional strengthening by developing capacities in all aspects of program coordination, monitoring and evaluation; a new sub-component on communications will support information sharing for better management and accountability. It has following three sub-components: (i) program coordination; (ii) monitoring and evaluation (M and E); and (iii) communication."
},
"project_name":"Ethiopia General Education Quality Improvement Project II",
"projectdocs":[
{
"DocTypeDesc":"Project Information Document (PID), Vol.",
"DocType":"PID",
"EntityID":"090224b081e545fb_1_0",
"DocURL":"http://www-wds.worldbank.org/servlet/WDSServlet?pcont=details&eid=090224b081e545fb_1_0",
"DocDate":"28-AUG-2013"
},
{
"DocTypeDesc":"Indigenous Peoples Plan (IP), Vol.1 of 1",
"DocType":"IP",
"EntityID":"000442464_20130920111729",
"DocURL":"http://www-wds.worldbank.org/servlet/WDSServlet?pcont=details&eid=000442464_20130920111729",
"DocDate":"01-JUL-2013"
},
{
"DocTypeDesc":"Project Information Document (PID), Vol.",
"DocType":"PID",
"EntityID":"090224b0817b19e2_1_0",
"DocURL":"http://www-wds.worldbank.org/servlet/WDSServlet?pcont=details&eid=090224b0817b19e2_1_0",
"DocDate":"22-NOV-2012"
}
],
"projectfinancialtype":"IDA",
"projectstatusdisplay":"Active",
"regionname":"Africa",
"sector":[
{
"Name":"Primary education"
},
{
"Name":"Secondary education"
},
{
"Name":"Public administration- Other social services"
},
{
"Name":"Tertiary education"
}
],
"sector1":{
"Name":"Primary education",
"Percent":46
},
"sector2":{
"Name":"Secondary education",
"Percent":26
},
"sector3":{
"Name":"Public administration- Other social services",
"Percent":16
},
"sector4":{
"Name":"Tertiary education",
"Percent":12
},
"sector_namecode":[
{
"name":"Primary education",
"code":"EP"
},
{
"name":"Secondary education",
"code":"ES"
},
{
"name":"Public administration- Other social services",
"code":"BS"
},
{
"name":"Tertiary education",
"code":"ET"
}
],
"sectorcode":"ET,BS,ES,EP",
"source":"IBRD",
"status":"Active",
"supplementprojectflg":"N",
"theme1":{
"Name":"Education for all",
"Percent":100
},
"theme_namecode":[
{
"name":"Education for all",
"code":"65"
}
],
"themecode":"65",
"totalamt":130000000,
"totalcommamt":130000000,
"url":"http://www.worldbank.org/projects/P129828/ethiopia-general-education-quality-improvement-project-ii?lang=en"
}
You can use $nin when you want to specify which values should not be returned for particular field:
db.collection.find({countryname: {$nin: ["Africa", "East Asia and Pacific"]}}).sort({lendprojectcost: -1})
If you want to sort by lendprojectcost in descending order (max value first) then you should use sort with -1 value

Multiple response in action on google dialogflow

How can i get multiple response on action on google console using dialogflow ?
i simulated on Action on google console but only two responses are showing on it
where as third response are not showing
here is my json response
{
"source": "webhook",
"data": {
"google": {
"is_ssml": true,
"permissions_request": null,
"expect_user_response": true
}
},
"messages": [
{
"type": 0,
"speech": "peter Got around 28 marks in maths. which is ranked 1 among 3 candidate in class 1"
},
{
"textToSpeech": "peter Got around 28 marks in maths. which is ranked 1 among 3 candidate in class 1",
"platform": "google",
"displayText": "peter Got around 28 marks in maths. which is ranked 1 among 3 candidate in class 1",
"type": "simple_response"
},
{
"textToSpeech": "Working",
"platform": "google",
"displayText": "Working",
"type": "simple_response"
},
{
"textToSpeech": "Working 2",
"platform": "google",
"displayText": "Working 2",
"type": "simple_response"
}
]
}
Here is my console output
any help regarding this is much appreciated
Thank you
Regards Saif
Only two simple responses will be accepted as a response. If you want more content you will need to consolidate your text into one of the two responses.
As you can see on the AoG Responses docs, it is specified as a requirement :
At most 2 chat bubbles per turn
So your third bubble won't display, as intended by Google.
As suggested in the previous answer from Nick, you need to consolidate your text and wrap everything in your 2 bubbles. In a simple response, you can line break by adding a \n where needed.
In a Basic Card however, you can access a limited subset of markdown, as stated in the docs link I provided, like that :
New line with a double space
**bold**
*italics*
Rich responses have the following requirements and optional properties that you can configure:
Supported on surfaces with the actions.capability.SCREEN_OUTPUT
capability.
The first item in a rich response must be a simple response.
At most two simple responses.
At most one basic card or StructuredResponse.
At most 8 suggestion chips. (you can add more than 8 also but you will get a warning not an error.)
Suggestion chips are not allowed in a FinalResponse
Linking out to the web from smart displays is currently not
supported.

Duplicate schema/structured data markup?

Will this structure be problematic?
<script type="application/ld+json">
{
"#context":"http://schema.org",
"#type":"WebPage",
"name":"Postcards",
"url":"https://local.mysite.com/postcards.html",
"breadcrumb":{
"#type":"BreadcrumbList",
"itemListElement":[
{
"#type":"ListItem",
"position":1,
"item":{
"#id":"https://local.mysite.com",
"name":"My Site"
}
},
{
"#type":"ListItem",
"position":2,
"item":{
"#id":"https://local.mysite.com/postcards.html",
"name":"Postcards"
}
}
]
},
"mainEntity":{
"#type":"WebPageElement",
"offers":{
"#type":"Offer",
"itemOffered":[
{
"#type":"Product",
"name":"Christmas Postcards",
"url":"https://local.mysite.com/christmas-postcards.html"
},
{
"#type":"Product",
"name":"Getaway Postcards",
"url":"https://local.mysite.com/getaway-postcards.html"
}
]
}
}
}</script>
<script type="application/ld+json">
{
"#context":"http://schema.org",
"#type":"WebPage",
"name":"Postcards",
"url":"https://local.mysite.com/postcards.html",
"breadcrumb":{
"#type":"BreadcrumbList",
"itemListElement":[
{
"#type":"ListItem",
"position":1,
"item":{
"#id":"https://local.mysite.com",
"name":"My Site"
}
},
{
"#type":"ListItem",
"position":2,
"item":{
"#id":"https://local.mysite.com/postcards.html",
"name":"Postcards"
}
}
]
},
"mainEntity":{
"#type":"WebPageElement",
"offers":{
"#type":"Offer",
"itemOffered":[
{
"#type":"Product",
"name":"Mini Postcards",
"url":"https://local.mysite.com/mini-postcards.html"
},
{
"#type":"Product",
"name":"Summer Postcards",
"url":"https://local.mysite.com/summer-postcards.html"
}
]
}
}
}</script>
The reason there could be "duplicate" markup like this for a single category page is that the page may use multiple product templates.
In the current implementation, the markup is dynamically constructed in the product template. For example, if there are two product templates for a single Category Page, the markup will be reconstructed twice, but containing different WebPageElement.
Will this yield bad results? I checked in Google's testing tool and it didn't give me any errors or warnings.
Multiple nodes, same entity
If you have multiple nodes that represent the same entity on a page, the best practice is to give these nodes the same URI as identifier.
With JSON-LD, you can provide identifiers with #id.
So
both of your WebPage items could get "#id": "" (for the current URL; preferably specify your canonical URL here),
both of your BreadcrumbList items could get "#id": "#breadcrumbs",
both of your ListItem-1 items could get "#id": "#breadcrumbs-1", and
both of your ListItem-2 items could get "#id": "#breadcrumbs-2".
That way, Google’s SDTT will display each of these items only once, because it now knows that they are about the same entity.
Referencing nodes instead of duplicating them
#id also allows you to reference nodes instead of embedding them (and thereby duplicating their data). See an example.
In your case this would have the advantage that you don’t have to duplicate the WebPage/BreadcrumbList/ListItem nodes to begin with. You would specify these nodes once, and each product template would then outpout only the Offer/Product nodes. These nodes could include (reverse) references to the WebPage/etc. (might be easier for you to implement), or the WebPage/etc. could reference these nodes.

hat is the proper structure for Parcel Delivery schema if your delivery contains multiple tracking numbers?

It is possible for our orders to contain multiple SKU's as well as multiple tracking numbers per SKU on an order.
I have been referencing https://developers.google.com/gmail/markup/reference/parcel-delivery. We are also using the JSON-LD format.
{
"#context":"http://schema.org",
"#type":"ParcelDelivery",
"deliveryAddress":{
"#type":"PostalAddress",
"name":"John Frank",
"streetAddress":"24 Willie Mays Plaza",
"addressLocality":"San Francisco",
"addressRegion":"CA",
"addressCountry":"US",
"postalCode":"94107"
},
"originAddress":{
"#type":"PostalAddress",
"name":"John Frank",
"streetAddress":"25 Willie Mays Plaza",
"addressLocality":"San Francisco",
"addressRegion":"CA",
"addressCountry":"US",
"postalCode":"94107"
},
"expectedArrivalFrom":"2013-03-10T12:00:00-08:00",
"expectedArrivalUntil":"2013-03-12T12:00:00-08:00",
"carrier":{
"#type":"Organization",
"name":"FedEx",
"url":"http://fedex.com/"
},
"itemShipped":{
"#type":"Product",
"name":"iPod Mini",
"url":"http://apple.com/ipad32gb",
"image":"http://apple.com/images/ipad32gb.jpg",
"sku":"B00DR0PDNE",
"description":"iPod Mini 32Gb White",
"brand":{
"#type":"Brand",
"name":"Apple"
},
"color":"white"
},
"trackingNumber":"3453291231",
"trackingUrl":"http://fedex.com/track/3453291231",
"potentialAction":{
"#type":"TrackAction",
"target":"http://fedex.com/track/3453291231"
},
"hasDeliveryMethod":"http://schema.org/ParcelService",
"partOfOrder":{
"#type":"Order",
"orderNumber":"176057",
"merchant":{
"#type":"Organization",
"name":"Bob Dole",
"sameAs":"http://www.freebase.com/m/0fhkx"
},
"orderStatus":"http://schema.org/OrderInTransit"
}
}
I checked previous questions on SO and can not seem to find an answer on google or in their official documentation or schema.org. Any advice would be greatly appreciated. Cheers.
Please correct me if I am wrong but after some research I am quite certain you just need to replicate the same json snippet for each parcel in the order. This is how it would work if you were not using JSON-LD so it makes sense it would work the same way. Cheers.

Difficulty using `populate` with `groupBy` and `sum` with Waterline query in Sails.js

I have run into a strange problem with the groupBy and sum methods when used with populate. I have a set of associated models: User, Source (books, etc), Recommendation, and Discipline (i.e. academic discipline).
I attempted the following waterline query:
Recommendation.find({
where: {discipline: '5559ea07dfa9bd0499f9f799'},
groupBy: ['source'], sum: ['rating']
}).exec(console.log);
This worked well, returning:
[
{
"source": "5571e72ab50f0c3c49fe19f6",
"rating": 4
},
{
"source": "5571b88c51861950360fac1c",
"rating": 12
}
]
I then tried it with populate on the source because I wanted to have the full source data linked to the each recommendation. So I tried:
Recommendation.find({
where: {discipline: '5559ea07dfa9bd0499f9f799'},
groupBy: ['source'], sum: ['rating']
}).populate('source').exec(console.log);
This yielded something strange:
[
{
"source": {
"type": "book",
"identifiers": [
{
"type": "ISBN_10",
"identifier": "1400823226"
},
{
"type": "ISBN_13",
"identifier": "9781400823222"
}
],
"title": "Patterns for America",
"subtitle": "Modernism and the Concept of Culture",
"publisher": "Princeton University Press",
"year": 1999,
"language": "en",
"categories": [
"Literary Criticism"
],
"abstract": "In recent decades, historians and social theorists have given much thought to the concept of \"culture,\" its origins in Western thought, and its usefulness for social analysis. In this book, Susan Hegeman focuses on the term's history in the United States in the first half of the twentieth century. She shows how, during this period, the term \"culture\" changed from being a technical term associated primarily with anthropology into a term of popular usage. She shows the connections between this movement of \"culture\" into the mainstream and the emergence of a distinctive \"American culture,\" with its own patterns, values, and beliefs. Hegeman points to the significant similarities between the conceptions of culture produced by anthropologists Franz Boas, Edward Sapir, Ruth Benedict, and Margaret Mead, and a diversity of other intellectuals, including Randolph Bourne, Van Wyck Brooks, Waldo Frank, and Dwight Macdonald. Hegeman reveals how relativist anthropological ideas of human culture--which stressed the distance between modern centers and \"primitive\" peripheries--came into alliance with the evaluating judgments of artists and critics. This anthropological conception provided a spatial awareness that helped develop the notion of a specifically American \"culture.\" She also shows the connections between this new view of \"culture\" and the artistic work of the period by, among others, Sherwood Anderson, Jean Toomer, Thomas Hart Benton, Nathanael West, and James Agee and depicts in a new way the richness and complexity of the modernist milieu in the United States.",
"imageLinks": {
"smallThumbnail": "http://bks3.books.google.de/books/content?id=OwYWU2H3me4C&printsec=frontcover&img=1&zoom=5&edge=curl&source=gbs_api",
"thumbnail": "http://bks3.books.google.de/books/content?id=OwYWU2H3me4C&printsec=frontcover&img=1&zoom=1&edge=curl&source=gbs_api"
},
"createdAt": "2015-06-05T14:56:12.714Z",
"updatedAt": "2015-06-05T14:56:12.724Z",
"id": "5571b88c51861950360fac1c"
},
"rating": 4
},
{
"source": {
"_bsontype": "ObjectID",
"id": "Uq¸Q\u0019P6\u000f¬\u001c"
},
"rating": 12
}
]
As you can see rather than replacing the source id with the full source properties, it added the source as an object in the returned array, and then added another object with a new source id reference, and the summed rating amount. Strangely, it also attached just one of the rating values to the source object it appended to the results.
Is this what should be happening. I can't follow the logic and it feels a bit buggy. In any case, what I would like is to have the source within each returned row, alongside the summed total. Can anyone explain what's going on here, and if I made an error perhaps?