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

Spotlight search malfunction after upgrade #2451

Closed
toropok opened this issue Dec 13, 2023 · 2 comments
Closed

Spotlight search malfunction after upgrade #2451

toropok opened this issue Dec 13, 2023 · 2 comments

Comments

@toropok
Copy link
Contributor

toropok commented Dec 13, 2023

Description

After upgrade_2521 customer noticed that spotlight search returns no results.

The reason is:

2023-12-13T10:24:53 INFO senaite.app.spotlight Spotlight query={'listing_searchable_text': u'\u041c\u0430\u043a\u0441\u0438\u043c\u043e*'} for catalog='senaite_catalog_sample'
------
2023-12-13T10:24:53 ERROR Zope.SiteErrorLog 1702437893.10.406990922902 https://---------------/@@API/spotlight/search
Traceback (innermost last):
  Module ZServer.ZPublisher.Publish, line 144, in publish
  Module ZPublisher.mapply, line 85, in mapply
  Module ZServer.ZPublisher.Publish, line 44, in call_object
  Module plone.jsonapi.core.browser.api, line 76, in __call__
  Module plone.jsonapi.core.browser.decorators, line 58, in decorator
  Module simplejson, line 395, in dumps
  Module simplejson.encoder, line 297, in encode
  Module simplejson.encoder, line 379, in iterencode
  Module simplejson.encoder, line 274, in default
TypeError: Object of type Missing is not JSON serializable
------
2023-12-13T10:24:53 ERROR Zope.SiteErrorLog 1702437893.110.412666511337 https://---------------/@@API/spotlight/search
Traceback (innermost last):
  Module ZServer.ZPublisher.Publish, line 144, in publish
  Module ZPublisher.mapply, line 85, in mapply
  Module ZServer.ZPublisher.Publish, line 44, in call_object
  Module plone.jsonapi.core.browser.api, line 76, in __call__
  Module plone.jsonapi.core.browser.decorators, line 58, in decorator
  Module simplejson, line 395, in dumps
  Module simplejson.encoder, line 297, in encode
  Module simplejson.encoder, line 379, in iterencode
  Module simplejson.encoder, line 274, in default
TypeError: Object of type Missing is not JSON serializable

This issue solves when you resave (open the sample page and click save button) the sample manually.

Reindexing samples through the ZMI page doesn't help. What's magical happens after "save" button to repeat it automatically?

@ramonski
Copy link
Contributor

Hi Leo,
thanks for sharing the traceback.

The issue above happens when a metadata (aka column) field hass a missing value, which is an instance of class Missing and it is part of the listing_searchable_text index.

As far as I remember, you extended the search terms for this index with an adapter?

This was probably the changeset that caused your error:
https://github.com/senaite/senaite.core/pull/2273/files

However, with this change we no longer use get_searchable_text_tokens from senaite.core.catalog.utils, which in fact used these Metadata columns.

Therefore, if you extend the search, avoid using this function, because it might give you these Missing values back and cause the above mentioned error.

Besides that, if you simply reindex an index in the catalog, the Metadata is not recreated. But if you save an object, it will reindex all indexes + metadata.

Hope that sheds some light into your issue.

@toropok
Copy link
Contributor Author

toropok commented Dec 13, 2023

@ramonski That's totally makes sense and helps a lot! I absolutely forgot about this legacy adapter!

thank you very much!

@toropok toropok closed this as completed Dec 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants