JSON API reference

  • Boolean OR search finds documents containing at least one of a series of terms.

  • Boolean operators like AND (.), NOT (-), and OR (|) can be used incr andlr parameters to refine search results.

  • Parentheses can be used with Boolean operators to control the order of evaluation in search queries.

  • You can internationalize queries by specifying interface language and filtering results by language using parameters like "hl" and "lr".

  • SafeSearch can be used to filter adult content from search results using the "safe" parameter.

Boolean OR Search

Boolean OR Search [ OR ]
Description

TheOR query term retrieves documents that include one of a series of (two or more) query terms. To use theOR query term, you would insert the search termOR, in uppercase letters, between each term in the series.

You can also use the "as_oq" request parameter (like "as_oq=London+Paris") to submit a search for any term in a set of terms.

Note: If a search request specifies the query "London+OR+Paris", the search results will include documents containing at least one of those two words. In some cases, documents in the search results may contain both words.

Examples

Search for London or Paris:

User input:london OR parisQuery term:q=london+OR+paris

Search for vacation and either London or Paris:

Query term:q=vacation+london+OR+paris

Search for vacation and one of London, Paris or chocolates:

Query term:  q=vacation+london+OR+paris+OR+chocolates

Search for vacation and chocolates and either london or paris, with the least weight being given to chocolates:

Query term:  q=vacation+london+OR+paris+chocolates

Search for vacation, chocolates and flowers in documents that also contain either London or Paris:

Query term:  q=vacation+london+OR+paris+chocolates+flowers

Search for vacation and one of London or Paris and also search for one of chocolates or flowers:

Query term:  q=vacation+london+OR+paris+chocolates+OR+flowers

Boolean Operators

You may use Boolean operators in values for the following parameters:

  • cr
  • lr

Boolean Operator Definitions

Note: You cannot include spaces in parameter values.

BooleanAND [.]
Description

TheAND operator (.) returns results that are in the intersection of the collections to either side of the "." operator.

Examples

This example removes all results that are in either French or Italian:
lr=(-lang_fr).(-lang_it)


BooleanNOT [-]
Description

TheNOT operator (-) removes all results that are in the collection immediately following the minus ("-") operator.

Examples

This example removes all results that are in French:
lr=-lang_fr

This example removes all results that are in either French or Italian:
lr=(-lang_fr).(-lang_it)

Note: You may have noticed that the second example above uses theBoolean AND operator to specify that results should not be written in French or Italian. Depending on the placement ofparentheses in your query, you could use either theBoolean AND operator or theBoolean OR operator to express this query. This is because if a document is written in French, then it isnot written in Italian. Thus, your Boolean statement must express that the document is not written in Frenchand the document is not written in Italian.


BooleanOR [|]
Description

TheOR operator (|) returns results that are in either the collection to the left or the collection to the right of the pipe ("|") operator.

Examples

This example returns all results that are written in either Simplified Chinese or Traditional Chinese:
lr=lang_zh-TW|lang_zh-CN

This example requests all results that are not written in French or Italian; notice that it placesparentheses in a different location than the sample query for theBoolean AND operator:
lr=-(lang_fr|lang_it)


Boolean Parentheses[()]
Description

This operator lets you ensure that all terms in the innermost set of parentheses are evaluated before terms outside the parentheses are evaluated. You can use parentheses to adjust the order in which terms are evaluated.

Examples

The example for theNOT [-] operator shows the following construct for request results that are not written in either French or Italian:
lr=(-lang_fr).(-lang_it)

The example for theOR (|) operator also shows a request for results not written in French of Italian. Since the latter example uses theOR operator rather than theAND operator, it also must change the location of the parentheses:
lr=-(lang_fr|lang_it)

Internationalizing Queries and Results Presentation

The Google WebSearch service enables you to search for documents in multiple languages. You can specify the character encoding that should be used to interpret your HTTP request and to encode your response. You can also filter results to only include documents written in certain languages.

The following sections discuss issues related to searching in multiple languages:

Interface Languages

You can use the "hl" request parameter to identify the language of your graphical interface. The "hl" parameter value may affect search results, especially on international queries when language restriction (using the "lr" parameter) is not explicitly specified. In such cases, the "hl" parameter may promote search results in the same language as the user's input language.

We suggest you explicitly set the "hl" parameter in search results to ensure that Google selects the highest quality search results for each query.

Please see theSupported Interface Languages section for a complete list of valid values for the "hl" parameter.

Simplified and Traditional Chinese Search

Simplified Chinese and Traditional Chinese are two writing variants of the Chinese language. The same concept may be written differently in each variant. Given a query in one of the variants, the Google WebSearch service can return results that include pages in both variants.

To use this feature:

  1. Set the "c2coff" request parameter to0
    and
  2. Do one of the following:
    • Do not set the "lr" request parameter
      or
    • Set the "lr" request parameter tolr=lang_zh-TW|lang_zh-CN

The following example shows the query parameters you would include in a request for results in both simplified and traditional Chinese. (Note that additional required information, such as the "client", is not included in the example.)

search?hl=zh-CN    &lr=lang_zh-TW|lang_zh-CN    &c2coff=0

Filtering Results

Google WebSearch provides a number of ways to filter your search results:

Automatic Filtering of Search Results

In an effort to provide the best search results possible, Google uses two techniques to automatically filter search results that are generally considered undesirable:

  • Duplicate Content—If multiple documents contain the same information, then only the most relevant document of that set is included in your search results.

  • Host Crowding—If there are many search results from the same site, Google may not show all the results from that site or may show the results lower in
    the ranking than they otherwise would have been.

We recommend you leave these filters on for typical search requests because the filters significantly enhance the quality of most search results. However, you can bypass these automatic filters by setting the "filter" query parameter to0 in your search request.

Filtering Adult Content with SafeSearch

Many Google customers do not want to display search results for sites that contain adult content. Using our SafeSearch filter, you can screen for search results that contain adult content and eliminate them. Google's filters use proprietary technology to check keywords, phrases and URLs. While no filters are 100 percent accurate, SafeSearch will remove the overwhelming majority of adult content from your search results.

Google strives to keep SafeSearch as current and comprehensive as possible by continually crawling the Web and by incorporating updates from user suggestions.

You can adjust the degree to which Google filters your results for adult content using the "safe" query parameter. The following table explains Google's SafeSearch settings and how those settings will affect your search results:

SafeSearch LevelDescription
highEnables a stricter version of safe search.
mediumBlocks web pages containing pornography and other explicit sexual content.
offDoes not filter adult content from search results.

* The default SafeSearch setting isoff.

International Values

Supported Interface Languages

Google supports more than 80 languages. The default interface language is English. The following list identifies all of the interface languages that Google supports.

Display Languagehl Parameter Value
Afrikaansaf
Albaniansq
Amharicsm
Arabicar
Azerbaijaniaz
Basqueeu
Belarusianbe
Bengalibn
Biharibh
Bosnianbs
Bulgarianbg
Catalanca
Chinese (Simplified)zh-CN
Chinese (Traditional)zh-TW
Croatianhr
Czechcs
Danishda
Dutchnl
Englishen
Esperantoeo
Estonianet
Faroesefo
Finnishfi
Frenchfr
Frisianfy
Galiciangl
Georgianka
Germande
Greekel
Gujaratigu
Hebrewiw
Hindihi
Hungarianhu
Icelandicis
Indonesianid
Interlinguaia
Irishga
Italianit
Japaneseja
Javanesejw
Kannadakn
Koreanko
Latinla
Latvianlv
Lithuanianlt
Macedonianmk
Malayms
Malayamml
Maltesemt
Marathimr
Nepaline
Norwegianno
Norwegian (Nynorsk)nn
Occitanoc
Persianfa
Polishpl
Portuguese (Brazil)pt-BR
Portuguese (Portugal)pt-PT
Punjabipa
Romanianro
Russianru
Scots Gaelicgd
Serbiansr
Sinhalesesi
Slovaksk
Sloveniansl
Spanishes
Sudanesesu
Swahilisw
Swedishsv
Tagalogtl
Tamilta
Telugute
Thaith
Tigrinyati
Turkishtr
Ukrainianuk
Urduur
Uzbekuz
Vietnamesevi
Welshcy
Xhosaxh
Zuluzu

Country Collection Values

You can use the following values to specify a country filter using the "cr" query parameter:

CountryCountry Collection Name
AfghanistancountryAF
AlbaniacountryAL
AlgeriacountryDZ
American SamoacountryAS
AndorracountryAD
AngolacountryAO
AnguillacountryAI
AntarcticacountryAQ
Antigua and BarbudacountryAG
ArgentinacountryAR
ArmeniacountryAM
ArubacountryAW
AustraliacountryAU
AustriacountryAT
AzerbaijancountryAZ
BahamascountryBS
BahraincountryBH
BangladeshcountryBD
BarbadoscountryBB
BelaruscountryBY
BelgiumcountryBE
BelizecountryBZ
BenincountryBJ
BermudacountryBM
BhutancountryBT
BoliviacountryBO
Bosnia and HerzegovinacountryBA
BotswanacountryBW
Bouvet IslandcountryBV
BrazilcountryBR
British Indian Ocean TerritorycountryIO
Brunei DarussalamcountryBN
BulgariacountryBG
Burkina FasocountryBF
BurundicountryBI
CambodiacountryKH
CamerooncountryCM
CanadacountryCA
Cape VerdecountryCV
Cayman IslandscountryKY
Central African RepubliccountryCF
ChadcountryTD
ChilecountryCL
ChinacountryCN
Christmas IslandcountryCX
Cocos (Keeling) IslandscountryCC
ColombiacountryCO
ComoroscountryKM
CongocountryCG
Congo, the Democratic Republic of thecountryCD
Cook IslandscountryCK
Costa RicacountryCR
Cote D'ivoirecountryCI
Croatia (Hrvatska)countryHR
CubacountryCU
CypruscountryCY
Czech RepubliccountryCZ
DenmarkcountryDK
DjibouticountryDJ
DominicacountryDM
Dominican RepubliccountryDO
East TimorcountryTP
EcuadorcountryEC
EgyptcountryEG
El SalvadorcountrySV
Equatorial GuineacountryGQ
EritreacountryER
EstoniacountryEE
EthiopiacountryET
European UnioncountryEU
Falkland Islands (Malvinas)countryFK
Faroe IslandscountryFO
FijicountryFJ
FinlandcountryFI
FrancecountryFR
France, MetropolitancountryFX
French GuianacountryGF
French PolynesiacountryPF
French Southern TerritoriescountryTF
GaboncountryGA
GambiacountryGM
GeorgiacountryGE
GermanycountryDE
GhanacountryGH
GibraltarcountryGI
GreececountryGR
GreenlandcountryGL
GrenadacountryGD
GuadeloupecountryGP
GuamcountryGU
GuatemalacountryGT
GuineacountryGN
Guinea-BissaucountryGW
GuyanacountryGY
HaiticountryHT
Heard Island and Mcdonald IslandscountryHM
Holy See (Vatican City State)countryVA
HondurascountryHN
Hong KongcountryHK
HungarycountryHU
IcelandcountryIS
IndiacountryIN
IndonesiacountryID
Iran, Islamic Republic ofcountryIR
IraqcountryIQ
IrelandcountryIE
IsraelcountryIL
ItalycountryIT
JamaicacountryJM
JapancountryJP
JordancountryJO
KazakhstancountryKZ
KenyacountryKE
KiribaticountryKI
Korea, Democratic People's Republic ofcountryKP
Korea, Republic ofcountryKR
KuwaitcountryKW
KyrgyzstancountryKG
Lao People's Democratic RepubliccountryLA
LatviacountryLV
LebanoncountryLB
LesothocountryLS
LiberiacountryLR
Libyan Arab JamahiriyacountryLY
LiechtensteincountryLI
LithuaniacountryLT
LuxembourgcountryLU
MacaocountryMO
Macedonia, the Former Yugosalv Republic ofcountryMK
MadagascarcountryMG
MalawicountryMW
MalaysiacountryMY
MaldivescountryMV
MalicountryML
MaltacountryMT
Marshall IslandscountryMH
MartiniquecountryMQ
MauritaniacountryMR
MauritiuscountryMU
MayottecountryYT
MexicocountryMX
Micronesia, Federated States ofcountryFM
Moldova, Republic ofcountryMD
MonacocountryMC
MongoliacountryMN
MontserratcountryMS
MoroccocountryMA
MozambiquecountryMZ
MyanmarcountryMM
NamibiacountryNA
NaurucountryNR
NepalcountryNP
NetherlandscountryNL
Netherlands AntillescountryAN
New CaledoniacountryNC
New ZealandcountryNZ
NicaraguacountryNI
NigercountryNE
NigeriacountryNG
NiuecountryNU
Norfolk IslandcountryNF
Northern Mariana IslandscountryMP
NorwaycountryNO
OmancountryOM
PakistancountryPK
PalaucountryPW
Palestinian TerritorycountryPS
PanamacountryPA
Papua New GuineacountryPG
ParaguaycountryPY
PerucountryPE
PhilippinescountryPH
PitcairncountryPN
PolandcountryPL
PortugalcountryPT
Puerto RicocountryPR
QatarcountryQA
ReunioncountryRE
RomaniacountryRO
Russian FederationcountryRU
RwandacountryRW
Saint HelenacountrySH
Saint Kitts and NeviscountryKN
Saint LuciacountryLC
Saint Pierre and MiqueloncountryPM
Saint Vincent and the GrenadinescountryVC
SamoacountryWS
San MarinocountrySM
Sao Tome and PrincipecountryST
Saudi ArabiacountrySA
SenegalcountrySN
Serbia and MontenegrocountryCS
SeychellescountrySC
Sierra LeonecountrySL
SingaporecountrySG
SlovakiacountrySK
SloveniacountrySI
Solomon IslandscountrySB
SomaliacountrySO
South AfricacountryZA
South Georgia and the South Sandwich IslandscountryGS
SpaincountryES
Sri LankacountryLK
SudancountrySD
SurinamecountrySR
Svalbard and Jan MayencountrySJ
SwazilandcountrySZ
SwedencountrySE
SwitzerlandcountryCH
Syrian Arab RepubliccountrySY
Taiwan, Province of ChinacountryTW
TajikistancountryTJ
Tanzania, United Republic ofcountryTZ
ThailandcountryTH
TogocountryTG
TokelaucountryTK
TongacountryTO
Trinidad and TobagocountryTT
TunisiacountryTN
TurkeycountryTR
TurkmenistancountryTM
Turks and Caicos IslandscountryTC
TuvalucountryTV
UgandacountryUG
UkrainecountryUA
United Arab EmiratescountryAE
United KingdomcountryUK
United StatescountryUS
United States Minor Outlying IslandscountryUM
UruguaycountryUY
UzbekistancountryUZ
VanuatucountryVU
VenezuelacountryVE
VietnamcountryVN
Virgin Islands, BritishcountryVG
Virgin Islands, U.S.countryVI
Wallis and FutunacountryWF
Western SaharacountryEH
YemencountryYE
YugoslaviacountryYU
ZambiacountryZM
ZimbabwecountryZW

