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

Fix search results always being empty when using a backend that doesn't return highlights #8729

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

mlaily
Copy link

@mlaily mlaily commented Jan 7, 2024

Fix search results always being empty when using a backend that doesn't return highlights.

This notably happens with Synapse on SQLite.

Type of change

  • Feature
  • Bugfix
  • Technical
  • Other :

Content

Search results are filtered to make sure there is at least one match with the highlights returned by the backend.

The issue is that some backends — in my case Synapse with SQLite instead of PostGreSQL — return an empty array for highlights.

The result is that search results always appear empty from the Android app. (The web element app does something different because search results look ok there with the same server)

As a minimal workaround I simply bypassed the filter in case the highlights are empty.

This should preserve the existing behaviour in most situation while allowing the search page to work when highlights are not returned by the backend.

Motivation and context

No open issue AFAIK

Screenshots / GIFs

Tests

I tested my changes on my own homeserver to make sure it works.

Tested devices

  • Physical
  • Emulator
  • OS version(s): Android 13 (33)

Checklist

Signed-off-by: Melvyn Laïly melvyn.laily@gmail.com

@mlaily mlaily force-pushed the fix-search-without-highlights branch from 9180675 to 9e64cb7 Compare January 7, 2024 21:07
…urn highlights

This notably happens with Synapse on SQLite.
@mlaily mlaily force-pushed the fix-search-without-highlights branch from 9e64cb7 to 342d46b Compare January 7, 2024 21:08
@bmarty bmarty added the Z-Community-PR Issue is solved by a community member's PR label Jan 30, 2024
Copy link
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merci pour le PR @mlaily !
The method setHighLightedText may return null to mitigate this issue: element-hq/synapse#8686. It's maybe worth checking the status of this Synapse issue before being able to merge this change.

// In this case, don't attempt to filter based on the highlights, to avoid erasing all the results...
if (highlights.isEmpty()) {
return wordToSpan
}
Copy link
Member

@bmarty bmarty Jan 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will work, hence another possible fix would have been to just remove the var found below.
But it's maybe clearer like this.

@mlaily
Copy link
Author

mlaily commented Feb 5, 2024

Hi @bmarty, thanks for the review!

I noticed the issue you mentioned, but it's still open and I'm not knowledgeable enough about synapse to be certain it's solved or not myself.

I felt it was better to be conservative and keep the existing filtering behavior as is and just add a check for the specific situation where the highlights are not returned at all.

Does the PR looks okay to you? If not I'm sorry but I'm not sure what I should change. Could you point me in the direction you think is correct?

Thanks!

@bmarty
Copy link
Member

bmarty commented Feb 16, 2024

Hi @mlaily ,

Thanks for the feedback. This project is in maintenance mode now, we are focusing on Element X now (https://github.com/element-hq/element-x-android).

So we would merge only PRs that fixes critical issues, or PRs which do not contain any doubt. I am afraid that we do not want to go further with the proposal changes.

@mlaily
Copy link
Author

mlaily commented Feb 16, 2024

Hi,

Oh ok I didn't know that.

Is the switch to Element X planned soon though? It is still in pre-alpha according to its readme, and I just tried to use it with my home server but it doesn't work because I don't have the sliding sync feature enabled...

So we would merge only PRs that fixes critical issues, or PRs which do not contain any doubt.

The search feature not working at all seems like a pretty big issue to me, even though it only happens with some backends...
It is nonetheless a real annoyance my users are facing right now.

I don't understand your doubts about my 3 lines of code fix so it's a bit disappointing to hear.

I hope you can somehow revisit this decision.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Z-Community-PR Issue is solved by a community member's PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants