1 Query strings explained.
A query string is a modification to a URL (or web address; link).
Consider the different effects of these two superficially similar URLs:
The only difference is that one link had the string ?q=dog at the end. This string has two parts: the question mark ? and a key-value pair q=dog. The ? is the sending website saying to the target website “I’m about to send you one or more key-value pairs”. The *= sign bonds the key and value as a pair.
A key-value pair is a piece of formal notation for expressing that a particular variable (the key part of the key-value pair, q in our example) should be treated as though it currently holds a particular value (the value part of the key-value pair, dog in our example). Usually the key is more meaningful to the receiving website and the value is more meaningful to the sending website.
In our example, the google page offers up a text-entry field in which the user types thier query. The query text is thought of as a value, and Google needs a variable (or key) to hold this value. The name of the variable is q. So if the user types ‘dog’ then the key ‘q’ would hold the value ‘dog’ and we’d have a key-value pair q=dog. But typing ‘dog’ in the text-entry field isn’t the only way to send the q=dog key-value pair to google.
Assuming that the sender crafting the URL knows the convention that the contemts of the free-text box are referred to by Google using q ; and assuming that both parties understand the convention that the question mark punctuation item signals the onset of one or more key-value pairs, the sender can get google to carry out their dog search by embedding it in the link used to access google’s site.
I said that the question mark signifies that one or more key-value pairs are coming up. Consider this URL:
http://www.google.com/search?q=stroop&lr=lang_fr
This breaks down into
- the base URK for google search: http://www.google.com/search
- A question mark operator to indicate that one or more key-value pairs are coming up
- the key-value pair
q=stroopto pass the search term ‘stroop’ into its key ‘q’ - An ampersand character which acts to separate one key-value pair from the next in case of a chain of them
- another key-value pair
lr=lang_fr. The key ‘lr’ is ‘language results’ and the value ‘lang_fr’ is the code for French, so this key-value pair requests French-language results for the main search term.
So this URL is intended to return hits for French-langusge versions of the Stroop test: this is what it returned:


