<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="362935" data-post-id="362935">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="dimamik" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/dimamik/120/39846_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  dimamik
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Hey!</p>
<p><strong>Semantic search</strong> is finally here! Read more in <a href="https://hexdocs.pm/torus/0.4.0/semantic_search.html" rel="noopener nofollow ugc">Semantic search with Torus</a> guide.<br>
Shortly - it allows you to generate embeddings using a configurable (and chainable) adapters and use them to compare against the ones stored in your database.</p>
<p>Supported adapters (for now):</p>
<ul>
<li>
<p><code>Torus.Embeddings.OpenAI</code> - uses OpenAI’s API to generate embeddings.</p>
</li>
<li>
<p><code>Torus.Embeddings.HuggingFace</code> - uses HuggingFace’s API to generate embeddings.</p>
</li>
<li>
<p><code>Torus.Embeddings.LocalNxServing</code> - generate embeddings on your local machine using a variety of models available on Hugging Face</p>
</li>
<li>
<p><code>Torus.Embeddings.PostgresML</code> - uses PostgreSQL <a href="https://PostgresML.org/docs" rel="noopener nofollow ugc">PostgresML extension</a> to generate embeddings</p>
</li>
<li>
<p><code>Torus.Embeddings.Batcher</code> - a long‑running GenServer that collects individual embedding calls, groups them into a single batch, and forwards the batch to the configured <code>embedding_module</code> (any from the above or your custom one).</p>
</li>
<li>
<p><code>Torus.Embeddings.NebulexCache</code> - a wrapper around <a href="https://hexdocs.pm/nebulex/readme.html" rel="noopener nofollow ugc">Nebulex</a> cache, allowing you to cache the embedding calls in memory, so you save the resources/cost of calling the embedding module multiple times for the same input.</p>
</li>
</ul>
<p>And you can easily create your own adapter by implementing the <code>Torus.Embedding</code> behaviour.</p>
<p>So after you’ll pick your favorite embedding adapter, you can add semantic search:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">def search(term) do
  search_vector = Torus.to_vector(term)

  Post
  |&gt; Torus.semantic([p], p.embedding, search_vector, distance: :l2_distance, pre_filter: 0.7)
  |&gt; Repo.all()
end
</code></pre>
<h3><a name="p-362935-future-plans-1" class="anchor" href="#p-362935-future-plans-1" aria-label="Heading link" rel="nofollow"></a>Future plans:</h3>
<ul>
<li>Release <code>torus_example</code> app that would allow experimenting with options and different search types to pick the best one</li>
<li>Add support for highlighting search results. (Base off of a <code>ts_headline</code> function)</li>
<li>Extend similarity search to support <a href="https://www.postgresql.org/docs/current/fuzzystrmatch.html" rel="noopener nofollow ugc"><code>fuzzystrmatch</code></a> extension distance options.</li>
</ul>
<h3><a name="p-362935-links-2" class="anchor" href="#p-362935-links-2" aria-label="Heading link" rel="nofollow"></a>Links</h3>
<ul>
<li><a href="https://hexdocs.pm/torus/0.4.0/semantic_search.html" class="inline-onebox" rel="noopener nofollow ugc">Semantic search — Torus v0.4.0</a></li>
<li><a href="https://github.com/dimamik/torus" class="inline-onebox" rel="noopener nofollow ugc">GitHub - dimamik/torus: Torus bridges Ecto and PostgreSQL, simplifying building search queries. · GitHub</a></li>
</ul> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="362935" data-batch-url="/posts/batch_likers">
                        5
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/torus-integrate-postgresqls-search-into-ecto-queries/70024/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-362935" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="362935"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #11"></div>
  </section>
</div>
    <div class="postbit" id="367252" data-post-id="367252">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="jam" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/jam/120/36266_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  jam
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Hey <a class="mention" href="/u/dimamik" rel="nofollow">@dimamik</a>, thanks for making this! Looks very useful. I’m putting it in play on a project. Is it possible to stack <code>ilike</code> and <code>similarity</code> or will it be? Or is there a better approach than this?</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">query =
  if String.length(query) &lt; 2 do
    base_query |&gt; Torus.ilike([u, _m], [u.username], Utils.sanitize_ilike(input) &lt;&gt; "%")
  else
    base_query |&gt; Torus.similarity([u, _m], [u.username], input, pre_filter: true)
  end
