Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Cannot Register Analyzer #506

Closed
mihikjw opened this issue Sep 22, 2023 · 1 comment
Closed

[BUG] Cannot Register Analyzer #506

mihikjw opened this issue Sep 22, 2023 · 1 comment
Labels
bug Something isn't working untriaged Need triage

Comments

@mihikjw
Copy link

mihikjw commented Sep 22, 2023

What is the bug?

Registering an analyzer using the example method returns an error when creating the index:

opensearchpy.exceptions.RequestError: RequestError(400, 'mapper_parsing_exception', 'Failed to parse mapping [_doc]: analyzer [whitespace_analyzer] has not been configured in mappings')

It looks like when it goes through the following function:

class Index(object):
   def analyzer(self, *args, **kwargs):
      analyzer = analysis.analyzer(*args, **kwargs)
      d = analyzer.get_analysis_definition()
      # empty custom analyzer, probably already defined out of our control
      if not d:
         return

      # merge the definition
      merge(self._analysis, d, True)

d is always an empty dict taken from BuiltinAnalyzer.get_analysis_definition - resulting in the definition not being merged.

Am I missing a step, or is this a bug?

How can one reproduce the bug?

standards_index = Index("standards")

@standards_index.document
class StandardDocument(Document):
    id = Keyword(required=True)
    name = Text(
        required=True,
        analyzer=ngram_analyzer,
        search_analyzer=whitespace_analyzer,
        fields={"raw": Keyword()},
    )

# ...

whitespace_analyzer = analyzer(
    "whitespace_analyzer",
    tokenizer="whitespace",
    filter=["lowercase", "asciifolding"],
)

# ...

index.analyzer(whitespace_analyzer)
index.create(using=connection)   # this line triggers the exception

What is the expected behavior?

The Analyzer is registered correctly and the index can be created with StandardDocument and not trigger an exception.

What is your host/environment?

WSL2 Ubuntu 18.04.5 LTS

Do you have any screenshots?

N/A

Do you have any additional context?

N/A

@mihikjw mihikjw added bug Something isn't working untriaged Need triage labels Sep 22, 2023
@mihikjw mihikjw closed this as completed Sep 22, 2023
@dblock
Copy link
Member

dblock commented Sep 26, 2023

@mihikjw What was your issue, and how did you solve it, for the next person?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working untriaged Need triage
Projects
None yet
Development

No branches or pull requests

2 participants