使用 JSON-LD 标记搜索 – 如何嵌入多个查询参数? [英] Using JSON-LD to mark up a seach – How to embed multiple query parameters?

查看:51
本文介绍了使用 JSON-LD 标记搜索 – 如何嵌入多个查询参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 JSON-LD 增强搜索功能的语义.

I want to enhance a search function's semantic meaning using JSON-LD.

最流行的代码片段似乎是来自 Google 的片段:

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>

虽然我理解这是如何工作的,但我想知道是否可以将 SearchAction 标记与 Schema.org 词汇表的其他部分结合起来.

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.

例如,当您可以搜索特定时间点的可用酒店房间时,是否可以使用 JSON-LD 嵌入此信息?

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?

假设搜索字符串如下所示:search-hotels-global.com/?s=new-york&start=5-5-15&end?19-5-15,我如何在 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",
   }
}

推荐答案

不,那不可能.首先,它是无效的 JSON-LD,因为它在一个对象中多次使用相同的属性(您需要将后两个 query_input 更改为其他内容),其次 Google 不支持多个 URL参数.您可以在 Google 的结构化数据测试工具中对其进行测试,网址为 https://developers.google.com/结构化数据/测试工具/

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_inputs 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/

这篇关于使用 JSON-LD 标记搜索 – 如何嵌入多个查询参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