Provides synonym expansion and contraction filters with support for both single-word and multi-word (graph-aware) synonym handling. Supports Solr/Elasticsearch synonym file format with explicit mappings and equivalent groups.
| Type | Name | Description |
|---|---|---|
| TokenFilter | synonym |
Single-word synonym expansion/contraction |
| TokenFilter | synonym_graph |
Graph-aware multi-word synonym filter |
Explicit mapping (one-directional):
ipod, i-pod, i pod => ipod
sea biscuit, seabiscuit => seabiscuit
Equivalent groups (bidirectional):
couch, sofa, divan
notebook, laptop, netbook
| Feature | synonym |
synonym_graph |
|---|---|---|
| Multi-word input | Flattened | Proper graph with posLength |
| Index-time safe | β | β (use at query-time only) |
| Position accuracy | Approximate | Exact graph arcs |
Use synonym for index-time expansion and synonym_graph for query-time with
multi-word synonyms.
use pizza_analysis_synonym::{SynonymFilter, SynonymMap, SynonymRule};
let rules = vec![
SynonymRule::equivalent(vec!["quick", "fast", "speedy"]),
SynonymRule::explicit(vec!["ny", "new york"], "new york"),
];
let map = SynonymMap::from_rules(&rules);
let filter = SynonymFilter::new(map);[dependencies]
pizza-analysis-synonym = "0.1"Or via pizza-analysis-all:
[dependencies]
pizza-analysis-all = { version = "0.1", features = ["synonym"] }MIT
Part of the INFINI Pizza ecosystem