Against Elasticsearch, on real data

WANDS is Wayfair's product search dataset (MIT licence): 480 queries, 42,994 products and 231,873 human judgements (Exact, Partial, Irrelevant). It is a good first test because the answers are not obvious.

WANDS is only an example: judy works against any index, alias or data stream. This command downloads the dataset at a pinned commit, writes the judgement set, creates an index and loads the products into it:

Shell
export ES_URL=https://… ES_API_KEY=…
judy import wands --url env:ES_URL --api-key env:ES_API_KEY
Text
downloading WANDS at 3b74dcf from github.com/wayfair/WANDS
wands.judgements.yaml: 480 queries, 231873 judgements
1575 products were labelled twice for the same query (16 with different labels; the higher grade was kept)
loading 42994 products into judy-wands with a semantic_text field, which runs inference over every product (a few minutes)
  4500/42994
  …
judy-wands: 42994 products

Exact becomes grade 3, Partial grade 1, Irrelevant grade 0. The index gets a semantic_text field product_semantic, fed by copy_to from the name, class and description, so you can compare lexical, semantic and hybrid search. It took 2 minutes 45 seconds here.

Option Meaning
--cluster <name> a cluster from judy.yaml, instead of --url and --api-key
--index <name> the index to create (default judy-wands)
--no-semantic leave out the semantic_text field, so loading runs no inference
--inference-id <id> the inference endpoint for semantic_text (default: the cluster's default)
--commit <ref> another revision of wayfair/WANDS
--recreate delete the index first. Without it judy stops when the index exists
<directory> a folder that already holds query.csv, label.csv and product.csv, instead of downloading

Without --url or --cluster the command writes the judgement set and loads nothing.

A target is a Query DSL body with {{query}} and {{size}} placeholders. Write secrets as env: references so the file can be committed:

YAML
# judy.yaml
clusters:
  live: {url: "env:ES_URL", api_key: "env:ES_API_KEY"}
targets:
  lexical: {dsl: {cluster: live, index: judy-wands, file: queries/lexical.json}}
docs: {id: product_id, title: product_name, text: [product_description]}
Shell
mkdir queries && cat > queries/lexical.json <<'EOF'
{"size": "{{size}}",
 "_source": ["product_id", "product_name", "product_class", "product_description"],
 "query": {"multi_match": {"query": "{{query}}",
   "fields": ["product_name^3", "product_class^2", "category_hierarchy", "product_description", "product_features"]}}}
EOF

The docs: line tells judy how to read an id, a title and text from each hit. The id must be the same value your judgements use (here the WANDS product_id).

Text
$ judy run wands.judgements.yaml --target lexical
ran 480 queries against lexical in 12.4s
set wands  target lexical  labels human
queries 480 (479 scorable)

all
  success@1  0.818
  success@3  0.900
  mrr@10     0.859
  ndcg@10    0.594
  recall@10  0.058
  err@10     0.539
  judged@10  0.865

tag words:1
  success@1  0.957
  success@3  0.957
  mrr@10     0.957
  ndcg@10    0.900
…
tag words:3+
  success@1  0.810
  success@3  0.905
  mrr@10     0.858
  ndcg@10    0.567
…
misses: no relevant result in the top 10 (32)
  beds that have leds
  bathroom vanity knobs
  non slip shower floor tile
  medium size chandelier
  nautical platters
  palram harmony greenhouses
  low profile loveseat recliner
  wishbone chair
  star wars rug
  promo codes or discounts
  ... and 22 more

in plain words
  For 82% of queries the first result is relevant (success@1), and 90% have a relevant result in the
    first three (success@3).
  ndcg@10 is 0.594: the top 10 earns 59% of what a perfect ordering of the judged documents would
    (1.0 is perfect). Use it to compare against a baseline: what is achievable depends on your data.
  …
  32 of 479 queries (7%) returned nothing relevant in the top 10. These are the clearest failures:
    start with the misses listed above.
  By words, words:3+ scores lowest on ndcg@10 (0.567) and words:1 highest (0.900): look at words:3+
    first.
wrote wands.lexical.results.yaml

What one command gives you:

  • Headline metrics. Seven numbers, so a change that trades one for another is visible.
  • Automatic groups. judy tags every query with its length (words:1, words:2, words:3+) and how it was answered (mode:lexical). A one-word query scores 0.900 and a three-word query 0.567: the long queries are where this search is weak.
  • Misses. The 32 queries with nothing relevant in the top ten, named. Start there.
  • In plain words. What the numbers mean for someone new to them, added after the numbers. --no-explain leaves it out.
  • A results file. wands.lexical.results.yaml holds each query's scores and ranked ids, so later comparisons need no cluster. The file wands.lexical.requests.jsonl holds the request judy sent for each query.

judged@10 0.865 says 86.5% of what the search returned in the top ten has a judgement. The rest counts as not relevant, so keep an eye on it, especially for semantic search, which surfaces documents nobody labelled. The judge fills those gaps.

Compare lexical with hybrid search, or measure a router.