Schema Data for a School - schema.org

Best Schema Practiced for School with Subdivisions
I am interested in best SEO practices for creating schema markup for a School that has subdivisions: Preschool, ElementarySchool, MiddleSchool, and HighSchool. My plan initially is to create JSON-LD for each of the division pages and the home page.
My questions are:
is this a good method of doing this and in line with best schema practices?
When using schema, what is the best method of associating a subdivision of a school with the school?
Would it be appropriate to use the schema contactPoint to mark up each of the names and phone numbers on the contact page?
Are there any opportunities I should take advantage of or pitfalls I should avoid?
I have included JSON-LD code for what I'm thinking the code for some of these pages might look like.
Home Page:
<script type='application/ld+json'>
{
"#context": "http://schema.org/",
"#type": "School",
"address": {
"#type": "PostalAddress",
"addressCountry": "Country",
"addressLocality": "City",
"addressRegion": "State",
"postalCode": "12345",
"streetAddress": "123 School St",
"telephone": "+15432190100",
"description": "This is a very good school"
},
"areaServed": "City",
"name": "School",
"url": "https://www.school.edu",
"sameAs": [
"https://www.facebook.com/school",
"https://www.youtube.com/user/school",
"http://twitter.com/school",
"https://www.instagram.com/school/"
]
}
</script>
Preschool Page
Note: The phone number and name are different but the address is the same. Would this be duplicate or spammy in Google's eyes?
<!--Preschool-->
<script type='application/ld+json'>
{
"#context": "http://schema.org/",
"#type": "Preschool",
"address": {
"#type": "PostalAddress",
"addressCountry": "Country",
"addressLocality": "City",
"addressRegion": "State",
"postalCode": "12345",
"streetAddress": "123 School St",
"telephone": "+15432190101",
"description": "School has a very good preschool"
},
"areaServed": "City",
"name": "School - Preschool",
"url": "https://www.school.edu/preschool",
"parentOrganization": {
"#type": "School",
"name": "School"
}
}
</script>

I tried to provide you the best solution with all possibilities.
Let's clear your doubts first.
Ans1: You are going in the right direction though structure needs to be modified as shown in below code.
Ans2: For implementing Subdivision, the best method is to use Educational Organization Schema which provides SubOrganization.
Ans3: You can check the use of contactPoint in your case in below given code.
Ans4: There aren't any pitfalls if you are doing that properly.
Below JSON-LD contains all the structure that you might require like School, PreSchool, MiddleSchool etc.
<script type="application/ld+json">
{
"#context": "http://schema.org",
"#type": "EducationalOrganization",
"name" : "School",
"address": {
"#type": "PostalAddress",
"addressCountry": "IN",
"addressLocality": "City",
"addressRegion": "State",
"postalCode": "000000",
"streetAddress": "#310 Example",
"telephone": "+15432190100",
"description": "This is a very good school"
},
"areaServed": "City",
"#id" : "http://www.example.com/homepage-url",
"url": "http://www.example.com/",
"logo": "http://www.example.com/images/logo.png",
"email" : "example#example.com",
"sameAs": [
"https://www.facebook.com/example",
"http://twitter.com/example",
"https://www.instagram.com/example"
],
"subOrganization" : [
{
"#type": "Preschool",
"name" : "Preschool 1",
"telephone" : "+1-877-672-7777",
"#id" : "http://www.example.com/preschool-1",
"url": "http://www.example.com/preschool-1",
"address":{
"#type":"PostalAddress",
"streetAddress":"#310 Example",
"addressLocality":"City",
"addressRegion":"State",
"postalCode":"000000",
"addressCountry":"IN"
},
"contactPoint" : [
{ "#type" : "ContactPoint",
"telephone" : "+1-877-746-0909",
"contactType" : "Customer Service",
"contactOption" : "TollFree",
"areaServed" : "IN"
} ,
{ "#type" : "ContactPoint",
"telephone" : "+1-877-746-0606",
"contactType" : "Bill Payment",
"contactOption" : "TollFree",
"areaServed" : "IN"
}
]
},
{
"#type": "Preschool",
"name" : "Preschool 2",
"telephone" : "+1-877-672-8888",
"#id" : "http://www.example.com/preschool-2",
"url": "http://www.example.com/preschool-2",
"address":{
"#type":"PostalAddress",
"streetAddress":"#310 Example",
"addressLocality":"City",
"addressRegion":"State",
"postalCode":"000000",
"addressCountry":"IN"
},
"contactPoint" : [
{ "#type" : "ContactPoint",
"telephone" : "+1-877-746-3030",
"contactType" : "Customer Service",
"contactOption" : "TollFree",
"areaServed" : "IN"
} ,
{ "#type" : "ContactPoint",
"telephone" : "+1-877-746-2020",
"contactType" : "Bill Payment",
"contactOption" : "TollFree",
"areaServed" : "IN"
}
]
},
{
"#type": "MiddleSchool",
"name" : "MiddleSchool 1",
"telephone" : "+1-877-672-9999",
"#id" : "http://www.example.com/middleschool-1",
"url": "http://www.example.com/middleschool-1",
"address":{
"#type":"PostalAddress",
"streetAddress":"#310 Example",
"addressLocality":"City",
"addressRegion":"State",
"postalCode":"000000",
"addressCountry":"IN"
}
},
{
"#type": "MiddleSchool",
"name" : "MiddleSchool 2",
"telephone" : "+1-877-672-0000",
"#id" : "http://www.example.com/middleschool-2",
"url": "http://www.example.com/middleschool-2",
"address":{
"#type":"PostalAddress",
"streetAddress":"#310 Example",
"addressLocality":"City",
"addressRegion":"State",
"postalCode":"000000",
"addressCountry":"IN"
}
}
]
}
</script>
The above code is also verified with Google Structured Data Testing Tool.
Attaching the screenshot for your reference.
Don't worry about "Uncategorized Error", it's likely a Bug in Google Schema Tool.
More info about that error here.
Hope it works :)

Related

Mongotemplate project to exclude fields from nested List

There are two different collections :
Collection 1-
Recipe: {
"UID": "R001",
"name" : "RecipeName",
"chef" : "XYZ",
"ingredients" : ["I001", "I002", "I003"],
"price" : "999"
}
Ingredients: {
"UID": "I001",
"name": "Ingredient1",
"price" : "100",
"DisplayName": "Ingredient One"
}
Using mongotemplate i am able to lookup and fetch list objects like below :
[{
"UID": "R001",
"name" : "RecipeName",
"ingredients" : [
{
"UID": "I001",
"name": "Ingredient1",
"price" : "100",
"displayName": "Ingredient One"
}]
}]
However in result i am not able to use the project for the ingredients list, where i want to include only selected details like UID and displayName.
[{
"UID": "R001",
"name" : "RecipeName",
"ingredients" : [
{
"UID": "I001",
"displayName": "Ingredient One"
}]
}]

How to correct document validation fail in Mongodb?

Ive created the following collection(the creation of which is successful)
db.createCollection("Company", { "validator": { "$jsonSchema": {
"bsonType":"object",
"required":["city_name","city","street_name","building_number","budget","Department"],
"properties":{ "city_name":{ "bsonType":"string",
"description":"name of city" },
"city":{ "bsonType":"string",
"description":"City" },
"street_name":{ "bsonType":"string",
"description" :"name of street" },
"building_number":{"bsonType":"int",
"description":"number of building", minimum: 0, maximum: 500},
"budget":{"bsonType":"double",
"description":"budget of company",minimum: 0 },
"Department":{ "bsonType":"object",
"required":["Department_name","floor_number","Employee"],
"properties":{ "Department_name":{"bsonType":"string",
"description": "name of department" },
"floor_number":{"bsonType":"int",
"description":"number of floor" },
}},
"Employee":{ "bsonType":"object",
"required":["first_name","last_name","DOB","Salary"],
"properties":{"first_name":{"bsonType":"string",
"description":"Employees first name"},
"last_name":{"bsonType":"string",
"description":"Employees last name"},
"DOB":{"bsonType":"date",
"description":"Date of birth of empployee"},
"Salary":{"bsonType":"double",
"description":"Salary of Employee",minimum: 0},
"Position":{"bsonType":"string",
"description":"Position of employee. Field is not required"}}}}}}});
Ive created a set of data to insert into this collection to test the validations
db.Company.insert(
{ "city_name":"Sydney",
"city":"Sydney",
"street_name":"Pitt Street",
"building_number":100,
"budget": 100000.0,
"Department":{"department_name":"Google",
"floor_number":4,
"Employee" :{"first_name" : "George",
"last_name": "Martin",
"DOB": new Date('Dec 26,1981'),
"Salary" : "70000",
"Position": "CEO"}}
});
However when i run this script i get an error
WriteResult({
"nInserted" : 0,
"writeError" : {
"code" : 121,
"errmsg" : "Document failed validation"
}
})
Sadly Mongodb isnt very specific in what causes such errors and ive gone through my syntax and declarations and could not pick up on any errors myself,when clearly there is!
Why am i recieving this error when running my code? Thankyou
Try this:
01) Schema:
db.createCollection(
"Company",
{
"validator": {
"$jsonSchema": {
"bsonType":"object",
"required":["city_name","city","street_name","building_number","budget","Department"],
"properties": {
"city_name":{ "bsonType" : "string", "description" : "name of city" },
"city":{ "bsonType" : "string", "description" : "City" },
"street_name":{ "bsonType" : "string","description" : "name of street" },
"building_number": { "bsonType" : "int", "description" : "number of building", minimum: 0, maximum: 500},
"budget": { "bsonType" : "double", "description" : "budget of company",minimum: 0 },
"Department": {
"bsonType":"object",
"required":["Department_name","floor_number","Employee"],
"properties": {
"Department_name":{"bsonType":"string", "description": "name of department" },
"floor_number":{"bsonType":"int", "description":"number of floor" },
"Employee":{
"bsonType":"object",
"required":["first_name","last_name","DOB","Salary"],
"properties":{
"first_name":{"bsonType":"string", "description":"Employees first name"},
"last_name":{"bsonType":"string", "description":"Employees last name"},
"DOB":{"bsonType":"date", "description":"Date of birth of empployee"},
"Salary":{"bsonType":"double", "description":"Salary of Employee",minimum: 0},
"Position":{"bsonType":"string", "description":"Position of employee. Field is not required"}
}
}
}
},
}
}
}
}
);
02) Insert:
db.Company.insert(
{
"city_name": "Sydney",
"city": "Sydney",
"street_name": "Pitt Street",
"building_number": NumberInt(100),
"budget": 100000.0,
"Department":{
"Department_name":"Google",
"floor_number": NumberInt(4),
"Employee" : {
"first_name" : "George",
"last_name": "Martin",
"DOB": new Date('Dec 26,1981'),
"Salary" : 70000.0,
"Position": "CEO"
}
},
});
I have to do a few changes:
'int' fields have to be NumberInt(number) in the insert command.
The scheme has been changed so that 'Employee' is within 'Department'.
Salary must be double.
"Salary" : "70000" is an int, but the schema ask for double: "Salary":{"bsonType":"double", "description":"Salary of Employee",minimum: 0},.
I would recommend that you use the alias "bsonType":"number" in your schema instead of int,double, long, decimal. Since javascript is not typed, it can be a real pain to keep track which is used in your code.
See doc: https://docs.mongodb.com/manual/reference/operator/query/type/#available-types

How to change the response in MongoDB using translatable fields

I am looking for the way how to resolve this and I can't find it. I appreciate your help.
I have a collection with products like:
[
{
"name": [
{ "es": "Producto 1" },
{ "en": "Product 1" }
]
"reference": "PR1",
"price": "20",
"description": [
{ "es": "Descripción 1" },
{ "en": "Description 1" }
]
}
]
And I would like to do:
db.products.aggregate(); // Find by language es for example:
And get:
[
{
"name": "Producto 1",
"reference": "PR1",
"price": "20",
"description": "Descripción 1"
}
]
Thanks very much.
I would suggest a schema change though to this:
[
{
"name" : [
{
"language" : "es",
"description" : "Producto 1"
},
{
"language" : "en",
"description" : "Product 1"
}
],
"reference" : "PR1",
"price" : "20",
"description" : [
{
"language" : "es",
"description" : "Descripción 1"
},
{
"language" : "en",
"description" : "Description 1"
}
]
}
]
cause then you could actually group by the language in your case.
If this is possible then you could do the following:
db.products.aggregate([
{$unwind: "$someName"},
{$unwind: "$someName.name"},
{$unwind: "$someName.description"},
{
$group: {
_id: {namelang: "$someName.name.language", namedesc: "$someName.description.language"},
name: {$first: "$someName.name.description"},
reference: {$first: "$someName.reference"},
price: {$first: "$someName.price"},
description: {$first: "$someName.description.description"}
}
},
{
$match: {
"_id.namelang": "en",
"_id.namedesc": "en"
}
}
])
FYI since you didn't provided your complete json I created one random. Here is the complete schema:
{
"_id" : ObjectId("59ea07a600f5db2660dbf162"),
"someName" : [
{
"name" : [
{
"language" : "es",
"description" : "Producto 1"
},
{
"language" : "en",
"description" : "Product 1"
}
],
"reference" : "PR1",
"price" : "20",
"description" : [
{
"language" : "es",
"description" : "Descripción 1"
},
{
"language" : "en",
"description" : "Description 1"
}
]
}
]
}

Kapacitor how to create task using template via the rest api?

I can successfully create templates and tasks using the rest api.
How do i create a task using a template via rest api?
Which endpoint should i use?
Okay found out how:
Basically just use the same task rest endpoint and do a post and pass in the json.
In the json you can specify templateId and the vars like below.
{
"status": "disabled"
,"id": "test_task4"
,"template-id": "generic_mean_alert"
,"vars" : {
"measurement": {"type" : "string", "value" : "cpu" },
"where_filter": {"type": "lambda", "value": "\"cpu\" == 'cpu-total'"},
"groups": {"type": "list", "value": [{"type":"string", "value":"host"},{"type":"string", "value":"dc"}]},
"field": {"type" : "string", "value" : "usage_idle" },
"warn": {"type" : "lambda", "value" : "\"mean\" < 30.0" },
"crit": {"type" : "lambda", "value" : "\"mean\" < 10.0" },
"window": {"type" : "duration", "value" : "1m" },
"slack_channel": {"type" : "string", "value" : "#alerts_testing" }
}
,"dbrps": [ { "db": "test","rp": "autogen" } ]
,"type": "stream"
}
http://yoururl/kapacitor/v1/tasks

How to get subarray from mongo document? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
How can I fetch a subarray from document?
Here is one of documents:
"director_details": {
"0": {
"AppointmentDate": "2010-06-02",
"AppointmentStatus": "CURRENT",
"AppointmentType": "SEC",
"NumAppointments": "1",
"Person": {
"CountryOfResidence": [],
"DOB": [],
"Forename": "MARK JHONSONE",
"Nationality": "NATIONALITY UNKNOWN",
"PersonAddress": {
"AddressLine": "5 PARSONS STREET",
"Country": [],
"County": "WEST MIDLANDS",
"PostTown": "DUDLEY",
"Postcode": "DY1 1JJ"
},
"PersonID": "CSeJxNkEELgkAQhe/9CvFerlpZsK0IFUSEUFZH2dyxlnK1XY3897mG5WV48/HezDDYf2cP4wVS8VwsTHuETANEkjMurgvzGK2HM9PwyQDfoW4qLQpV0rJSBGHr32he1gUQu6WtxIzLNJcgaAZkF+y3 [...]",
"Surname": "WESTWOOD",
"Title": "MR"
}
},
"1": {
"AppointmentDate": "2010-06-02",
"AppointmentStatus": "CURRENT",
"AppointmentType": "DIR",
"NumAppointments": "1",
"Occupation": "DIRECTOR",
"Person": {
"CountryOfResidence": "UNITED KINGDOM",
"DOB": "1979-11-30",
"Forename": "MARK DAVID",
"Nationality": "BRITISH",
"PersonAddress": {
"AddressLine": "5 PARSONS STREET",
"Country": [],
"County": "WEST MIDLANDS",
"PostTown": "DUDLEY",
"Postcode": "DY1 1JJ"
},
"PersonID": "CSeJxNkN0KgkAQhe97CvG+XCt/gm0jqCAihLK6lE3HWsp129XIt881TG+GMx9nZg6DF5/sabxBKpbzuWmPkGkAj/OE8dvcPIWboW8aCzLAD6jqSoVQBS1KRRC2ukbzohJAxg1tJE6YTHMJnGZA9svD [...]",
"Surname": "WESTWOOD",
"Title": "MR"
}
}
}
I want to search director which forename contains "david" and surname & title are not empty.
I have a query that works pretty fine, but it also returns extra subarray which I want to remove from output.
Ok. Suppose your document is:
{
"director_details": {
"0": {
"AppointmentDate": "2010-06-02",
...
},
"1": {
"AppointmentDate": "2010-06-02",
...
}
}
}
}
First of all, director_details in you question is not an array, it's an object. And director_details.Person.Forename: /david/ will not match by a couple of reasons:
Part of object's graph is missed, a path to Forename is director_details.1.Person.Forename.
Regexs in MongoDB are case sensitive by default, you should toggle i flag to make it case-insensitive.
The correct query that will match is: db.directors.find({"director_details.1.Person.Forename" : /DAVID/}). With current data model it is not flexible at all, as you need to specify 0 or 1.
Consider making director_details an array, like:
{
"director_details": [
{
"AppointmentDate": "2010-06-02",
...
},
{
"AppointmentDate": "2010-06-02",
...
}
]
}
In this case the query is very simple:
db.directors.find({}, {"director_details" : {$elemMatch : {"Person.Forename" : /DAVID/}}})
And here is the result of running it:
> db.directors.find({}, {"director_details" : {$elemMatch : {"Person.Forename" : /DAVID/}}}).pretty()
{
"_id" : ObjectId("52455db9cafed39bf0dee631"),
"director_details" : [
{
"AppointmentDate" : "2010-06-02",
"AppointmentStatus" : "CURRENT",
"AppointmentType" : "DIR",
"NumAppointments" : "1",
"Occupation" : "DIRECTOR",
"Person" : {
"CountryOfResidence" : "UNITED KINGDOM",
"DOB" : "1979-11-30",
"Forename" : "MARK DAVID",
"Nationality" : "BRITISH",
"PersonAddress" : {
"AddressLine" : "5 PARSONS STREET",
"Country" : [ ],
"County" : "WEST MIDLANDS",
"PostTown" : "DUDLEY",
"Postcode" : "DY1 1JJ"
},
"PersonID" : "CSeJxNkN0KgkAQhe97CvG+XCt/gm0jqCAihLK6lE3HWsp129XI",
"Surname" : "WESTWOOD",
"Title" : "MR"
}
}
]
}