Error: Page contains property “query-input” which

2019-05-28 09:04发布

问题:

I get this error from the Google RichSnippets testing tool:

Error: Page contains property "query-input" which is not part of the schema.

But where did I make a mistake?

HTML:

<div id="dkAjaxSearch">
<input id="ajaxSearch" type="text" value="" name="search_term" itemprop="query-input">
Press Enter to search
</div>

JSON-LD:

<script type="application/ld+json">
{
   "@context": "http://schema.org",
   "@type": "WebSite",
   "url": "https://domain.com/",
   "potentialAction": {
     "@type": "SearchAction",
     "target": "http://domain.com/search/{search_term_string}",
     "query-input": "required name=search_term_string"
   }
}
</script>

Documentation: An improved search box within the search results

回答1:

It’s explained in the documentation about Actions:

Additional information is often required from a user or client in order to formulate a complete request. To facilitate this process we need the ability to describe within a potential action how to construct these inputs. Since we need this capability for filling in any property of an Action, we introduce a notion of property annotations using a hypen ("-") delimiter. For example, by specifying a "location-input" property on a potential action we are indicating that "location" is a supported input for completing the action.

But as this property does not exist (i.e., it’s not defined in the property table on SearchAction), validators report it as an error.

This issue already gets discussed on Schema.org’s GitHub: SearchAction example uses "query-input" property that is not defined

So you did not do something wrong. Unless Schema.org decides that Actions should be handled in a different way, validators should probably update and allow -input and -output suffixes.



回答2:

The problem is that the query-input value (in your case search_term_string) must match the input field name.

in your case:

<input id="ajaxSearch" type="text" value="" name="search_term" itemprop="query-input">

must be:

<input id="ajaxSearch" type="text" value="" name="search_term_string" itemprop="query-input">