Search code examples
internationalizationgoogle-custom-search

lr-parameter of google's CSE API not returning pages only in defined language


I'm using the Google CSE to search through a multilingual website (german, english, dutch, french).

The Problem is that I want the search to return results only in the language the user is on e.g. www.coolsite.de/en/?q=hotel should only return results in english.

The documentation says:

You can restrict the search to documents written in a particular language (e.g., lr=lang_ja).

so that's exactly what I want to achieve!

But my search still returns german results when lr is set to lang_en (available languages). All my pages have set language in html-Tag like this:

<html lang="en"> or <html lang="de">

they also contain <meta name="language" content="en" /> or <meta name="language" content="de" /> (is this the correct value for the meta? I read that the value should contain the full name of the language?!)

Am I missing something?


Solution

  • My workaround was to set the hq-Parameter (Appends the extra query terms to the query.) to site:http://www.coolsite.de/[language-I-want-to-search-in]/

    It would have also been possible to filter for data contained in my PageMap.