...
</code></pre>
<p>Fwiw, I think it’d be nice if it also auto-sanitized <code>ilike</code> queries.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="367252" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/torus-integrate-postgresqls-search-into-ecto-queries/70024/13">Post #12</a>
	                </div>
	            </div>
              <div id="likers-container-367252" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="367252"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #12"></div>
  </section>
</div>
    <div class="postbit" id="367255" data-post-id="367255">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="dimamik" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/dimamik/120/39846_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  dimamik
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Hey! Thanks a lot! So we’ve been using it this way:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">  def search(query, term) when length(term) &lt; 3 do
    term = Torus.sanitize(term)

    Torus.ilike(query, [u], [u.username], term &lt;&gt; "%")
  end

  def search(query, term) do
    Torus.similarity(query, [u], [u.username], term)
  end
</code></pre>
<p>But yes, there are plans to make it composable so that you can use different search types in a single query!<br>
And regarding the sanitization, I’ve opted to expose <code>Torus.sanitize/1</code> instead of embedding it into the term itself. Probably should improve the visibility of it though</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="367255" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/torus-integrate-postgresqls-search-into-ecto-queries/70024/14">Post #13</a>
	                </div>
	            </div>
              <div id="likers-container-367255" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="367255"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #13"></div>
  </section>
</div>
    <div class="postbit" id="367271" data-post-id="367271">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="jam" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/jam/120/36266_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  jam
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<blockquote>
<p>there are plans to make it composable</p>
</blockquote>
<p>Nice! And thanks for pointing me to the <code>sanitize</code> function. <img src="https://forum.elixirforum.com/images/emoji/apple/slight_smile.png?v=15" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20"></p>
<p>One other quick question: where should I set this <code>SET pg_trgm.word_similarity_threshold = 0.3</code>?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="367271" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/torus-integrate-postgresqls-search-into-ecto-queries/70024/15">Post #14</a>
	                </div>
	            </div>
              <div id="likers-container-367271" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="367271"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #14"></div>
  </section>
</div>
    <div class="postbit" id="367292" data-post-id="367292">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="dimamik" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/dimamik/120/39846_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  dimamik
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>There are a few options, either in <code>postgresql.conf</code> or per-database in a migration:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">defmodule YourApp.Repo.Migrations.SetWordSimilarityThreshold do
  use Ecto.Migration

  @database Application.compile_env!(:your_app_name, YourApp.Repo)[:database]

  def up do
    execute("""
    ALTER DATABASE #{@database} SET pg_trgm.word_similarity_threshold = 0.5;
    """)
  end

  def down do
    execute("""
    ALTER DATABASE #{@database} RESET pg_trgm.word_similarity_threshold;
    """)
  end
end

</code></pre> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="367292" data-batch-url="/posts/batch_likers">
                        2
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/torus-integrate-postgresqls-search-into-ecto-queries/70024/16">Post #15</a>
	                </div>
	            </div>
              <div id="likers-container-367292" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="367292"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #15"></div>
  </section>
</div>
    <div class="postbit" id="367636" data-post-id="367636">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="dimamik" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/dimamik/120/39846_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  dimamik
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<h2><a name="p-367636-torus-v052-is-released-1" class="anchor" href="#p-367636-torus-v052-is-released-1" aria-label="Heading link" rel="nofollow"></a>Torus v0.5.2 is released!</h2>
<h2><a name="p-367636-new-2" class="anchor" href="#p-367636-new-2" aria-label="Heading link" rel="nofollow"></a>New <img src="https://forum.elixirforum.com/images/emoji/apple/fire.png?v=15" title=":fire:" class="emoji" alt=":fire:" loading="lazy" width="20" height="20"></h2>
<ul>
<li>New <a href="https://torus.dimamik.com" rel="noopener nofollow ugc">demo page</a> where you can explore different search types and their options. It also includes semantic search, so if you’re hesitant - go check it out!</li>
<li>Other documentation improvements</li>
</ul>
<h2><a name="p-367636-fixes-3" class="anchor" href="#p-367636-fixes-3" aria-label="Heading link" rel="nofollow"></a>Fixes</h2>
<ul>
<li>Correctly handles <code>order: :none</code> in <code>Torus.semantic/5</code> search.</li>
<li>Updates <code>Torus.Embeddings.HuggingFace</code> to point to the updated feature extraction endpoint.</li>
<li>Suppresses warnings for missing <code>ecto_sql</code> dependency by adding it to the required dependencies. Most of us already had it, but now it’ll be explicit.</li>
<li>Correctly parses an array of integers in <code>Torus.QueryInspector.substituted_sql/3</code> and <code>Torus.QueryInspector.tap_substituted_sql/3</code>. Now we should be able to handle all possible query variations.</li>
</ul>
<aside class="onebox allowlistedgeneric" data-onebox-src="https://torus.dimamik.com">
  <header class="source">

      <a href="https://torus.dimamik.com" target="_blank" rel="noopener nofollow ugc">torus.dimamik.com</a>
  </header>

  <article class="onebox-body">
    

