1

I want to use schema.org for describing the search engine in my website. I've seen this technique in these pages:

Here is the current code:

<script type="application/ld+json">
{
  "@context": "http://schema.org",
  "@type": "WebSite",
  "url": "http://example.com/",
  "name": "Website-Name",
  "potentialAction": {
    "@type": "SearchAction",
    "target": "http://example.com/?q={q}",
    "query-input": "required name=q"
  }
}
</script>

Although I understand this code, in fact my search engine includes another input (a select tag) that has (of course) a default value. I want to include that parameter in the JSON-LD code and specify the default value.

Is it possible? Or should I change the target to http://example.com/?q={q}&param=defaultValue?

UPDATE: This answer: https://stackoverflow.com/a/30061501/1726461 is not a duplicate of my answer, because it hasn't really solved: The whole answer is based on a mistake - the JSON-LD may have multiple equal properties, as can be seen at https://developers.google.com/structured-data/slsb-overview#how_do_you_set_it_up under site+app tab and in the source-code of https://www.pinterest.com (they use Microdata instead JSON-LD). Furthermore, it hasn't gotten many votes so it's not very useful.

Community
  • 1
  • 1
RanSch
  • 469
  • 4
  • 16
  • Votes don’t mean much for Schema.org-related questions here, as only few people seem to be interested in these (so voting scores are typically way lower than in other questions). Furthermore, the linked answer is correct (and Google’s example is wrong): a JSON-LD node can’t have the same property multiple times (you have to use [one property with multiple values in an array](http://stackoverflow.com/a/30506476/1591669)). In Microdata (and RDFa) using the same property multiple times is fine. – unor Apr 21 '16 at 13:06
  • Possible duplicate of [Using JSON-LD to mark up a seach – How to embed multiple query parameters?](http://stackoverflow.com/questions/30059864/using-json-ld-to-mark-up-a-seach-how-to-embed-multiple-query-parameters) – unor Apr 21 '16 at 13:13
  • Although google's testing tool shows that there is a mistake, the Pinterest example proves that in fact it works. – RanSch Apr 21 '16 at 13:26
  • 1
    You said that Pinterest uses Microdata, and, as I mentioned, Microdata does of course follow different rules than JSON-LD - these are totally different syntaxes. Microdata: `bar1 bar2`. JSON-LD: `"foo": ["bar1", "bar2"]` – unor Apr 21 '16 at 13:28
  • 1
    OK, I understand my mistake now. Thanks – RanSch Apr 26 '16 at 13:39

1 Answers1

2

Yes, you are correct in saying you use the following:

http://example.com/?q={q}&param=defaultValue

The 'target' is the URL that the search results page is found at, with '{q}' replaced by the search query. Anything else in the URL is preserved.

grg
  • 5,023
  • 3
  • 34
  • 50