How to fix this schema markup, I am getting the error code Duplicate key found - schema

Can you please help me fix this Schema markup. When testing on Google Structured Data Testing tool, I am getting the error code:
Duplicate key found in object declaration on line 119
<!-- JSON-LD markup generated by Google Structured Data Markup Helper. -->
<script type="application/ld+json">
{
"#context" : "http://socialwetalk.me",
"#type" : "LocalBusiness",
"name" : "SocialWeTalk",
"image" : [ "http://socialwetalk.me/wp-content/uploads/2019/03/macbook_mockup-1.png", "http://socialwetalk.me/wp-content/uploads/2018/08/service-summary-2.png" ],
"priceRange" : "$450 - $850",
"telephone" : "+961 76 020 274",
"email" : "info#socialwetalk.me",
"address" : {
"#type" : "PostalAddress",
"streetAddress" : "Hamra, Jeanne d'Arc",
"addressLocality" : "Beirut"
},
"geo" : {
"#type" : "GeoCoordinates",
"latitude" : "33.897835",
"longitude" : "35.481523"
},
"#type":"Review",
"itemReviewed":{"#type":"Product","name":"SocialWeTalk"}
"reviewRating":{"#type":"Rating","ratingValue":4.5,"bestRating":5}
"author":{"#type":"Person","name":"Samir Tutunji"}
"reviewBody":"SocialWeTalk helped us understand where our customers are coming from, and came up with an innovative concept online to keep them coming..."}
}
</script>
I am using Google Structured Data testing tool to validate my work

Its fixed and reformatted
<!-- JSON-LD markup generated by Google Structured Data Markup Helper. -->
<script type="application/ld+json">
{
"#context" : "http://schema.org",
"#type" : "LocalBusiness",
"name" : "SocialWeTalk",
"image" : [ "http://socialwetalk.me/wp-content/uploads/2019/03/macbook_mockup-1.png", "http://socialwetalk.me/wp-content/uploads/2018/08/service-summary-2.png" ],
"priceRange" : "$450 - $850",
"telephone" : "+961 76 020 274",
"email" : "info#socialwetalk.me",
"address" : {
"#type" : "PostalAddress",
"streetAddress" : "Hamra, Jeanne d'Arc",
"addressLocality" : "Beirut"
},
"review" : [
{
"#type" : "Review",
"author" : {
"#type" : "Person",
"name" : "Pro Retrofits"
},
"reviewBody" : "We love our clients"
}, {
"#type" : "Review",
"author" : {
"#type" : "Person",
"name" : "Crunch"
},
"reviewBody" : "We love our clients"
}, {
"#type" : "Review",
"author" : {
"#type" : "Person",
"name" : "SocialWeTalk"
}],
"geo" : {
"#type" : "GeoCoordinates",
"latitude" : "33.897835",
"longitude" : "35.481523"
}
}
</script>
<script type="application/ld+json">
{
"#context":"http://socialwetalk.me","#type":"Review",
"itemReviewed":{"#type":"Product","name":"SocialWeTalk"},
"reviewRating":{"#type":"Rating","ratingValue":4.5,"bestRating":5},
"author":{"#type":"Person","name":"Samir Tutunji"},
"reviewBody":"SocialWeTalk helped us understand where our customers are coming from, and came up with an innovative concept online to keep them coming..."}
</script>

Related

Remove Subdocument items with $pull

I'm trying to remove items from subdocuments using ExpressJS and Mongoose but it is only removing the first items, not the sub items.
So I want to remove "subitem 2" in the messages Array
This is the structure:
{
"_id" : ObjectId("5c4ee94b30ebd71cbed89a35"),
"title" : "Test",
"subitem" : [
{
"_id" : ObjectId("5c4ee95630ebd71cbed89a36"),
"title" : "Item 1",
"messages" : [
{
"_id" : ObjectId("5c4ee95f30ebd71cbed89a37"),
"type" : "single_article",
"date" : "Jan 28, 2019",
"title" : "subitem 1",
"text" : ""
}
]
},
{
"_id" : ObjectId("5c4ee96830ebd71cbed89a38"),
"title" : "item 2",
"messages" : [
{
"_id" : ObjectId("5c4ee96e30ebd71cbed89a39"),
"type" : "single_article",
"date" : "Jan 28, 2019",
"title" : "subitem 2",
"text" : ""
}
]
}
],
"__v" : 0
}
And this is the $pull method:
getController.deleteRec = function(req,res,collection){
var id = req.params.id;
console.log(id);
collection.updateOne({'subitem.messages._id': id}, {$pull: {'subitem.0.messages': {"_id": id}}}).
then(function(result){
console.log(result);
});
};
Now I know why it is only deleting the first item because I have "subitem.0.messages". How can I loop over this, so it can delete all items?
You can use $ as a wildcard index, removing all elements in the array matching your query like this:
{$pull: {'subitem.$.messages': {"_id": id}}}
if you want to remove multiple documents:
{$pull: {'subitem.$.messages': {"_id": {$in : [id, id2, id3...]}}}}

How to in execute Google API into Nativescript-Vue?

Can anyone help me how to use Google APIs into Nativescript-Vue. Please, Thanks in advance
You may try with axios.
If you hit this api by axios
https://maps.googleapis.com/maps/api/distancematrix/json?units=imperial&origins=Washington,DC&destinations=New+York+City,NY&key=YOUR_API_KEY
you will get data like this -
{
"destination_addresses" : [ "New York, NY, USA" ],
"origin_addresses" : [ "Washington, DC, USA" ],
"rows" : [
{
"elements" : [
{
"distance" : {
"text" : "225 mi",
"value" : 361715
},
"duration" : {
"text" : "3 hours 49 mins",
"value" : 13725
},
"status" : "OK"
}
]
}
],
"status" : "OK"
}
so it's easy with vuejs for show data in view, if you familiar with vuejs.
Happy coding :)

Scoring documents in Lucene 6.2.0

My query in lucene 6.2.0 goes like:
query query = new PhraseQuery.Builder()
.add(new Term("country","russia"))
.setSlop(1)
.build();
Basically among all my documents which are:
{
"_id" : ObjectId("586b723b4b9a835db416fa26"),
"name" : "test",
"countries" : {
"country" : [
{
"name" : "russia"
},
{
"name" : "USA china"
}
]
}
}
{
"_id" : ObjectId("586b73f24b9a835fefb10ca5"),
"name" : "nitika jain",
"countries" : {
"country" : [
{
"name" : "russia and denmrk"
},
{
"name" : "USA china"
}
]
}
}
{
"_id" : ObjectId("586b744f4b9a835fefb10ca7"),
"name" : "arjun",
"countries" : {
"country" : [
{
"name" : "russia pakistan"
},
{
"name" : "india iraq"
}
]
}
}
I want a document which has only russia. Ideally it should be the one highest scored, but instead I get something like "Found 3 hits."
Document<stored,indexed,tokenized<id:586b723b4b9a835db416fa26> stored,indexed,tokenized,omitNorms,indexOptions=DOCS<name:test> stored,indexed,tokenized,omitNorms,indexOptions=DOCS<countries:{ "country" : [ { "name" : "russia"} , { "name" : "USA china"}]}> stored,indexed,tokenized<country:russia> stored,indexed,tokenized<country:USA china>>**0.12874341**
Document<stored,indexed,tokenized<id:586b73f24b9a835fefb10ca5> stored,indexed,tokenized,omitNorms,indexOptions=DOCS<name:nitika jain> stored,indexed,tokenized,omitNorms,indexOptions=DOCS<countries:{ "country" : [ { "name" : "russia and denmrk"} , { "name" : "USA china"}]}> stored,indexed,tokenized<country:russia and denmrk> stored,indexed,tokenized<country:USA china>>**0.12874341**
Document<stored,indexed,tokenized<id:586b744f4b9a835fefb10ca7> stored,indexed,tokenized,omitNorms,indexOptions=DOCS<name:arjun> stored,indexed,tokenized,omitNorms,indexOptions=DOCS<countries:{ "country" : [ { "name" : "russia pakistan"} , { "name" : "india iraq"}]}> stored,indexed,tokenized<country:russia pakistan> stored,indexed,tokenized<country:india iraq>>**0.12874341**
All 3 results are equally scored. How can I get the document with only russia to be highest scored?
In Phrase queries, the slop is zero by default, requiring exact matches. that means that if you modify your query in this way:
query query = new PhraseQuery.Builder()
.add(new Term("country","russia"))
.build();
you'll get what you're looking for.

How do I set up my json schema structure