<h3><a href="https://torus.dimamik.com" target="_blank" rel="noopener nofollow ugc">Torus search demo
     · Phoenix Framework</a></h3>



  </article>

  <div class="onebox-metadata">
    
    
  </div>

  <div style="clear: both"></div>
</aside>

<p><a href="https://github.com/dimamik/torus" class="onebox" target="_blank" rel="noopener nofollow ugc">https://github.com/dimamik/torus</a></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="367636" data-batch-url="/posts/batch_likers">
                        5
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/torus-integrate-postgresqls-search-into-ecto-queries/70024/17">Post #16</a>
	                </div>
	            </div>
              <div id="likers-container-367636" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="367636"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #16"></div>
  </section>
</div>
    <div class="postbit" id="383048" data-post-id="383048">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="dimamik" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/dimamik/120/39846_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  dimamik
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<h2><a name="p-383048-bm25-full-text-search-is-now-available-via-the-new-torusbm255httpshexdocspmtorustorushtmlbm255-macro-1" class="anchor" href="#p-383048-bm25-full-text-search-is-now-available-via-the-new-torusbm255httpshexdocspmtorustorushtmlbm255-macro-1" aria-label="Heading link" rel="nofollow"></a><img src="https://forum.elixirforum.com/images/emoji/apple/fire.png?v=15" title=":fire:" class="emoji" alt=":fire:" loading="lazy" width="20" height="20"> <strong>BM25 Full-Text Search</strong> is now available via the new <a href="https://hexdocs.pm/torus/Torus.html#bm25/5" rel="noopener nofollow ugc"><code>Torus.bm25/5</code></a> macro</h2>
<p><a href="https://en.wikipedia.org/wiki/Okapi_BM25" rel="noopener nofollow ugc">BM25</a> is a modern ranking algorithm that generally provides superior relevance scoring compared to traditional TF-IDF (used by <code>full_text/5</code>). This integration uses the <a href="https://github.com/timescale/pg_textsearch" rel="noopener nofollow ugc">pg_textsearch</a> extension by Timescale.</p>
<p><strong>See it in action <a href="https://torus.dimamik.com/?method=bm25" rel="noopener nofollow ugc">on the demo page</a></strong></p>
<h2><a name="p-383048-key-features-2" class="anchor" href="#p-383048-key-features-2" aria-label="Heading link" rel="nofollow"></a>Key features:</h2>
<ul>
<li>State-of-the-art BM25 ranking with configurable index parameters (k1, b)</li>
<li>Blazingly fast top-k queries via Block-Max WAND optimization (<code>Torus.bm25/5</code> + <code>limit</code>)</li>
<li>Simple syntax: <code>Post |&gt; Torus.bm25([p], p.body, "search term") |&gt; limit(10)</code></li>
<li>Score selection with <code>:score_key</code> and post-filtering with <code>:score_threshold</code></li>
<li>Language/stemming configured at index creation via <code>text_config</code></li>
</ul>
<h2><a name="p-383048-requirements-3" class="anchor" href="#p-383048-requirements-3" aria-label="Heading link" rel="nofollow"></a>Requirements:</h2>
<ul>
<li>PostgreSQL 17+</li>
<li>pg_textsearch extension installed</li>
<li>BM25 index on the search column (with <code>text_config</code> for language)</li>
</ul>
<p>See the <a href="https://dimamik.com/posts/bm25_search" rel="noopener nofollow ugc">BM25 Search Guide</a> for detailed setup instructions and examples.</p>
<h2><a name="p-383048-when-to-use-bm25-vs-full_text-4" class="anchor" href="#p-383048-when-to-use-bm25-vs-full_text-4" aria-label="Heading link" rel="nofollow"></a><strong>When to use bm25 vs full_text:</strong></h2>
<ul>
<li>Use <code>bm25/5</code> for fast single-column search with modern relevance ranking</li>
<li>Use <code>full_text/5</code> for multi-column search with weights or when using stored tsvector columns</li>
</ul>
<hr>
<p>Special thanks to folks from <a href="https://podcast.thinkingelixir.com/" rel="noopener nofollow ugc">Thinking Elixir</a> for pointing to this fantastic <code>pg_textsearch</code> extension that does the heavy lifting here.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="383048" data-batch-url="/posts/batch_likers">
                        7
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/torus-integrate-postgresqls-search-into-ecto-queries/70024/18">Post #17</a>
	                </div>
	            </div>
              <div id="likers-container-383048" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="383048"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #17"></div>
  </section>
