Monday, May 11, 2026

Searches Are Weird! No they're not! Bad coding style?

In David Marcus's guest post on good coding style (see here)  he reviewed a book from 1986 called  "Professional Pascal."

I wondered if it was still in print and could be bought:

1) I went to Amazon and searched all products for Professional Pascal. I got this, which is not that book.

2) I then restricted to books, and I got the same, though later on the page I got a relevant book, here.

3) I then searched for Professional Pascal on Google, and got the Amazon site for the book here.

David thought this was weird. I did not. As I put it:

A computer does something which makes no sense. This is common, hence it's not weird.

Why did the search from outside of Amazon do better than the search inside of Amazon?

Speculation

1) Search is just a really hard problem.

2) The coders at Amazon did not use good coding style. They should read the book. If they can find it. 

7 comments:

  1. It's even weirder. A lot of times google search will give a (supposed) link to Amazon. When I click on it, I don't get what the link summary says. Amazon also has some sort of internal ranking, where it ranks the things that it would like to sell you on top, even if that's not what you've searched for.

    ReplyDelete
  2. Cory Doctorow has thoroughly explained this phenomenon multiple times. I believe this post is the first instance I saw: https://pluralistic.net/2022/11/28/enshittification/

    ReplyDelete
  3. What if the search function is not designed to help you effectively find things, but to maximize profit? Showing sponsored items over more correct ones, more profitable items over better deals, versions of items in stock already near you rather than across the country, etc. The price slider doesn't even go low enough sometimes, but the technology supports this by manually modifying the URL.

    The ineffective search is probably a design decision.

    ReplyDelete
  4. FWIW, if I go to amazon.com and put "professional pascal" -- _with_ the quotation marks -- into its search box, the first result is Ledgard's book. If I go to amazon.co.uk (I happen to be located in the UK) Ledgard's book is the first result even without the quotation marks.

    But, indeed, on amazon.com without the quotation marks I get a list of watches and toys and things, with the book nowhere in sight. If I restrict to "Books" then it tells me "No results for professional pascal in Books" even though the same search with the quotation marks gets me Ledgard's book, and two other things whose names do indeed include "professional Pascal". I assume these results are similar to Bill's. So something is definitely terribly wrong with their searching.

    I have a third speculation about why Amazon's search produces such crazy results: what they want it to do isn't the same thing as you want it to do. (a) Maybe an _average Amazon customer_ searching for professional + Pascal really is more interested in the watches and toys and things than in a programming-style book from the 1980s. If they weight their search results towards e.g. things that are bought more often, then that would _very partially_ explain what we see. (Only very partially, because what I get is a list of just 21 items, none of which is the book.) (b) I haven't checked but I suspect all those watches and toys and things are sold _by Amazon itself_, whereas the book is sold by someone else and e.g. Amazon don't get much of the profit from the sale.

    These observations would be pretty well explained by the following theory, which for other reasons I don't actually believe: a search on Amazon will, if possible, return only items that ship from Amazon (i.e., they are held in Amazon's warehouses and so Amazon is providing something more than just a storefront). If no such items match the search then it will show things that ship from elsewhere. There are 21 ship-from-Amazon things matching <> so you get to see those. But there are none matching <<"professional pascal">> so the search falls back to showing you the things that _don't_ ship from Amazon, including the book you actually want.

    (I don't quite believe this theory because I am fairly sure I have often seen things that don't ship from Amazon in search results intermingled with things that do. So more likely the criterion is something more like "ship from Amazon _or_ are popular" or "ship from Amazon _or_ are more than averagely profitable for Amazon despite shipping from elsewhere".)

    ReplyDelete
  5. The Amazon on-site search prioritizes different things. They default the sorting order to "Featured" and their sorting options do not even include "Relevance" (which is a business choice, not a programming one).

    I went to Amazon and typed "Professional Pascal" into the search box (with the quotes) and got the book right away.

    ReplyDelete
  6. Either amazon search does different things for different times or different people, or I didn't put in quotes. Both are plausible.

    ReplyDelete
  7. amazon search does indeed different things depending on geolocation and amazon branch and also whether you are currently using your aws/google/etc/ profile while conducting the search. it's shall we say, stochastic rather than deterministic.

    ReplyDelete