added related fields into the search capability consistently in all DB#78
added related fields into the search capability consistently in all DB#78Nightwing-77 wants to merge 10 commits intowagtail:mainfrom
Conversation
|
@Nightwing-77 It looks like this PR incorporates changes from a previous version of #68 - please can you rebase this on current main? I'm also not clear on what exactly this PR is fixing. If this is indeed making For context - the |
hey! sure i'll rebase it!! also i'm very confident the functionality of .search is working on db backend !! i don't exactly remember where but i think i did face that issue and fix it!! maybe in #68 (it's been some time , i don't remember rt now) : could u go and check out the test case in test_postgres_backend.py |
0f23e52 to
5b45c5a
Compare
|
@gasman i've added the proper test case and was able to get the testcases to pass for postgresql , i'm not sure why it kept failing for other two!! |
2055535 to
577e09b
Compare
In the current database search, related fields were not being considered because they were pre-filtered in the get_searchable_search_fields function.
To address this:
I switched to using the get_search_fields function, which returns all fields.
Flattened the field tree and converted related fields into a combined format.
Example: related field (author) { search field (name) } becomes searchfield(author__name).
The original get_search_field function was intended for tree traversal, but it only returned a flattened tree with filtered search fields, so I simplified the logic.
Now, the search vector is constructed using SearchVector(author__name).
While building the search vector, annotations are filtered out, and only the actual field names are used.