Module: WeaviateRecord::Queries::Order

Included in:
Relation
Defined in:
lib/weaviate_record/queries/order.rb

Overview

This module contains function to sort Weaviate records

Instance Method Summary collapse

Instance Method Details

#order(*args, **kw_args) ⇒ Object

Sort the records based on the given attributes. You can pass multiple attributes to sort the records. This sorting specification will be ignored if you are performing bm25 search.

Example:

Article.order(:title)
# Sorts the records based on title in ascending order

Article.order(:title, created_at: :desc)
# Sorts the records based on title in ascending order and created_at in descending order

Raises:

  • (ArgumentError)


17
18
19
20
21
22
23
24
# File 'lib/weaviate_record/queries/order.rb', line 17

def order(*args, **kw_args)
  raise ArgumentError, 'expected at least one argument' if args.empty? && kw_args.empty?

  sorting_specifiers = combine_arguments(args, kw_args)
  assign_sort_options(sorting_specifiers)
  @loaded = false
  self
end