I'm trying to figure out how a json schema should be implemented (as standardized as possible).
I have noticed that if I define a schema for a form using the v4 draft, I cannot voice the requirements my project has. So I created a schema that uses the v4 schema ("$schema": "http://json-schema.org/draft-04/schema#"), and gave it a custom id for the project, lets call it projectschema#. This schema validates, so all is good standard-wise. I have added two values to the type enum.
I then use this schema as $schema for another schema that describes form properties and validations, the formschema#. This schema too validates, this time against the projectschema#.
Now, as documented on www.json-schema.org, there's also a hyper-schema which allows the definition of links. Useful, as I can define where to POST the form to, or even where to get valueSets to use in the form (i.e. a rest service to get a list of user titles).
However, the v4 schema itself does not support links. I see how the v4 hyper-schema draft does support links, and is referencing the v4 schema draft, but I cannot figure out how to implement the hyper-schema, which probably means I'm missing some fundamental part of the 'how to use and implement json schema' knowledge.
I found the following on http://json-schema.org/latest/json-schema-hypermedia.html:
JSON Schema is a JSON based format for defining the structure of JSON data. This document specifies hyperlink- and hypermedia-related keywords of JSON Schema.
The term JSON Hyper-Schema is used to refer to a JSON Schema that uses these keywords.
If the draft hyper-schema uses the draft schema keywords, then why is the 'links' keyword nowhere to be found in the schema?
Is my (or any) custom schema actually a hyper schema? And if so, is anything that implements a (custom or draft) json schema called a hyper schema?
I could fire off a hundred questions. Main question: what is the relation between a Schema and a Hyper Schema, and how should I implement a schema for a form that needs more types than defined in the v4 draft?
Sorry for the length of this answer. Hopefully it's helpful.
I too struggled to understand how to validate a particular link in Hyper-Schema so I implemented each link as a base JSON Schema then tied each link together with a Hyper-Schema.
Definitions (definitions.json):
{
"$schema" : "http://json-schema.org/schema#",
"definitions" : {
"id" : {
"type" : "integer",
"minimum" : 1,
"exclusiveMinimum" : false
},
"foreign_key_id" : {
"$ref" : "#/definitions/id"
},
"season_name" : {
"type" : "string",
"minLength" : 1,
"maxLength" : 1,
"pattern" : "^[A-T]{1,1}$"
},
"currency" : {
"type" : "integer"
},
"shares" : {
"type" : "integer"
},
"username" : {
"type" : "string",
"minLength" : 1,
"maxLength" : 19,
"pattern" : "^[^ ]{1,19}$"
},
"name" : {
"type" : "string",
"minLength" : 1,
"maxLength" : 64,
"pattern" : "^[A-Za-z0-9][A-Za-z0-9_\\- ]*$"
},
"email" : {
"type" : "string",
"format" : "email"
},
"timestamp" : {
"type" : "string",
"format" : "date-time"
}
}
}
Base object schema:
{
"$schema" : "http://json-schema.org/schema#",
"type" : "object",
"properties" : {
"id" : { "$ref" : "definitions.json#/definitions/id" },
"season_name" : { "$ref" : "definitions.json#/definitions/season_name" },
"user_id" : { "$ref" : "definitions.json#/definitions/foreign_key_id" },
"coins" : { "$ref" : "definitions.json#/definitions/currency" },
"bonus_coins" : { "$ref" : "definitions.json#/definitions/currency" },
"created_at" : { "$ref" : "definitions.json#/definitions/timestamp" },
"updated_at" : { "$ref" : "definitions.json#/definitions/timestamp" }
},
"required" : [
"id",
"season_name",
"user_id",
"coins",
"bonus_coins",
"created_at",
"updated_at"
],
"additionalProperties" : false
}
POST schema (account_request_post.json):
{
"$schema" : "http://json-schema.org/schema#",
"type" : "object",
"properties" : {
"season_name" : { "$ref" : "definitions.json#/definitions/season_name" },
"user_id" : { "$ref" : "definitions.json#/definitions/foreign_key_id" }
},
"required" : [
"season_name",
"user_id"
],
"additionalProperties" : false
}
Hyper Schema:
{
"$schema" : "http://json-schema.org/schema#",
"type" : "object",
"links" : [
{
"description" : "Create a new account.",
"href" : "accounts",
"method" : "POST",
"rel" : "create",
"title" : "Create",
"schema" : { "$ref" : "account_request_post.json#" }
},
{
"description" : "List accounts.",
"href" : "accounts",
"method" : "GET",
"rel" : "index",
"title" : "List"
}
]
}
Json hyper-schema is a subset of Json-schema standard dedicated to hyperlink and hypermedia keywords and rules.
The "links" keyword is defined in the hyper-schema section of the draft. Indeed it is a part of json-schema (despite it is defined in a special draft section)
If your are defining an API interface, it is likely you want to use hyper-schema. If you are just defining validation contracts, plain Json-schema keywords are enough.

