Module: WeaviateRecord::Relation::QueryBuilder

Included in:
WeaviateRecord::Relation
Defined in:
lib/weaviate_record/relation/query_builder.rb

Overview

This module contains methods which helps to build query for Weaviate

Instance Method Summary collapse

Instance Method Details

#to_queryObject

This will return the query that will be sent to Weaviate. More like to_sql in ActiveRecord.

Example:

Article.select(:title, :content).near_text('friendship movie').limit(5).offset(2).to_query

Returns:

{:class_name=>"Article",
 :limit=>"5",
 :offset=>"2",
 :fields=>"title content",
 :near_text=>"{ concepts: [\"friendship movie\"], distance: 0.55 }"}


17
18
19
20
21
22
23
24
25
26
# File 'lib/weaviate_record/relation/query_builder.rb', line 17

def to_query
  query_params = basic_params
  fill_up_keyword_search_param(query_params)
  fill_up_similarity_search_param(query_params)
  fill_up_conditions_param(query_params)
  fill_up_sort_param(query_params)
  fill_up_question_param(query_params)

  query_params
end