When several documents contain the same search term, field length helps decide whether that term is genuinely informative. A match in a short title usually carries more weight than the same match buried in a long synopsis. section 3.4.1 section 3.4.2
The algorithm contributes to relevance scoring in three connected ways:
- Counts term frequency: repeated occurrences of a search word in a field generally increase its score. section 3.4.2
- Accounts for inverse document frequency: terms appearing throughout the index contribute less discriminating power. section 3.4.2
- Normalizes for field length: a term appearing in a shorter field can be more relevant than the same term in a longer field. section 3.4.2 section 3.4.1
Java in book titles
Suppose a title search looks for Java. “Effective Java” contains two words, while “Head First Java” contains three; although both match, the shorter title can receive the stronger relevance score. A longer synopsis illustrates the same principle: one occurrence in a 100-word synopsis is less informative than two occurrences in a five-word title. section 3.4.1
Elasticsearch applies BM25 by default for this scoring example. Its b parameter controls term-frequency normalization based on document length and has a listed default of 0.75. Elasticsearch also supports other similarity algorithms and per-field similarity configuration; custom algorithms are an advanced option. section 3.4.1
