Press "Guide" to search the site?

7

Recently I went to the SOpt site by Google Chrome and came across an interesting feature that is "Tab to Search "(Omnibox) .

In short, typing a website address and pressing the Tab key performs the search directly on a specific site without the need to change the search engine and other solutions. >

The image below illustrates better what I'm saying:

Followingtheexampleof SOpt , by pressing Tab and performing a search, the browser redirects me to the site search page, in this case link .

Before I said, I have three questions that are interconnected, which are:

  • What is this feature?
  • How to add to my site?
  • Is Google Chrome only supported?
asked by anonymous 28.12.2016 / 14:32

1 answer

3

It probably refers to application/opensearchdescription+xml , it's an XML format that adds custom search to your site, something should stick like this:

<link rel="search" type="application/opensearchdescription+xml" title="Titulo" href="busca.xml">

And the search.xml:

<?xml version="1.0" encoding="UTF-8"?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/"
                   xmlns:moz="http://www.mozilla.org/2006/browser/search/">
    <ShortName>Nome do buscador</ShortName>
    <Description>Descrição</Description>
    <Tags>asp.net programar core</Tags>
    <Contact>email de contato</Contact>
    <InputEncoding>UTF-8</InputEncoding> <!-- altere para o seu charset padrão usado na página nos inputs -->
    <OutputEncoding>UTF-8</OutputEncoding> <!-- altere para o seu charset padrão usado na página na saida -->
    <Image width="16" height="16" type="image/x-icon">{endereço do icone}</Image>

    <Url type="text/html" method="get" template="http://www.meusite.com.br/busca?q={searchTerms}" />
    <Url type="application/opensearchdescription+xml"
        rel="self"
        template="http://www.meusite.com.br/busca.xml" />
    <Language>pt-BR</Language> <!-- idioma da página -->
    <AdultContent>false</AdultContent>
    <Attribution>Atribuição do proprietário/empresa</Attribution>
</OpenSearchDescription>
  

Most tags are optional, I'm going to search a little more and add the detailing on each, it has more configurations possible but it's been some time since I worked with it.

Note that each page within a same site may have its own search XML.

To adjust the sending of the request set the method, being POST or GET with the attribute method="" and template= containing the url, {searchTerms} will be obtained by what the user edited, this should be done in the tag Url :

<Url type="text/html" method="get" template="http://www.meusite.com.br/busca?q={searchTerms}"></Url>

List of pre-defined suggestions:

You can use the tag with the URL of a json with pre-defined suggestions:

 <Url type="application/x-suggestions+json" template="URL do json" />

Example:

[
   "sea",
   [
      "sears",
      "search engines",
      "search engine",
      "search",
      "sears.com",
      "seattle times"
   ],
   [
      "7,390,000 results",
      "17,900,000 results",
      "25,700,000 results",
      "1,220,000,000 results",
      "1 result",
      "17,600,000 results"
   ],
   [
      "http://meusite.com.br?q=sears",
      "http://meusite.com.br?q=search+engines",
      "http://meusite.com.br?q=search+engine",
      "http://meusite.com.br?q=search",
      "http://meusite.com.br?q=sears.com",
      "http://meusite.com.br?q=seattle+times"
   ]
]

The format of the array:

  • In the first item of the array we have the word that will get the suggestions
  • In the second we have 6 suggestions of palavas
  • In the third we have the result for each suggestion
  • In the fourth we have the urls that can be modified for each word, and can make it easier to use with friendly urls.

Support:

Browsers like Google Chrome and Firefox support opensearchdescription well, but other browsers do not have much support for this, anyway leaving <link type="search" ...> will not affect them negatively.

    
28.12.2016 / 14:55