Web / Apache Lucene Interview questions
What is the difference between per-field similarity and global similarity configuration?
By default, a single Similarity instance (BM25Similarity, unless changed) is set once on IndexWriterConfig and used uniformly across every field in the index - that's global configuration.
Per-field similarity, via PerFieldSimilarityWrapper, lets different fields use entirely different scoring behavior within the same index. This matters because fields genuinely differ in what "relevant" means: a short, high-signal title field might benefit from different length-normalization (a lower b value) than a long body field, and a field storing tags might not want length normalization applied at all.
The trade-off is complexity and consistency - per-field similarity makes overall relevance tuning harder to reason about, since scores from different fields being combined (say, in a multi-field BooleanQuery) may no longer be on a directly comparable scale. Most applications start with a single global Similarity and only introduce per-field tuning once a specific field's scoring behavior is demonstrably wrong for its content.
More Related questions...