Class: ParadeDB::SearchMethods::FacetQuery

Inherits:
Object
  • Object
show all
Defined in:
lib/parade_db/search_methods.rb

Overview

---- Facet Query helper ----

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(relation:, primary_key:, builder:, fields:, size:, order:, missing:, agg:, exact:, connection:) ⇒ FacetQuery

Returns a new instance of FacetQuery.



863
864
865
866
867
868
869
870
871
872
873
874
875
876
# File 'lib/parade_db/search_methods.rb', line 863

def initialize(relation:, primary_key:, builder:, fields:, size:, order:, missing:, agg:, exact:, connection:)
  @connection = connection
  @relation = build_relation(
    relation: relation,
    primary_key: primary_key,
    builder: builder,
    fields: fields,
    size: size,
    order: order,
    missing: missing,
    agg: agg,
    exact: exact
  )
end

Instance Attribute Details

#connectionObject (readonly)

Returns the value of attribute connection.



846
847
848
# File 'lib/parade_db/search_methods.rb', line 846

def connection
  @connection
end

#relationObject (readonly)

Returns the value of attribute relation.



846
847
848
# File 'lib/parade_db/search_methods.rb', line 846

def relation
  @relation
end

Class Method Details

.build(relation:, primary_key:, builder:, fields:, size:, order:, missing:, agg:, exact:, connection:) ⇒ Object



848
849
850
851
852
853
854
855
856
857
858
859
860
861
# File 'lib/parade_db/search_methods.rb', line 848

def self.build(relation:, primary_key:, builder:, fields:, size:, order:, missing:, agg:, exact:, connection:)
  new(
    relation: relation,
    primary_key: primary_key,
    builder: builder,
    fields: fields,
    size: size,
    order: order,
    missing: missing,
    agg: agg,
    exact: exact,
    connection: connection
  )
end

Instance Method Details

#executeObject



882
883
884
# File 'lib/parade_db/search_methods.rb', line 882

def execute
  parse_facets(connection.select_one(sql))
end

#sqlObject



878
879
880
# File 'lib/parade_db/search_methods.rb', line 878

def sql
  relation.to_sql
end