Use full text search in fields
Newbie here, is there a way I can fields defined as full text search fields?
10 Replies
What do you mean by "full text search fields"?
basically instead of using ilike to check if string is included in an amalgamation of columns, use tsvector
I might be more of a newbie than you, then, because this is the first time I've heard of tsvector. 😅
Now that I am thinking about this, I basically need to create a migration and create the FTS index, and then just use raw PGSql
so thank you either way
I thought like it can be defined like the vectorization stuff
AshAI might be useful here. It's built for this
I don't want to use embeddings, I need to do some benchmarking
I have a lot of fields and some of them have on value
I could concat everything but I need it for filtering
This is a bit more manual work, but I have also done it in the past using
custom_statments
for createing the indexes and fragment
in calculations to make it searchable and surface things like ts_rank
and ts_headline
do you have a snippet I can use as a reference? I am new to ash
This is what i modeled it after at the time https://github.com/ash-project/ash_hq/blob/33467d034f0cf72b4d263a0e004267d44e820bd4/lib/ash_hq/docs/extensions/search/transformers/add_search_structure.ex#L49-L49
GitHub
ash_hq/lib/ash_hq/docs/extensions/search/transformers/add_search_st...
The Ash Framework homepage and documentation site. - ash-project/ash_hq
it's a bit more involved in there because it's an extension that puts the search elements on the resource
but I just looked at the functions and copied the sql into custom_statments and calculations using fragments