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


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Just to be clear, <code>Torus</code> uses tsvector as well, so you may be comparing apples to the same apples.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="391249" 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/22">Post #21</a>
	                </div>
	            </div>
              <div id="likers-container-391249" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="391249"
                     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 #21"></div>
  </section>
</div>
    <div class="postbit" id="392773" data-post-id="392773">
  <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>Hello,</p>
<p>Thank you again for this package. I am trying to migrate my previous search which already leveraged upon Postgres triggers to generate tsvector on record create with rankings already depending on column. Should I just use similarity to query the column or do I need to create embedding with the recommended packages to get the best out of Torus?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="392773" 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/23">Post #22</a>
	                </div>
	            </div>
              <div id="likers-container-392773" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="392773"
                     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 #22"></div>
  </section>
</div>
    <div class="postbit" id="393069" data-post-id="393069">
  <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">
								<h1><a name="p-393069-torus-v070-is-out-hybrid-search-and-match-highlighting-1" class="anchor" href="#p-393069-torus-v070-is-out-hybrid-search-and-match-highlighting-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"> Torus v0.7.0 is out - Hybrid Search and Match Highlighting! <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"></h1>
<p><strong>Hybrid search</strong> via the new <strong><a href="https://hexdocs.pm/torus/Torus.html#hybrid/4" rel="noopener nofollow ugc"><code>Torus.hybrid/4</code></a></strong> macro - it combines several search strategies (<code>full_text</code>, <code>bm25</code>, <code>similarity</code>, <code>semantic</code>) into a single ranked query using <a href="https://learn.microsoft.com/en-us/azure/search/hybrid-search-ranking" rel="noopener nofollow ugc">Reciprocal Rank Fusion</a>, the industry-standard way to combine keyword and semantic search:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">search_vector = Torus.to_vector("magic school")

Post
|&gt; Torus.hybrid([p], [
     full_text: {[p.title, p.body], "magic school"},
     semantic: {p.embedding, search_vector, weight: 2.0}
   ], limit: 10)
|&gt; Repo.all()


</code></pre>
<p>Everything runs in a single SQL query, and the result is a regular Ecto query you can keep piping <code>select</code>, <code>preload</code>, or pagination onto. Per-branch weights and limits are tunable. See the <a href="https://hexdocs.pm/torus/hybrid_search.html" rel="noopener nofollow ugc">Hybrid search guide</a> for details.</p>
<p><strong>Match highlighting</strong> via the new <a href="https://hexdocs.pm/torus/Torus.html#highlight/3" rel="noopener nofollow ugc"><code>Torus.highlight/3</code></a> macro, built on <code>ts_headline</code>. The simplest way is the new <code>:highlight</code> option available on all search types:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">Post
|&gt; Torus.full_text([p], [p.title, p.body], "shocker", highlight: [title: p.title])
|&gt; Repo.all()
# =&gt; [%Post{title: "Hogwarts &lt;b&gt;Shocker&lt;/b&gt;", ...}]

</code></pre>
<p>Try both live on the <a href="https://torus.dimamik.com/" rel="noopener nofollow ugc">demo page</a>. Let me know what you think!</p>
<p></p><div class="lightbox-wrapper"><a class="lightbox" href="https://forum.elixirforum.com/uploads/default/original/3X/5/0/50a90b4a6426a846d402d9db6a58867c890c5842.jpeg" data-download-href="https://forum.elixirforum.com/uploads/default/50a90b4a6426a846d402d9db6a58867c890c5842" title="CleanShot 2026-08-24 at 11.55.23" rel="nofollow"><img src="https://forum.elixirforum.com/uploads/default/optimized/3X/5/0/50a90b4a6426a846d402d9db6a58867c890c5842_2_690x440.jpeg" alt="CleanShot 2026-08-24 at 11.55.23" data-base62-sha1="bvyn7EmEwFYZCnWupyokznPXEmm" width="690" height="440" srcset="https://forum.elixirforum.com/uploads/default/optimized/3X/5/0/50a90b4a6426a846d402d9db6a58867c890c5842_2_690x440.jpeg, https://forum.elixirforum.com/uploads/default/optimized/3X/5/0/50a90b4a6426a846d402d9db6a58867c890c5842_2_1035x660.jpeg 1.5x, https://forum.elixirforum.com/uploads/default/original/3X/5/0/50a90b4a6426a846d402d9db6a58867c890c5842.jpeg 2x" data-dominant-color="DEE2E3"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">CleanShot 2026-08-24 at 11.55.23</span><span class="informations">1200×766 56.7 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div><p></p>
<p><img src="https://forum.elixirforum.com/images/emoji/apple/warning.png?v=15" title=":warning:" class="emoji" alt=":warning:" loading="lazy" width="20" height="20"> Heads up on breaking changes: Torus now requires <code>ecto ~&gt; 3.10</code>, and <code>Torus.Embeddings.NebulexCache</code> targets Nebulex 3.0+ (add <code>nebulex_local</code> if you use the cache). Full details in the <a href="https://github.com/dimamik/torus/blob/main/CHANGELOG.md" rel="noopener nofollow ugc">changelog</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="393069" data-batch-url="/posts/batch_likers">
                        3
                      </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/24">Post #23</a>
	                </div>
	            </div>
              <div id="likers-container-393069" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="393069"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-last-post cat-last-post" title="Last post!"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <span class="all-loaded">— All posts loaded —</span>
</div></template></turbo-stream>