Kurisu

Kurisu

Please can you help me in choosing a good database model to facilitate search queries using PostgreSQL full text search?

Let’s say I have 3 tables: users, profiles and skills.
Resulting in following associations:

  • User has_one Profile (:profile) and Profile belongs_to User (:user).
  • User has_many Skill (:skills) and Skill belongs_to User (:user).

My search feature will show users whith user.name, or profile.introduction, or having one or more skills matching the search term.

My problem here is the one-to-many realtionship between users and skills.

I’m thinking to create a denormaized table or a view just for this search feature.
For example skill_documents with user_id and tsv column (to store the concatenation of all skills names of a given user) . This way everytime an user adds, removes or updates a skill the tsv column will be updated accordingly.

Please do you think this is an acceptable solution or what would you suggest me instead?

Thanks

Edit: I’m not finding the general programming category so I put my question in the members only one.

Edit 2: So as suggested by @dimitarvp I moved my question to Elixir category and added Ecto tags. There is no Ecto dedicated category apparently.

Most Liked

entone

entone

I started playing with Sonic recently, and it’s a really nice lightweight full-text search system. It doesn’t have any distributed functionality, but you could potentially run it using a side-car pattern for super-fast full-text search.

You can see my usage here, GitHub - entone/web_archive_viewer: View MAFF webpage archives directly from the compressed Zip file · GitHub

dimitarvp

dimitarvp

This is a perfectly valid question for the Ecto category btw.

entone

entone

I’m a big proponent of a polyglot database approach, and choosing the right tool for the job. I think pushing your text data to a purpose built DB allows you to make the right choices with regards to your SQL architecture without sacrificing anything for your search functionality.

Same thing for telemetry data and logs.

Where Next?

Popular in Questions Top

nobody
How to bind a phoenix app to a specific ip address? could not find anything about that, nowhere, unfortunately, but for me this is quite...
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
JDanielMartinez
Hi! May someone helps me, please! I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
dotdotdotPaul
Okay, I’m having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I’m sure I’...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New

Other popular topics Top

9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
PeterCarter
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
New
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1144 54120 245
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement