blob: 00bf0d1a301e7f12e6e2718d6b937bb7f632ee69 [file] [log] [blame]
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="A Weight is the specialization of a `Query` for a given set of segments."><meta name="keywords" content="rust, rustlang, rust-lang, Weight"><title>Weight in tantivy::query - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Semibold.ttf.woff2"><link rel="stylesheet" href="../../normalize.css"><link rel="stylesheet" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" href="../../ayu.css" disabled><link rel="stylesheet" href="../../dark.css" disabled><link rel="stylesheet" href="../../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../../storage.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../main.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../../favicon.svg"></head><body class="rustdoc trait"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">&#9776;</button><a class="sidebar-logo" href="../../tantivy/index.html"><div class="logo-container"><img src="http://fulmicoton.com/tantivy-logo/tantivy-logo.png" alt="logo"></div></a><h2></h2></nav><nav class="sidebar"><a class="sidebar-logo" href="../../tantivy/index.html"><div class="logo-container">
<img src="http://fulmicoton.com/tantivy-logo/tantivy-logo.png" alt="logo"></div></a><h2 class="location"><a href="#">Weight</a></h2><div class="sidebar-elems"><section><h3><a href="#required-methods">Required Methods</a></h3><ul class="block"><li><a href="#tymethod.explain">explain</a></li><li><a href="#tymethod.scorer">scorer</a></li></ul><h3><a href="#provided-methods">Provided Methods</a></h3><ul class="block"><li><a href="#method.count">count</a></li><li><a href="#method.for_each">for_each</a></li><li><a href="#method.for_each_no_score">for_each_no_score</a></li><li><a href="#method.for_each_pruning">for_each_pruning</a></li></ul><h3><a href="#implementors">Implementors</a></h3></section><h2><a href="index.html">In tantivy::query</a></h2></div></nav><main><div class="width-limiter"><nav class="sub"><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../wheel.svg"></a></div></div></form></nav><section id="main-content" class="content"><div class="main-heading"><h1 class="fqn">Trait <a href="../index.html">tantivy</a>::<wbr><a href="index.html">query</a>::<wbr><a class="trait" href="#">Weight</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../../clipboard.svg" width="19" height="18" alt="Copy item path"></button></h1><span class="out-of-band"><a class="srclink" href="../../src/tantivy/query/weight.rs.html#58-123">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">&#x2212;</span>]</a></span></div><div class="item-decl"><pre class="rust trait"><code>pub trait Weight: Send + Sync + 'static {
fn <a href="#tymethod.scorer" class="fnname">scorer</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&amp;self,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;reader: &amp;<a class="struct" href="../struct.SegmentReader.html" title="struct tantivy::SegmentReader">SegmentReader</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;boost: <a class="type" href="../type.Score.html" title="type tantivy::Score">Score</a><br>&nbsp;&nbsp;&nbsp;&nbsp;) -&gt; <a class="type" href="../type.Result.html" title="type tantivy::Result">Result</a>&lt;Box&lt;dyn <a class="trait" href="trait.Scorer.html" title="trait tantivy::query::Scorer">Scorer</a>&gt;&gt;;
<span class="item-spacer"></span> fn <a href="#tymethod.explain" class="fnname">explain</a>(&amp;self, reader: &amp;<a class="struct" href="../struct.SegmentReader.html" title="struct tantivy::SegmentReader">SegmentReader</a>, doc: <a class="type" href="../type.DocId.html" title="type tantivy::DocId">DocId</a>) -&gt; <a class="type" href="../type.Result.html" title="type tantivy::Result">Result</a>&lt;<a class="struct" href="struct.Explanation.html" title="struct tantivy::query::Explanation">Explanation</a>&gt;;
fn <a href="#method.count" class="fnname">count</a>(&amp;self, reader: &amp;<a class="struct" href="../struct.SegmentReader.html" title="struct tantivy::SegmentReader">SegmentReader</a>) -&gt; <a class="type" href="../type.Result.html" title="type tantivy::Result">Result</a>&lt;u32&gt; { ... }
<span class="item-spacer"></span> fn <a href="#method.for_each" class="fnname">for_each</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&amp;self,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;reader: &amp;<a class="struct" href="../struct.SegmentReader.html" title="struct tantivy::SegmentReader">SegmentReader</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;callback: &amp;mut dyn FnMut(<a class="type" href="../type.DocId.html" title="type tantivy::DocId">DocId</a>, <a class="type" href="../type.Score.html" title="type tantivy::Score">Score</a>)<br>&nbsp;&nbsp;&nbsp;&nbsp;) -&gt; <a class="type" href="../type.Result.html" title="type tantivy::Result">Result</a>&lt;()&gt; { ... }
<span class="item-spacer"></span> fn <a href="#method.for_each_no_score" class="fnname">for_each_no_score</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&amp;self,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;reader: &amp;<a class="struct" href="../struct.SegmentReader.html" title="struct tantivy::SegmentReader">SegmentReader</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;callback: &amp;mut dyn FnMut(<a class="type" href="../type.DocId.html" title="type tantivy::DocId">DocId</a>)<br>&nbsp;&nbsp;&nbsp;&nbsp;) -&gt; <a class="type" href="../type.Result.html" title="type tantivy::Result">Result</a>&lt;()&gt; { ... }
<span class="item-spacer"></span> fn <a href="#method.for_each_pruning" class="fnname">for_each_pruning</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&amp;self,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;threshold: <a class="type" href="../type.Score.html" title="type tantivy::Score">Score</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;reader: &amp;<a class="struct" href="../struct.SegmentReader.html" title="struct tantivy::SegmentReader">SegmentReader</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;callback: &amp;mut dyn FnMut(<a class="type" href="../type.DocId.html" title="type tantivy::DocId">DocId</a>, <a class="type" href="../type.Score.html" title="type tantivy::Score">Score</a>) -&gt; <a class="type" href="../type.Score.html" title="type tantivy::Score">Score</a><br>&nbsp;&nbsp;&nbsp;&nbsp;) -&gt; <a class="type" href="../type.Result.html" title="type tantivy::Result">Result</a>&lt;()&gt; { ... }
}</code></pre></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>A Weight is the specialization of a <code>Query</code>
for a given set of segments.</p>
<p>See <a href="trait.Query.html"><code>Query</code></a>.</p>
</div></details><h2 id="required-methods" class="small-section-header">Required Methods<a href="#required-methods" class="anchor"></a></h2><div class="methods"><details class="rustdoc-toggle method-toggle" open><summary><section id="tymethod.scorer" class="method has-srclink"><a class="srclink rightside" href="../../src/tantivy/query/weight.rs.html#64">source</a><h4 class="code-header">fn <a href="#tymethod.scorer" class="fnname">scorer</a>(&amp;self, reader: &amp;<a class="struct" href="../struct.SegmentReader.html" title="struct tantivy::SegmentReader">SegmentReader</a>, boost: <a class="type" href="../type.Score.html" title="type tantivy::Score">Score</a>) -&gt; <a class="type" href="../type.Result.html" title="type tantivy::Result">Result</a>&lt;Box&lt;dyn <a class="trait" href="trait.Scorer.html" title="trait tantivy::query::Scorer">Scorer</a>&gt;&gt;</h4></section></summary><div class="docblock"><p>Returns the scorer for the given segment.</p>
<p><code>boost</code> is a multiplier to apply to the score.</p>
<p>See <a href="trait.Query.html"><code>Query</code></a>.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="tymethod.explain" class="method has-srclink"><a class="srclink rightside" href="../../src/tantivy/query/weight.rs.html#67">source</a><h4 class="code-header">fn <a href="#tymethod.explain" class="fnname">explain</a>(&amp;self, reader: &amp;<a class="struct" href="../struct.SegmentReader.html" title="struct tantivy::SegmentReader">SegmentReader</a>, doc: <a class="type" href="../type.DocId.html" title="type tantivy::DocId">DocId</a>) -&gt; <a class="type" href="../type.Result.html" title="type tantivy::Result">Result</a>&lt;<a class="struct" href="struct.Explanation.html" title="struct tantivy::query::Explanation">Explanation</a>&gt;</h4></section></summary><div class="docblock"><p>Returns an <a href="struct.Explanation.html" title="Explanation"><code>Explanation</code></a> for the given document.</p>
</div></details></div><h2 id="provided-methods" class="small-section-header">Provided Methods<a href="#provided-methods" class="anchor"></a></h2><div class="methods"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.count" class="method has-srclink"><a class="srclink rightside" href="../../src/tantivy/query/weight.rs.html#70-77">source</a><h4 class="code-header">fn <a href="#method.count" class="fnname">count</a>(&amp;self, reader: &amp;<a class="struct" href="../struct.SegmentReader.html" title="struct tantivy::SegmentReader">SegmentReader</a>) -&gt; <a class="type" href="../type.Result.html" title="type tantivy::Result">Result</a>&lt;u32&gt;</h4></section></summary><div class="docblock"><p>Returns the number documents within the given <a href="../struct.SegmentReader.html" title="SegmentReader"><code>SegmentReader</code></a>.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.for_each" class="method has-srclink"><a class="srclink rightside" href="../../src/tantivy/query/weight.rs.html#81-89">source</a><h4 class="code-header">fn <a href="#method.for_each" class="fnname">for_each</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self,<br>&nbsp;&nbsp;&nbsp;&nbsp;reader: &amp;<a class="struct" href="../struct.SegmentReader.html" title="struct tantivy::SegmentReader">SegmentReader</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;callback: &amp;mut dyn FnMut(<a class="type" href="../type.DocId.html" title="type tantivy::DocId">DocId</a>, <a class="type" href="../type.Score.html" title="type tantivy::Score">Score</a>)<br>) -&gt; <a class="type" href="../type.Result.html" title="type tantivy::Result">Result</a>&lt;()&gt;</h4></section></summary><div class="docblock"><p>Iterates through all of the document matched by the DocSet
<code>DocSet</code> and push the scored documents to the collector.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.for_each_no_score" class="method has-srclink"><a class="srclink rightside" href="../../src/tantivy/query/weight.rs.html#93-101">source</a><h4 class="code-header">fn <a href="#method.for_each_no_score" class="fnname">for_each_no_score</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self,<br>&nbsp;&nbsp;&nbsp;&nbsp;reader: &amp;<a class="struct" href="../struct.SegmentReader.html" title="struct tantivy::SegmentReader">SegmentReader</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;callback: &amp;mut dyn FnMut(<a class="type" href="../type.DocId.html" title="type tantivy::DocId">DocId</a>)<br>) -&gt; <a class="type" href="../type.Result.html" title="type tantivy::Result">Result</a>&lt;()&gt;</h4></section></summary><div class="docblock"><p>Iterates through all of the document matched by the DocSet
<code>DocSet</code> and push the scored documents to the collector.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.for_each_pruning" class="method has-srclink"><a class="srclink rightside" href="../../src/tantivy/query/weight.rs.html#113-122">source</a><h4 class="code-header">fn <a href="#method.for_each_pruning" class="fnname">for_each_pruning</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self,<br>&nbsp;&nbsp;&nbsp;&nbsp;threshold: <a class="type" href="../type.Score.html" title="type tantivy::Score">Score</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;reader: &amp;<a class="struct" href="../struct.SegmentReader.html" title="struct tantivy::SegmentReader">SegmentReader</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;callback: &amp;mut dyn FnMut(<a class="type" href="../type.DocId.html" title="type tantivy::DocId">DocId</a>, <a class="type" href="../type.Score.html" title="type tantivy::Score">Score</a>) -&gt; <a class="type" href="../type.Score.html" title="type tantivy::Score">Score</a><br>) -&gt; <a class="type" href="../type.Result.html" title="type tantivy::Result">Result</a>&lt;()&gt;</h4></section></summary><div class="docblock"><p>Calls <code>callback</code> with all of the <code>(doc, score)</code> for which score
is exceeding a given threshold.</p>
<p>This method is useful for the <a href="../collector/struct.TopDocs.html"><code>TopDocs</code></a> collector.
For all docsets, the blanket implementation has the benefit
of prefiltering (doc, score) pairs, avoiding the
virtual dispatch cost.</p>
<p>More importantly, it makes it possible for scorers to implement
important optimization (e.g. BlockWAND for union).</p>
</div></details></div><h2 id="implementors" class="small-section-header">Implementors<a href="#implementors" class="anchor"></a></h2><div id="implementors-list"><section id="impl-Weight-for-AllWeight" class="impl has-srclink"><a class="srclink rightside" href="../../src/tantivy/query/all_query.rs.html#23-38">source</a><a href="#impl-Weight-for-AllWeight" class="anchor"></a><h3 class="code-header">impl <a class="trait" href="trait.Weight.html" title="trait tantivy::query::Weight">Weight</a> for <a class="struct" href="struct.AllWeight.html" title="struct tantivy::query::AllWeight">AllWeight</a></h3></section><section id="impl-Weight-for-EmptyWeight" class="impl has-srclink"><a class="srclink rightside" href="../../src/tantivy/query/empty_query.rs.html#27-35">source</a><a href="#impl-Weight-for-EmptyWeight" class="anchor"></a><h3 class="code-header">impl <a class="trait" href="trait.Weight.html" title="trait tantivy::query::Weight">Weight</a> for <a class="struct" href="struct.EmptyWeight.html" title="struct tantivy::query::EmptyWeight">EmptyWeight</a></h3></section><section id="impl-Weight-for-AutomatonWeight%3CA%3E" class="impl has-srclink"><a class="srclink rightside" href="../../src/tantivy/query/automaton_weight.rs.html#42-83">source</a><a href="#impl-Weight-for-AutomatonWeight%3CA%3E" class="anchor"></a><h3 class="code-header">impl&lt;A&gt; <a class="trait" href="trait.Weight.html" title="trait tantivy::query::Weight">Weight</a> for <a class="struct" href="struct.AutomatonWeight.html" title="struct tantivy::query::AutomatonWeight">AutomatonWeight</a>&lt;A&gt;<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;A: <a class="trait" href="../../tantivy_fst/inner_automaton/trait.Automaton.html" title="trait tantivy_fst::inner_automaton::Automaton">Automaton</a> + Send + Sync + 'static,<br>&nbsp;&nbsp;&nbsp;&nbsp;A::<a class="associatedtype" href="../../tantivy_fst/inner_automaton/trait.Automaton.html#associatedtype.State" title="type tantivy_fst::inner_automaton::Automaton::State">State</a>: Clone,</span></h3></section></div><script src="../../implementors/tantivy/query/weight/trait.Weight.js" async></script></section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="tantivy" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.66.0-nightly (5c8bff74b 2022-10-21)" ></div></body></html>