org.apache.lucene.analysis.synonym

## Class SolrSynonymParser

- java.lang.Object
- - org.apache.lucene.analysis.synonym.SynonymMap.Builder
  - - org.apache.lucene.analysis.synonym.SynonymMap.Parser
    - - org.apache.lucene.analysis.synonym.SolrSynonymParser

-     public class SolrSynonymParser
      extends SynonymMap.Parser

  Parser for the Solr synonyms format.
  1. Blank lines and lines starting with '#' are comments.
  2. Explicit mappings match any token sequence on the LHS of "=>" and replace with all alternatives on the RHS. These types of mappings ignore the expand parameter in the constructor. Example:

     > i-pod, i pod => ipod

  3. Equivalent synonyms may be separated with commas and give no explicit mapping. In this case the mapping behavior will be taken from the expand parameter in the constructor. This allows the same synonym file to be used in different synonym handling strategies. Example:

     > ipod, i-pod, i pod

  4. Multiple synonym mapping entries are merged. Example:

     > foo => foo bar
     > foo => baz
     > is equivalent to
     > foo => foo bar, baz

  WARNING: This API is experimental and might change in incompatible ways in the next release.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `SolrSynonymParser(boolean dedup, boolean expand, Analyzer analyzer)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `parse(Reader in)` Parse the given input, adding synonyms to the inherited `SynonymMap.Builder`.

    - ### Methods inherited from class org.apache.lucene.analysis.synonym.SynonymMap.Parser

      `analyze`

    - ### Methods inherited from class org.apache.lucene.analysis.synonym.SynonymMap.Builder

      `add, build, join`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### SolrSynonymParser

          public SolrSynonymParser(boolean dedup,
                                   boolean expand,
                                   Analyzer analyzer)

  - ### Method Detail

    - #### parse

          public void parse(Reader in)
                     throws IOException,
                            ParseException

      Description copied from class: `SynonymMap.Parser`
      Parse the given input, adding synonyms to the inherited `SynonymMap.Builder`.
      Specified by:
        `parse` in class `SynonymMap.Parser`
      Parameters:
        `in` - The input to parse
      Throws:
        `IOException`
        `ParseException`

Copyright © 2000-2024 Apache Software Foundation. All Rights Reserved.