Skip to content

Update search query to use ILIKE operator#100

Open
UTXOnly wants to merge 1 commit into
mainfrom
UTXOnly-fix-search
Open

Update search query to use ILIKE operator#100
UTXOnly wants to merge 1 commit into
mainfrom
UTXOnly-fix-search

Conversation

@UTXOnly

@UTXOnly UTXOnly commented Mar 30, 2025

Copy link
Copy Markdown
Owner

Proposed fix for #99

  • Replaces LIKE operator to use ILIKE operator for searches to be case-insensitive

@UTXOnly UTXOnly linked an issue Mar 30, 2025 that may be closed by this pull request
@gasaichandesu

gasaichandesu commented Apr 11, 2025

Copy link
Copy Markdown
Contributor

Thank you for this PR, I got my hands on to it and my testing showed that global search is much more reliable now. However I found one edge case here not related to this issue.

Let's see generated SQL:

SELECT * FROM events WHERE kind = ANY(ARRAY [0]) 
	AND  EXISTS ( 
		SELECT 1 FROM 
			jsonb_array_elements(tags) as elem WHERE elem::text ILIKE '<query>' 
			OR content ILIKE '%<query>%') 
	ORDER BY created_at DESC LIMIT 100 ;

We are iterating through tags array and checking conditions. However if tags array is empty then we will never hit content ILIKE condition and miss some events. I reproduced this issue on our relay and we are missing some user profiles

The fix here would be to move OR content ILIKE <query> outside of EXISTS subquery. Please let me know if I should create another issue for that so you can merge this PR and close previous issue

I will try to make this fix myself. Unfortunately I do not have much experience in this area but I will try my best

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

search uses case sensitive query

2 participants