pub fn order_by_u64_field(
        self,
        field: Field,
    ) -> impl Collector<Fruit = Vec<(u64, DocAddress)>> {
        self.custom_score(ScorerByField { field })
    }
/// Set top-K to rank documents by a given fast field.
///
/// ```rust
/// # use tantivy::schema::{Schema, FAST, TEXT};
/// # use tantivy::{doc, Index, DocAddress};
/// # use tantivy::query::{Query, QueryParser};
/// use tantivy::Searcher;
/// use tantivy::collector::TopDocs;
/// use tantivy::schema::Field;
///
/// # fn main() -> tantivy::Result<()> {
/// #   let mut schema_builder = Schema::builder();
/// #   let title = schema_builder.add_text_field("title", TEXT);
/// #   let rating = schema_builder.add_u64_field("rating", FAST);
/// #   let schema = schema_builder.build();
/// #  
/// #   let index = Index::create_in_ram(schema);
/// #   let mut index_writer = index.writer_with_num_threads(1, 3_000_000)?;
/// #   index_writer.add_document(doc!(title => "The Name of the Wind", rating => 92u64));
/// #   index_writer.add_document(doc!(title => "The Diary of Muadib", rating => 97u64));
/// #   index_writer.add_document(doc!(title => "A Dairy Cow", rating => 63u64));
/// #   index_writer.add_document(doc!(title => "The Diary of a Young Girl", rating => 80u64));
/// #   assert!(index_writer.commit().is_ok());
/// #   let reader = index.reader().unwrap();
/// #   let query = QueryParser::for_index(&index, vec![title]).parse_query("diary")?;
/// #   let top_docs = docs_sorted_by_rating(&reader.searcher(), &query, rating)?;
/// #   assert_eq!(top_docs,
/// #            vec![(97u64, DocAddress(0u32, 1)),
/// #                 (80u64, DocAddress(0u32, 3))]);
/// #   Ok(())
/// # }
///
///
/// /// Searches the document matching the given query, and
/// /// collects the top 10 documents, order by the u64-`field`
/// /// given in argument.
/// ///
/// /// `field` is required to be a FAST field.
/// fn docs_sorted_by_rating(searcher: &Searcher,
///                          query: &dyn Query,
///                          sort_by_field: Field)
///     -> tantivy::Result<Vec<(u64, DocAddress)>> {
///
///     // This is where we build our topdocs collector
///     //
///     // Note the generics parameter that needs to match the
///     // type `sort_by_field`.
///     let top_docs_by_rating = TopDocs
///                 ::with_limit(10)
///                  .order_by_u64_field(sort_by_field);
///     
///     // ... and here are our documents. Note this is a simple vec.
///     // The `u64` in the pair is the value of our fast field for
///     // each documents.
///     //
///     // The vec is sorted decreasingly by `sort_by_field`, and has a
///     // length of 10, or less if not enough documents matched the
///     // query.
///     let resulting_docs: Vec<(u64, DocAddress)> =
///          searcher.search(query, &top_docs_by_rating)?;
///     
///     Ok(resulting_docs)
/// }
/// ```
///
/// # Panics
///
/// May panic if the field requested is not a fast field.
///
Set top-K to rank documents by a given fast field.
Set top - K to rank documents by a given fast field .
pub fn order_by_u64_field(
        self,
        field: Field,
    ) -> impl Collector<Fruit = Vec<(u64, DocAddress)>> {
        self.custom_score(ScorerByField { field })
    }
pub fn order_by_u64_field ( self , field : Field , ) -> impl Collector < Fruit = Vec < ( u64 , DocAddress ) > > { self . custom_score ( ScorerByField { field } ) }
Set top-K to rank documents by a given fast field.
Set top - K to rank documents by a given fast field .
self
field
Field
self
field
Field
use tantivy::schema::{schema, fast, text};
None
use tantivy::{doc, index, docaddress};
None
use tantivy::query::{query, queryparser};
use tantivy::Searcher;
use tantivy::collector::TopDocs;
use tantivy::schema::Field.
use tantivy :: Searcher ; use tantivy :: collector :: TopDocs ; use tantivy :: schema :: Field .
fn main() -> tantivy::result<()> {
None
let mut schema_builder = schema::builder();
None
let title = schema_builder.add_text_field("title", text);
None
let rating = schema_builder.add_u64_field("rating", fast);
None
let schema = schema_builder.build();
None
None
let index = index::create_in_ram(schema);
None
let mut index_writer = index.writer_with_num_threads(1, 3_000_000)?;
None
index_writer.add_document(doc!(title => "the name of the wind", rating => 92u64));
None
index_writer.add_document(doc!(title => "the diary of muadib", rating => 97u64));
None
index_writer.add_document(doc!(title => "a dairy cow", rating => 63u64));
None
index_writer.add_document(doc!(title => "the diary of a young girl", rating => 80u64));
None
assert!(index_writer.commit().is_ok());
None
let reader = index.reader().unwrap();
None
let query = queryparser::for_index(&index, vec![title]).parse_query("diary")?;
None
let top_docs = docs_sorted_by_rating(&reader.searcher(), &query, rating)?;
None
assert_eq!(top_docs,
None
vec![(97u64, docaddress(0u32, 1)),
None
(80u64, docaddress(0u32, 3))]);
None
ok(())
None
}
Searches the document matching the given query, and
collects the top 10 documents, order by the u64-`field`
given in argument.

`field` is required to be a FAST field.
fn docs_sorted_by_rating(searcher: &Searcher,
query: &dyn Query,
sort_by_field: Field)
> tantivy::Result> {

This is where we build our topdocs collector

Note the generics parameter that needs to match the
type `sort_by_field`.
let top_docs_by_rating = TopDocs
::with_limit(10)
.order_by_u64_field(sort_by_field).

and here are our documents. Note this is a simple vec.
The `u64` in the pair is the value of our fast field for
each documents.

The vec is sorted decreasingly by `sort_by_field`, and has a
length of 10, or less if not enough documents matched the
query.
let resulting_docs: Vec<(u64, DocAddress)>
searcher.search(query, ⊤_docs_by_rating)?.

Ok(resulting_docs)
}
```
Searches the document matching the given query and collects the top 10 documents order by the u64 - ` field ` given in argument . ` field ` is required to be a FAST field . fn docs_sorted_by_rating ( searcher : &Searcher query : &dyn Query sort_by_field : Field ) > tantivy :: Result > { This is where we build our topdocs collector Note the generics parameter that needs to match the type ` sort_by_field ` . let top_docs_by_rating = TopDocs :: with_limit ( 10 ) . order_by_u64_field ( sort_by_field ) . and here are our documents . Note this is a simple vec . The ` u64 ` in the pair is the value of our fast field for each documents . The vec is sorted decreasingly by ` sort_by_field ` and has a length of 10 or less if not enough documents matched the query . let resulting_docs : Vec< ( u64 DocAddress ) > searcher . search ( query ⊤_docs_by_rating ) ? . Ok ( resulting_docs ) } ` ` `
panics
May panic if the field requested is not a fast field.
May panic if the field requested is not a fast field .