how to reduce amount of data in neo4j query?

when requesting data over Neo4j, as in, say,
curl -i -XPOST -d'{ "query" : "start n=node(*) return n" }'
-H "accept:application/json;stream=true"
-H content-type:application/json
http://localhost:7474/db/data/cypher
i get, as documented, a response like this:
{
"columns" : [ "n" ],
"data" : [ [ {
"outgoing_relationships" : "http://localhost:7474/db/data/node/0/relationships/out",
"data" : {
},
"traverse" : "http://localhost:7474/db/data/node/0/traverse/{returnType}",
"all_typed_relationships" : "http://localhost:7474/db/data/node/0/relationships/all/{-list|&|types}",
"property" : "http://localhost:7474/db/data/node/0/properties/{key}",
"self" : "http://localhost:7474/db/data/node/0",
"properties" : "http://localhost:7474/db/data/node/0/properties",
"outgoing_typed_relationships" : "http://localhost:7474/db/data/node/0/relationships/out/{-list|&|types}",
"incoming_relationships" : "http://localhost:7474/db/data/node/0/relationships/in",
"extensions" : {
},
"create_relationship" : "http://localhost:7474/db/data/node/0/relationships",
"paged_traverse" : "http://localhost:7474/db/data/node/0/paged/traverse/{returnType}{?pageSize,leaseTime}",
"all_relationships" : "http://localhost:7474/db/data/node/0/relationships/all",
"incoming_typed_relationships" : "http://localhost:7474/db/data/node/0/relationships/in/{-list|&|types}"
} ], [ {
"outgoing_relationships" : "http://localhost:7474/db/data/node/1/relationships/out",
"data" : {
"glyph" : "δΈ€",
"~isa" : "glyph"
},
"traverse" : "http://localhost:7474/db/data/node/1/traverse/{returnType}",
"all_typed_relationships" : "http://localhost:7474/db/data/node/1/relationships/all/{-list|&|types}",
"property" : "http://localhost:7474/db/data/node/1/properties/{key}",
"self" : "http://localhost:7474/db/data/node/1",
"properties" : "http://localhost:7474/db/data/node/1/properties",
"outgoing_typed_relationships" : "http://localhost:7474/db/data/node/1/relationships/out/{-list|&|types}",
"incoming_relationships" : "http://localhost:7474/db/data/node/1/relationships/in",
"extensions" : {
},
"create_relationship" : "http://localhost:7474/db/data/node/1/relationships",
"paged_traverse" : "http://localhost:7474/db/data/node/1/paged/traverse/{returnType}{?pageSize,leaseTime}",
"all_relationships" : "http://localhost:7474/db/data/node/1/relationships/all",
"incoming_typed_relationships" : "http://localhost:7474/db/data/node/1/relationships/in/{-list|&|types}"
} ], [ {
"outgoing_relationships" : "http://localhost:7474/db/data/node/2/relationships/out",
"data" : {
"~isa" : "LPG",
"LPG" : "1"
},
"traverse" : "http://localhost:7474/db/data/node/2/traverse/{returnType}",
"all_typed_relationships" : "http://localhost:7474/db/data/node/2/relationships/all/{-list|&|types}",
"property" : "http://localhost:7474/db/data/node/2/properties/{key}",
"self" : "http://localhost:7474/db/data/node/2",
"properties" : "http://localhost:7474/db/data/node/2/properties",
"outgoing_typed_relationships" : "http://localhost:7474/db/data/node/2/relationships/out/{-list|&|types}",
"incoming_relationships" : "http://localhost:7474/db/data/node/2/relationships/in",
"extensions" : {
},
"create_relationship" : "http://localhost:7474/db/data/node/2/relationships",
"paged_traverse" : "http://localhost:7474/db/data/node/2/paged/traverse/{returnType}{?pageSize,leaseTime}",
"all_relationships" : "http://localhost:7474/db/data/node/2/relationships/all",
"incoming_typed_relationships" : "http://localhost:7474/db/data/node/2/relationships/in/{-list|&|types}"
} ], [ {
and so on and on. the URLs delivered with each node are certainly well meant, but they also occupy a major portion of the data transmitted. they're also highly redundant and not what i', after with my query. is there any way to drop all of that traverse,
all_typed_relationships,
property,
self,
properties,
outgoing_typed_relationships,
incoming_relationships,
extensions,
create_relationship,
paged_traverse,
all_relationships,
incoming_typed_relationships
jazz?
The only way is to specify the properties you want returned in the return statement. Like:
return id(n), n.glyph;