Skip to content

test_indexing_item_not_front test is failing #258

Closed

Description

@benoit74

I had to skip this test which is failing for now with most recent libzim:

def test_indexing_item_not_front(tmp_path: pathlib.Path, png_image: pathlib.Path):
fpath = tmp_path / "test.zim"
main_path = "welcome"
with Creator(fpath, main_path).config_dev_metadata() as creator:
creator.add_item(
StaticItem(
filepath=png_image,
path="welcome",
title="brain food", # title used for suggestions
index_data=IndexData(
title="screen", content="car" # title and content used for search
),
hints={libzim.writer.Hint.FRONT_ARTICLE: False}, # mark as not front
)
)
assert fpath.exists()
reader = Archive(fpath)
# "brain" works as a suggestion but "food" doesn't work because since no front
# article is present in the zim file, libzim doesn't create a title xapian index.
# so, when searching suggestion, libzim is fallback to a binary search on the title
# and return only article starting by the query.
# see https://github.com/openzim/libzim/issues/902#issuecomment-2223050129
assert "welcome" in list(reader.get_suggestions("brain"))
assert "welcome" not in list(reader.get_suggestions("food"))
assert "welcome" not in list(reader.get_suggestions("screen"))
assert "welcome" not in list(reader.get_suggestions("car"))
assert reader.get_search_results_count("screen") >= 1
assert reader.get_search_results_count("car") >= 1
assert reader.get_search_results_count("brain") == 0
assert reader.get_search_results_count("food") == 0

This looks like an upstream issue, hopefully only at read time: openzim/libzim#981

Activity

  1. added this to the 5.2.0 milestone on Apr 29, 2025
  2. self-assigned this
    on Apr 29, 2025
  3. added
    upstream
    regression
    on Apr 29, 2025
  4. benoit74 commented on May 13, 2025

    @benoit74
    CollaboratorAuthor

    We've agreed upstream that this was more a kind of bug / unwanted behavior. I will hence fix the test on scraperlib side.

  5. benoit74 commented on May 13, 2025

    @benoit74
    CollaboratorAuthor

    I will move this out of scraperlib 5.2.0:

    • it is not requiring any code change on the lib itself, only on tests
    • we need to test / document / align on more things around all these searches, and this is going to take time ; I would like to be sure about the full-text search behavior when non-front text/html article is passed for instance
  6. modified the milestones: 5.2.0, 5.3.0 on May 13, 2025
  7. modified the milestones: 5.3.0, 5.4.0 on Nov 14, 2025
  8. modified the milestones: 5.4.0, 5.5.0 on Mar 16, 2026
  9. removed
    upstream
    on Oct 20, 2026
  10. removed their assignment
    on Oct 20, 2026
  11. added
    pending clarification
    on Oct 20, 2026
  12. benoit74 commented on Oct 20, 2026

    @benoit74
    CollaboratorAuthor

    If someone wants to clarify this issue around full-text search behavior by fixing the failing test and adding more e.g. when non-front text/html article is passed, you're welcomed.

  13. removed
    pending clarification
    on Oct 20, 2026
  14. benoit74 commented on Oct 20, 2026

    @benoit74
    CollaboratorAuthor

    nota: I feel like sufficient unit tests can cover current libzim behavior and we can consider again that this is the spec for the time being ; if libzim behavior changes, then we can report it upstream and decides where the bug is.

  15. modified the milestones: 5.5.0, 5.6.0 on Oct 20, 2026
  16. rgaudin commented on Oct 21, 2026

    @rgaudin
    Member

    Yes, I think the reasonning was that we are exposing our own API shadowing part of the libzim but I agree we should consider libzim as a dependency and only test our code.

  17. mcwanza commented on Nov 7, 2026

    @mcwanza
    Contributor

    I'd like to take this one, following the last comments: treat libzim's current behavior as the spec. Plan: un-skip test_indexing_item_not_front and assert what libzim 3.13 does today (no suggestions for a non-front item, full-text search still matches), plus two tests for a non-front text/html item, one with custom IndexData and one with libzim's own indexing. Tests only, no library change. Could you assign it to me?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

regression

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions