how to get schema.org multiple keys for award category - schema.org

I am trying to create a schema.org in ld+json and I have all the data working so far.
I am trying to create an array for the award field for a person so I can list multiple awards.
If I do "award" : "some award" as a solo item it works. But I am having trouble creating multiple awards.
I have tried
"award": [
{
"#type" : "award",
"name" : "award name"
}
]
But I get a validation error that award is not a known valid target type for the award property.
I have checked out schema.org and tried looking it up online, but have not found anything helpful.
Has anyone had any experience with getting this to work?

according to award's docs:
Values expected to be one of these types
Text
so, there's no #type, just plain text, so you can try listing awards as strings in an array:
{
"#context": "https://schema.org",
"#type": "Person",
"award": ["Award", "Another award", "And another one"]
}

Related

Mongodb query to add a review into reviews

hi i have made a query to add a new review into the reviews array of an existing listing. this is the code im working with and i dont know where i went wrong with it . the second part is the example reviews
db.listingsandreviews.updateOne[
{reviews:{
"_id": "58663769",
"date": {
"$date": {
"$numberLong": "1451797200000"
}
},
{"listing_id": "10006546",
"reviewer_id": "51483090",
"reviewer_name": "Michelle",
"comments": "The place was really nice and the host are friendly with us"
}}}]
_id
"403055315"
date
2019-01-20T05:00:00.000+00:00
listing_id
"10006546"
reviewer_id
"15138940"
reviewer_name
"Milo"
comments
"The house was extremely well located and Ana was able to give us some …"
Not clear what the problem is, but from the description you may be missing $push operator to add review into existing reviews.
https://www.mongodb.com/docs/manual/reference/operator/update/push/#examples
If you can provide proper queries that you run and problem, we may be able to help better, for example currently "updateOne[" will cause error, as it should be "updateOne(".

Actions SDK: Two instances of org.schema.type.Text in same queryPattern fail

I can't create a queryPattern containing two Text fields, like so:
"parameters": [
{
"name": "text_a",
"type": "org.schema.type.Text"
},
{
"name": "text_b",
"type": "org.schema.type.Text"
}
],
"trigger": {
"queryPatterns": [
"add $org.schema.type.Text:text_b with $org.schema.type.Text:text_a",
"combine $org.schema.type.Text:text_b along with $org.schema.type.Text:text_a"
]
}
This will always result in a failure to match the intent (for example "add something with another").
However, I can use two Color types: If you change "Text" to "Color" in the above, and say "add red with blue" or "combine auburn along with green" then it matches and fires the intent.
I am creating deep-link intents only (i.e., commands, not a back-and-forth dialog), so I don't think DialogFlow will help me?
I suspect that the problem is that AoG is treating text parameters as "greedy", so a second parameter never matches because the first parameter has captured all the text. You don't see this with specific types, because it does more narrow matching for them.
You may actually try to use Dialogflow - it does work for deep linking Intents, although I don't know if it will behave the same way.

MongoDB get last 10 activities

In My social network I want to get the feed for member A , member A is following lets say 20 category/member.
when a category/member(followed by member A) do an activity it is inserted into a collection called recent_activity :
{
"content_id": "6", // content id member A is following
"content_type_id": "6",// content type (category , other member)
"social_network_id": "2", // the action category did (add/like/follow)
"member_id": "51758", //Member A
"date_added": ISODate("2014-03-23T11:37:03.0Z"),
"platform_id": NumberInt(2),
"_id": ObjectId("532ec75f6b1f76fa2d8b457b"),
"_type": {
"0": "Altibbi_Mongo_RecentActivity"
}
}
I want when member A login into the system to get last 10 activities for the categories/member
my problem :
How to get Only 10 activities for all categories/members.
It is better to do it in one query or to do a for loop.
For this use case, I'd suggest to invert the logic and keep a separate object of the last 10 activities for member A that is kept up-to-date all the time. While that solution is more write-heavy, it makes reading trivially simple and it can be extended very easily. I'd like to blatantly advertise a blog post I wrote a while ago about news feeds with mongodb which outlines this approach.
This 'fan-out' approach might seem overly complex at first, but when you think about importance filtering / ranking (a la facebook), push messages for particularly important events (facebook, twitter) or regular digest emails (practically all), you will get one location in your code to perform all this logic.
I think I commented that T'm not really seeing the selection criteria. So if you are "outside" of a single collection, then you have problems. But if your indicated fields are the things you want to "filter" by, then just do this:
db.collection.find({
"social_network_id": "2",
"content_type_id": "6",
"content_id": "6",
"member_id": { "$ne": "51758" }
})
.sort({ "$natural": -1 })
.limit(10);
So what does that do? You match the various conditions in the data to do the "category match" (if I understood what was meant), then you make sure you are not matching entries by the same member.
The last parts do the "natural" sort. This is important because the ObjectId is monotinic, or math speak for "ever increasing". This means the "newest" entries are always the "highest" value. So descending order is "latest" to "oldest".
And the very final part is a basic "limit". So just return the last 10 entries.
As long as you can "filter" within the same collection in whatever way you want, then this should be fine.

Is there any way to force a schema to be respected?

First, I'd like to say that I really love NoSQL & MongoDB but I've got some major concerns with its schema-less aspect.
Let's say I have 2 tables. Employees and Movies.
And... I have a very stupid data layer / framework that sometimes like to save objects in the wrong tables.
So one day, a Movie gets saved in the Employees table. Like this:
> use mongoTests;
switched to db mongoTests
> db.employees.insert({ name : "Max Power", sex : "Male" });
> db.employees.find();
{ "_id" : ObjectId("4fb25ce6420141116081ae57"), "name" : "Max Power", "sex" : "Male" }
> db.employees.insert({ title : "Fight Club", actors : [{ name : "Brad Pitt" }, { name : "Edward Norton" }]});
> db.employees.find();
{ "_id" : ObjectId("4fb25ce6420141116081ae57"), "name" : "Max Power", "sex" : "Male" }
{ "_id" : ObjectId("4fb25db834a31eb59101235b"), "title" : "Fight Club", "actors" : [ { "name" : "Brad Pitt" }, { "name" : "Edward Norton" } ] }
This is VERY wrong.
Let's switch the context, think about Movies, and CreditCards (for whatever reason, in this context credit cards would be stored in clear text inside the DB). This is SUPER WRONG?
The code would probably explode because it's trying to use an object
structure and receives another totally unknown structure.
Even worst, the code actually works and the webstore visitors
actually see credit cards information in the "Rent a movie" list.
Is there anything, built-in that would prevent such threat to ever happen? Like some way to "force" a schema to be respected for only some tables?
Or is there any way to force MongoDB to make a schema mandatory? (Can't create new fields in a table, etc)
EDIT: For those who thinks I'm trolling, I'm really not, this is an important question for me and my team because this is a big decision whether or not we're going to use NoSQL.
Thanks and have a nice day.
The schema-less aspect is one of the major positives.
A DB with a schema doesn't fully remove this kind of issue - e.g. there could be a bug in a system that uses a RDBMS that puts the wrong data in the wrong field/table.
IMHO, the bigger concern would be, how did that kind of bug make it through dev, testing and out into production?!
Having said that, you could set up a process that checks the "schema" of documents within a collection (e.g. look at newly added documents, check whether they have fields you would expect to see in there) - then flag up for investigation. There is such a tool (node.js) here (I think, I've never used it):
http://dhendo.github.com/node-mongodb-schema-validator/
Edit:
For those finding this question in future, so the link in my comment doesn't go overlooked, there's a jira item for this kind of thing here:
http://jira.mongodb.org/browse/SERVER-3536

Multilanguage Content in Rails

I'm about to start a new Project and need some advise.
For example, if i have a Model named "Page" that has "Posts" - how can i store more than one language when i create a new post and show only posts in a language when i click a - let's say - flag-icon at the top.
I have read a lot about l18n but as i understood - this is the way if i want to translate static messages like errors etc. ?
Hope somebody could explain a given strategy to to this in a clean way.
Thanks!
Like you said, localization and internationalization (abbreviated l10n and i18n, respectively) typically refer to the localization of the software product itself, rather than the content.
There are different strategies on how to manage content in multiple languages, and it does depend a lot on what you want to achieve. Suppose you operate a multilingual blog. However, some content is not relevant to an international audience, so you don't want to supply an English version (assuming your not a native English speaker, but I guess the point is clear).
Now it seems to make sense to simply not display that blog post in the English version of the blog. Hence, I'd suggest
Post {
"_id" : ObjectId('...'),
"PostGroupId: ObjectId('...'),
"Title" : "A Blog Post Title",
"Text" : "<h1>Lorem ipsum</h1> lots of text",
"Language" : "en",
"Published" : // and so on...
}
You can now easily query for all or specific posts in a given language: db.Posts.find({"language" : "en"}).sort({"Published" : -1});
Depending on your needs, you might want to add a grouping object for the posts to associate translations of posts to each other explicitly, using denormalized data:
PostGroup
{
"_id" : ObjectId('...'),
// ...
"Posts" : [{"lang" : "en", "id" : ObjectId('...')},
{"lang" : "de", "id" : ObjectId('...')} ]
// -- or simpler --
"AvailableLanguages" : ["en", "it", "fr"]
}