How Do Search Engines Work?

A search engine has already explored and catalogued billions of web pages, so it can instantly show the ones most likely to answer your question.

Think of it like this

It's like a librarian who has read every book in a vast library and kept detailed notes on which pages mention which topics. When you ask a question, they don't run off to read the shelves again - they check their notes and hand you the most useful pages first. Meanwhile, assistants keep walking the shelves, noting new books and changed pages so the notes stay fresh.

What's happening

Diagram in four numbered steps: a crawler robot follows links between web pages A to D; an index records which pages contain which words; for the search chocolate cake, the matching pages are scored on relevance, trust and links; and the results page lists pages A, D and C in order. Crawling and indexing happen in advance, while ranking and results happen when you search

Summary

A search engine constantly explores the web, stores what it finds in a giant index, and when you search, picks out and ranks the most useful matching pages in a fraction of a second.

A Closer Look

Search engines start by crawling. Automated programs called crawlers (also known as spiders or bots) visit web pages, read their content and follow the links they find to discover more pages, rather like exploring a city by taking every turning. Because websites change constantly, crawlers keep coming back, visiting busy news sites far more often than a page that rarely changes. Website owners can leave instructions in a small file called robots.txt asking crawlers to stay out of certain areas, and they can submit a list of their pages, called a sitemap, so nothing gets missed. Pages hidden behind a login, such as your email or online banking, are never crawled at all.

Everything the crawlers collect is processed into an index: an enormous organised record of which words and topics appear on which pages, along with details such as each page's language, when it was last updated and whether it works well on phones. It's the same idea as the index at the back of a textbook, which tells you every page that mentions a word without you having to read the whole book. This is the secret of the speed. When you press Search, the engine isn't scanning the live web - it's looking up your words in an index it built earlier, which is also why a brand-new page can take a while to appear in results.

The hard part is ranking: deciding which of thousands of matching pages to show first. Search engines weigh up many signals, such as how closely a page matches what you meant, how trustworthy and up to date it seems, and whether other respected sites link to it. That last idea made Google famous. In the late 1990s its founders, Larry Page and Sergey Brin, then students at Stanford University, treated each link as a kind of vote, giving more weight to votes from pages that were themselves well linked. Results are also tailored to you, using things like your language and rough location, which is why searching for pizza shows places nearby. The exact ranking rules are closely guarded and adjusted regularly, partly to stop people gaming them.

Common Misconceptions

  • A search engine doesn't search the whole internet live - it searches its own stored index, built from pages it crawled earlier.
  • The top result isn't guaranteed to be the most accurate answer - it's the page the ranking system judged most likely to be useful, and it can be wrong.
  • Paying a search engine doesn't buy a higher place in the ordinary results - paid adverts are shown separately and labelled as sponsored.

Frequently asked questions

Why do I see different results from someone else searching the same thing?

Search engines tailor results to the person searching. Your rough location, language and device all play a part, and if you're signed in, your past searches and settings may too. Results also shift over time as new pages are found and rankings are updated. So two people sitting side by side can see slightly different results, especially for local searches such as shops, opening times or anything 'near me'.

How does a new website get onto search engines?

Usually by being found. Once another page links to it, crawlers will eventually follow that link and add the new site to the index. Owners can speed this up by signing up to the free webmaster tools that the major search engines offer and submitting a sitemap. There's no guarantee of being listed or ranking well, though: pages need to be reachable, useful and not blocked from crawlers.

Do search engines remember what I search for?

Most major search engines keep a record of searches, which they use to improve results and to decide which adverts to show. If you're signed in to an account, your search history may be linked to it, and you can usually view or delete it in your account settings. Some search engines promise not to build a profile of you. Private browsing stops your own device saving the history, but not the search engine.

How it connects

Search engines bring together ideas from across the web:

Try it yourself

Search for something you're curious about, then search again with quotation marks around a phrase, such as "chocolate chip cookies", to find only pages using those exact words. Next, add site:bbc.co.uk to your search to see results from just that one website, and notice how precisely you can steer the index.