【问题标题】:How to create XML in Google custom search Autocomplete?如何在 Google 自定义搜索自动完成中创建 XML?
【发布时间】:2013-07-25 07:36:49
【问题描述】:

我尝试使用https://developers.google.com/custom-search/docs/queries的结构,但无法成功上传。

<Autocompletions>
  <Autocompletion term="cake" type="1" language=""/>
  <Autocompletion term="strawberry.*" type="2" match="2" language=""/>
  <Autocompletion term="vanilla" type="2" language=""/>
  <Autocompletion term="apple" type="3" language="">
    <Promotion id="1" queries="dessert" title="Apple pie for dessert!" url="http://www.example.com/applepieforsale"
        start_date="" end_date="" image_url=""  description="Apple pie is the best dessert ever!"/>
    <Promotion id="2" queries="apple" title="Buy Apple pie" url="http://www.example.com/applepieforsale"
        start_date="" end_date="" image_url="" description="We stock the best apple pie in the world, right here."/>
  </Autocompletion>
</Autocompletions>

我的网站正在使用 wordpress;我得到了帖子的标题,并希望将其用作谷歌自定义搜索的字符串查询。

请帮我弄清楚如何为自动完成创建 XML。

【问题讨论】:

    标签: search google-custom-search


    【解决方案1】:

    它不喜欢描述属性。如果您删除它们,它就会起作用。

    【讨论】:

      【解决方案2】:

      像这样在 XML 中保留所有术语:

      <Autocompletion term="%term-title%" type="%type%" language=""/>
      

      注意条款的长度,我发现如果是 3 个或更少的单词,Google 会接受。您添加的条目数量也没有太大限制(我一次添加了 9000 个条目)。而且我是用俄语添加的,所以编码也没有问题。

      最终的格式应该是这样的:

      <Autocompletions>
        <Autocompletion term="%term-title%" type="%type%" language=""/>
      
        ...
      
        <Autocompletion term="%term-title%" type="%type%" language=""/>
      </Autocompletions>
      

      Google 没有很好地记录,因此您必须浪费时间阅读此内容。希望对你有帮助:)

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-06-13
        • 2012-01-04
        • 2014-02-25
        • 1970-01-01
        相关资源
        最近更新 更多