</div>
    <div class="postbit" id="390465" data-post-id="390465">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="hakarabakara1" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/hakarabakara1/120/40651_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  hakarabakara1
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Thank you for this package. I am migrating from simple text matching to fulltext search and wondering how this would be merged into our set-up with multiple association.</p>
<p>We have University which offers Course which has a Category at a Campus which references table Location. The University has many Tags. A single search can be compared to University name and description, Campus name and description, Location name, or can match Course title and description, Campus name can be matched. It’s a long and complex query but we’d like to return not only matching terms but relevant results as well. Thank you for looking into it</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="390465" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/torus-integrate-postgresqls-search-into-ecto-queries/70024/19">Post #18</a>
	                </div>
	            </div>
              <div id="likers-container-390465" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="390465"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #18"></div>
  </section>
</div>
    <div class="postbit" id="390503" data-post-id="390503">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="dimamik" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/dimamik/120/39846_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  dimamik
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Hi! Thanks for reaching out.</p>
<p>In <code>Torus</code>, you can normally add any associations from your query into the bindings (and qualifiers) lists. So it could look something like that:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">Course
|&gt; join(:inner, [course], university in assoc(course, :university))
|&gt; join(:inner, [course], campus in assoc(course, :campus))
|&gt; join(:inner, [course, university, campus], location in assoc(campus, :location))
|&gt; Torus.full_text(
  [course, university, campus, location],
  [
    course.title,
    course.description,
    university.name,
    university.description,
    campus.name,
    campus.description,
    location.name
  ],
  term
)
|&gt; select([course], course.title)
|&gt; Repo.all()
</code></pre>
<p>And then you could tweak the search to satisfy your relevance needs using <a href="https://torus.hexdocs.pm/Torus.html#full_text/5" rel="noopener nofollow ugc"><code>full_text</code> options</a>.</p>
<p>If you’re interested in combining different search techniques - I suggest building two separate queries (and route them based, for example, on the length of input term).</p>
<p>Does this answer your question?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="390503" data-batch-url="/posts/batch_likers">
                        2
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/torus-integrate-postgresqls-search-into-ecto-queries/70024/20">Post #19</a>
	                </div>
	            </div>
              <div id="likers-container-390503" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="390503"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #19"></div>
  </section>
</div>
    <div class="postbit" id="391245" data-post-id="391245">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="hakarabakara1" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/hakarabakara1/120/40651_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  hakarabakara1
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Looks interesting. Let me play around with it and compare with tsvector for benchmarks</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="391245" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/torus-integrate-postgresqls-search-into-ecto-queries/70024/21">Post #20</a>
	                </div>
	            </div>
              <div id="likers-container-391245" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="391245"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #20"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <a class="load-more-button" data-turbo-stream="true" href="/topics/70024/load_more?page=3">Load more posts (3 remaining)</a>
</div></template></turbo-stream>