Skip to content

Unclear error message when using custom "synonym" with Analyze API #23943

Closed
@tsouza

Description

@tsouza

According to synonym filter comment:

/*
 * synonym and synonym_graph are different than everything else since they need access to the tokenizer factories for the index.
 * instead of building the infrastructure for plugins we rather make it a real exception to not pollute the general interface and
 * hide internal data-structures as much as possible.
*/

Because of this limitation, if you try to use it like the following (which is a valid syntax since the Analyze API docs mentions it but with stop filter instead):

GET _analyze
{
  "tokenizer": "standard",
  "filter": [{
    "type": "synonym",
    "synonyms": ["test,testing"]
  }],
  "text": "this is a test"
}

You will get the following error: failed to find global token filter under [synonym]

This is misleading since it is the same error that you get if you use an unknown token filter name and, for newbies, specially the ones that just learned about the Analyze API, it can be confusing since synonym should be a valid token filter name and the docs does not mentions this particular limitation of synonym token filter.

Moreover, IMO synonym should be supported by /_analyze API anyway, if possible. Since it only works in the context of an index, the need to create a new test index every time you change the synonym configuration can be a time consuming task compared to simply using the /_analyze API.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions