@@ -59,12 +59,12 @@ fn main() -> tantivy::Result<()> {
5959 let query_parser = QueryParser :: for_index ( & index, vec ! [ event_type, attributes] ) ;
6060 {
6161 let query = query_parser. parse_query ( "target:submit-button" ) ?;
62- let count_docs = searcher. search ( & * query, & TopDocs :: with_limit ( 2 ) ) ?;
62+ let count_docs = searcher. search ( & * query, & TopDocs :: with_limit ( 2 ) . order_by_score ( ) ) ?;
6363 assert_eq ! ( count_docs. len( ) , 2 ) ;
6464 }
6565 {
6666 let query = query_parser. parse_query ( "target:submit" ) ?;
67- let count_docs = searcher. search ( & * query, & TopDocs :: with_limit ( 2 ) ) ?;
67+ let count_docs = searcher. search ( & * query, & TopDocs :: with_limit ( 2 ) . order_by_score ( ) ) ?;
6868 assert_eq ! ( count_docs. len( ) , 2 ) ;
6969 }
7070 {
@@ -74,33 +74,33 @@ fn main() -> tantivy::Result<()> {
7474 }
7575 {
7676 let query = query_parser. parse_query ( "click AND cart.product_id:133" ) ?;
77- let hits = searcher. search ( & * query, & TopDocs :: with_limit ( 2 ) ) ?;
77+ let hits = searcher. search ( & * query, & TopDocs :: with_limit ( 2 ) . order_by_score ( ) ) ?;
7878 assert_eq ! ( hits. len( ) , 1 ) ;
7979 }
8080 {
8181 // The sub-fields in the json field marked as default field still need to be explicitly
8282 // addressed
8383 let query = query_parser. parse_query ( "click AND 133" ) ?;
84- let hits = searcher. search ( & * query, & TopDocs :: with_limit ( 2 ) ) ?;
84+ let hits = searcher. search ( & * query, & TopDocs :: with_limit ( 2 ) . order_by_score ( ) ) ?;
8585 assert_eq ! ( hits. len( ) , 0 ) ;
8686 }
8787 {
8888 // Default json fields are ignored if they collide with the schema
8989 let query = query_parser. parse_query ( "event_type:holiday-sale" ) ?;
90- let hits = searcher. search ( & * query, & TopDocs :: with_limit ( 2 ) ) ?;
90+ let hits = searcher. search ( & * query, & TopDocs :: with_limit ( 2 ) . order_by_score ( ) ) ?;
9191 assert_eq ! ( hits. len( ) , 0 ) ;
9292 }
9393 // # Query via full attribute path
9494 {
9595 // This only searches in our schema's `event_type` field
9696 let query = query_parser. parse_query ( "event_type:click" ) ?;
97- let hits = searcher. search ( & * query, & TopDocs :: with_limit ( 2 ) ) ?;
97+ let hits = searcher. search ( & * query, & TopDocs :: with_limit ( 2 ) . order_by_score ( ) ) ?;
9898 assert_eq ! ( hits. len( ) , 2 ) ;
9999 }
100100 {
101101 // Default json fields can still be accessed by full path
102102 let query = query_parser. parse_query ( "attributes.event_type:holiday-sale" ) ?;
103- let hits = searcher. search ( & * query, & TopDocs :: with_limit ( 2 ) ) ?;
103+ let hits = searcher. search ( & * query, & TopDocs :: with_limit ( 2 ) . order_by_score ( ) ) ?;
104104 assert_eq ! ( hits. len( ) , 1 ) ;
105105 }
106106 Ok ( ( ) )
0 commit comments