问题
I want to enhance a search function's semantic meaning using JSON-LD.
The most popular snippet to do that seems to be this one from Google:
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "WebSite",
"url": "https://www.example-petstore.com/",
"potentialAction": {
"@type": "SearchAction",
"target": "https://query.example-petstore.com/search?q={search_term_string}",
"query-input": "required name=search_term_string"
}
}
</script>
While I understood how this works, I am wondering if it's possible to combine the SearchAction
markup with other parts of Schema.org's vocabulary.
For example when you can search for a hotel room to be available at a specific point in time, is it possible to embed this information using JSON-LD?
Let's say the search string looks like this: search-hotels-global.com/?s=new-york&start=5-5-15&end?19-5-15
, how do I implement it in JSON-LD, can I do it just like this?
{
"@context": "http://schema.org",
"@type": "WebSite",
"url": "https://www.example-petstore.com/",
"potentialAction": {
"@type": "SearchAction",
"target": "search-hotels-global.com/?q={search_term_string}&start={start_date_input}&end={end_date_input",
"query-input": "required name=search_term_string",
"query-input": "name=start_date_input",
"query-input": "name=end_date_input",
}
}
回答1:
Not, that's not possible. First of all it's invalid JSON-LD as it uses the same property multiple times in an object (you would need to change the latter two query_input
s to something else) and secondly Google doesn't support multiple URL parameters. You can test it in Google's Structured Data Testing tool at https://developers.google.com/structured-data/testing-tool/
来源:https://stackoverflow.com/questions/30059864/using-json-ld-to-mark-up-a-seach-how-to-embed-multiple-query-parameters