Country Codes

The following table lists the two-letter country codes that can be used as values of the "gl" parameter:

CountryCountry Code
Afghanistanaf
Albaniaal
Algeriadz
American Samoaas
Andorraad
Angolaao
Anguillaai
Antarcticaaq
Antigua and Barbudaag
Argentinaar
Armeniaam
Arubaaw
Australiaau
Austriaat
Azerbaijanaz
Bahamasbs
Bahrainbh
Bangladeshbd
Barbadosbb
Belarusby
Belgiumbe
Belizebz
Beninbj
Bermudabm
Bhutanbt
Boliviabo
Bosnia and Herzegovinaba
Botswanabw
Bouvet Islandbv
Brazilbr
British Indian Ocean Territoryio
Brunei Darussalambn
Bulgariabg
Burkina Fasobf
Burundibi
Cambodiakh
Camerooncm
Canadaca
Cape Verdecv
Cayman Islandsky
Central African Republiccf
Chadtd
Chilecl
Chinacn
Christmas Islandcx
Cocos (Keeling) Islandscc
Colombiaco
Comoroskm
Congocg
Congo, the Democratic Republic of thecd
Cook Islandsck
Costa Ricacr
Cote D'ivoireci
Croatiahr
Cubacu
Cypruscy
Czech Republiccz
Denmarkdk
Djiboutidj
Dominicadm
Dominican Republicdo
Ecuadorec
Egypteg
El Salvadorsv
Equatorial Guineagq
Eritreaer
Estoniaee
Ethiopiaet
Falkland Islands (Malvinas)fk
Faroe Islandsfo
Fijifj
Finlandfi
Francefr
French Guianagf
French Polynesiapf
French Southern Territoriestf
Gabonga
Gambiagm
Georgiage
Germanyde
Ghanagh
Gibraltargi
Greecegr
Greenlandgl
Grenadagd
Guadeloupegp
Guamgu
Guatemalagt
Guineagn
Guinea-Bissaugw
Guyanagy
Haitiht
Heard Island and Mcdonald Islandshm
Holy See (Vatican City State)va
Hondurashn
Hong Konghk
Hungaryhu
Icelandis
Indiain
Indonesiaid
Iran, Islamic Republic ofir
Iraqiq
Irelandie
Israelil
Italyit
Jamaicajm
Japanjp
Jordanjo
Kazakhstankz
Kenyake
Kiribatiki
Korea, Democratic People's Republic ofkp
Korea, Republic ofkr
Kuwaitkw
Kyrgyzstankg
Lao People's Democratic Republicla
Latvialv
Lebanonlb
Lesothols
Liberialr
Libyan Arab Jamahiriyaly
Liechtensteinli
Lithuanialt
Luxembourglu
Macaomo
Macedonia, the Former Yugosalv Republic ofmk
Madagascarmg
Malawimw
Malaysiamy
Maldivesmv
Maliml
Maltamt
Marshall Islandsmh
Martiniquemq
Mauritaniamr
Mauritiusmu
Mayotteyt
Mexicomx
Micronesia, Federated States offm
Moldova, Republic ofmd
Monacomc
Mongoliamn
Montserratms
Moroccoma
Mozambiquemz
Myanmarmm
Namibiana
Naurunr
Nepalnp
Netherlandsnl
Netherlands Antillesan
New Caledonianc
New Zealandnz
Nicaraguani
Nigerne
Nigeriang
Niuenu
Norfolk Islandnf
Northern Mariana Islandsmp
Norwayno
Omanom
Pakistanpk
Palaupw
Palestinian Territory, Occupiedps
Panamapa
Papua New Guineapg
Paraguaypy
Perupe
Philippinesph
Pitcairnpn
Polandpl
Portugalpt
Puerto Ricopr
Qatarqa
Reunionre
Romaniaro
Russian Federationru
Rwandarw
Saint Helenash
Saint Kitts and Neviskn
Saint Lucialc
Saint Pierre and Miquelonpm
Saint Vincent and the Grenadinesvc
Samoaws
San Marinosm
Sao Tome and Principest
Saudi Arabiasa
Senegalsn
Serbia and Montenegrocs
Seychellessc
Sierra Leonesl
Singaporesg
Slovakiask
Sloveniasi
Solomon Islandssb
Somaliaso
South Africaza
South Georgia and the South Sandwich Islandsgs
Spaines
Sri Lankalk
Sudansd
Surinamesr
Svalbard and Jan Mayensj
Swazilandsz
Swedense
Switzerlandch
Syrian Arab Republicsy
Taiwan, Province of Chinatw
Tajikistantj
Tanzania, United Republic oftz
Thailandth
Timor-Lestetl
Togotg
Tokelautk
Tongato
Trinidad and Tobagott
Tunisiatn
Turkeytr
Turkmenistantm
Turks and Caicos Islandstc
Tuvalutv
Ugandaug
Ukraineua
United Arab Emiratesae
United Kingdomuk
United Statesus
United States Minor Outlying Islandsum
Uruguayuy
Uzbekistanuz
Vanuatuvu
Venezuelave
Viet Namvn
Virgin Islands, Britishvg
Virgin Islands, U.S.vi
Wallis and Futunawf
Western Saharaeh
Yemenye
Zambiazm
Zimbabwezw

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2024-08-21 UTC.