Skip to main content
When Google returns results for your query, the order they appear in is not arbitrary — it reflects a multi-factor ranking algorithm that weighs relevance, authority, freshness, and location signals simultaneously. As a developer using the Custom Search JSON API, you cannot directly rewrite Google’s ranking formula, but you have a meaningful set of levers that let you steer results toward what matters most for your use case. This page explains how Google scores results and exactly which parameters give you control.

How Google ranks results

Google’s ranking algorithm evaluates hundreds of signals for every candidate page in the index. From a practical developer perspective, four signals matter most:

Relevance

How well does the page match the query? Google looks at keyword frequency, prominence (title vs. body vs. URL), semantic similarity, and the overall topic of the page relative to the query intent.

Authority (PageRank)

How many other credible pages link to this page? The PageRank algorithm — the foundation of Google Search — treats inbound links as votes of confidence. Pages linked by many authoritative sources rank higher than obscure, isolated pages.

Freshness

For time-sensitive topics (news, product releases, events), Google boosts recently published or recently updated pages. A well-ranked older page can be outpaced by a fresh one if the query has recency intent.

Location

Google adjusts rankings based on the geographic context of the search. A query for “restaurants” in France should surface French results ahead of global ones. The gl (geolocation) and cr (country restrict) parameters give you control over this signal.
Within the scope defined by your Search Engine ID (cx), Google applies exactly the same ranking signals it uses for google.com. You are querying the same index — just potentially with a different scope and additional API-layer filters applied on top.

Parameters that influence ranking and results

Sort by date — sort

By default, Google ranks results by relevance. Setting sort=date switches the primary sort key to the estimated publication date of the page, surfacing the most recently published content first.
string
Specifies the sort order. Use date to sort by estimated page publication date (most recent first). Omit the parameter for the default relevance ranking.
Sorting by date trades relevance for recency. A page published yesterday with thin content will outrank a comprehensive authoritative page from last year. Use date sorting for explicitly time-sensitive use cases (news feeds, change logs, announcements) — not for general research queries where relevance matters more.
You can also sort by structured data attributes that your pages expose (e.g., sort=metatags-pubdate for a custom pubdate meta tag, or sort=recipe-ratingstars for pages with Recipe microdata). See the Filtering and sorting structured results guide for details.

Restrict by date — dateRestrict

While sort=date reorders results, dateRestrict filters them — removing any document that falls outside the specified time window entirely. The two parameters are independent and can be combined.
string
Restricts results to pages indexed or published within a relative time window. Format: d[n] (days), w[n] (weeks), m[n] (months), y[n] (years).
Combining sort and dateRestrict for news-style feeds:
Use dateRestrict to power “What’s new?” features, news digests, and change-monitoring tools. It is more precise than adding a year to the q string because it uses Google’s indexed date signal rather than relying on a date appearing in the page text.

Restrict to specific sites — siteSearch

The siteSearch parameter limits results to a particular domain (include mode) or removes results from a domain (exclude mode) for a single request — without changing your engine’s permanent configuration.
A domain name to include or exclude from results. Works in conjunction with siteSearchFilter.
string
Controls whether siteSearch includes or excludes the domain. Values: i (include only), e (exclude).
Site include vs. exclude strategies:

Require a phrase in every result — exactTerms

exactTerms acts as a hard relevance gate: every result returned must contain the specified phrase verbatim. This is the single most powerful lever for improving result precision when you know exactly what a relevant document must say.
string
A phrase that all returned documents must contain. Applies an additional mandatory constraint on top of q.
exactTerms is particularly valuable in professional or technical search applications where terminology precision matters — legal documents, medical literature, compliance content, or API documentation. It eliminates loosely-matched results that contain your keywords but miss the specific concept you need.

Language and geography signals — lr and gl

Two parameters directly influence which language and country variants of content rank highest:
string
Restricts results to documents written in a specific language. Format: lang_XX (e.g., lang_en for English, lang_fr for French, lang_de for German).
string
Boosts results whose country of origin matches the specified two-letter country code (ISO 3166-1 alpha-2). Does not exclude other countries — it applies a relevance boost. Example: us, gb, de, fr, jp.
lr is a hard filter — it removes documents not in the specified language entirely. gl is a soft boost — it promotes results from the specified country but does not exclude others. Use lr when language purity is critical; use gl when you want geographically relevant results without eliminating international content.

Combining ranking controls

The parameters above stack independently — each narrows or reorders the result set on a different dimension. Here are practical patterns for common use cases:
Surfaces only TechCrunch articles about security vulnerabilities from the last week, sorted newest first.
Finds only english-language Kubernetes official docs that explicitly discuss rolling updates.
Finds recent German-language content about e-commerce regulation, boosted for German-origin sources, published within the last 6 months.

What you cannot control

It is equally important to understand the limits of your influence:
If you need to surface specific pages regardless of Google’s ranking — for example, featured articles, pinned announcements, or sponsored results — use the Promotions feature in the Programmable Search Engine Control Panel. Promotions appear in the promotions array of the API response, separate from the organic items array, and are always shown regardless of ranking.