Class: Weaviate::Query

Inherits:
Base
  • Object
show all
Defined in:
lib/weaviate/query.rb

Instance Attribute Summary

Attributes inherited from Base

#client

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Weaviate::Base

Instance Method Details

#aggs(class_name:, fields: nil, tenant: nil, where: nil, object_limit: nil, near_text: nil, near_vector: nil, near_image: nil, near_object: nil, group_by: nil) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/weaviate/query.rb', line 48

def aggs(
  class_name:,
  fields: nil,
  tenant: nil,
  where: nil,
  object_limit: nil,
  near_text: nil,
  near_vector: nil,
  near_image: nil,
  near_object: nil,
  group_by: nil
)
  response = client.graphql.execute(
    aggs_query(
      class_name: class_name,
      tenant: tenant,
      fields: fields,
      where: where,
      near_text: near_text,
      near_vector: near_vector,
      near_image: near_image,
      near_object: near_object
    ),
    group_by: group_by,
    object_limit: object_limit
  )
  response.original_hash.dig("data", "Aggregate", class_name)
rescue Graphlient::Errors::ExecutionError => error
  raise Weaviate::Error.new(error.response.data.aggregate.errors.messages.to_h)
end

#explore(fields:, after: nil, limit: nil, offset: nil, sort: nil, where: nil, near_text: nil, near_vector: nil, near_image: nil, near_object: nil) ⇒ Object



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/weaviate/query.rb', line 79

def explore(
  fields:,
  after: nil,
  limit: nil,
  offset: nil,
  sort: nil,
  where: nil,
  near_text: nil,
  near_vector: nil,
  near_image: nil,
  near_object: nil
)
  response = client.graphql.execute(
    explore_query(
      fields: fields,
      sort: sort,
      where: where,
      near_text: near_text,
      near_vector: near_vector,
      near_image: near_image,
      near_object: near_object
    ),
    after: after,
    limit: limit,
    offset: offset
  )
  response.original_hash.dig("data", "Explore")
rescue Graphlient::Errors::ExecutionError => error
  raise Weaviate::Error.new(error.to_s)
end

#get(class_name:, fields:, after: nil, tenant: nil, limit: nil, autocut: nil, offset: nil, sort: nil, where: nil, near_text: nil, near_vector: nil, near_image: nil, near_object: nil, with_hybrid: nil, bm25: nil, ask: nil) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/weaviate/query.rb', line 5

def get(
  class_name:,
  fields:,
  after: nil,
  tenant: nil,
  limit: nil,
  autocut: nil,
  offset: nil,
  sort: nil,
  where: nil,
  near_text: nil,
  near_vector: nil,
  near_image: nil,
  near_object: nil,
  with_hybrid: nil,
  bm25: nil,
  ask: nil
)
  response = client.graphql.execute(
    get_query(
      class_name: class_name,
      tenant: tenant,
      fields: fields,
      autocut: autocut,
      sort: sort,
      where: where,
      near_text: near_text,
      near_vector: near_vector,
      near_image: near_image,
      near_object: near_object,
      with_hybrid: with_hybrid,
      bm25: bm25,
      ask: ask
    ),
    after: after,
    limit: limit,
    offset: offset
  )
  response.original_hash.dig("data", "Get", class_name)
rescue Graphlient::Errors::ExecutionError => error
  raise Weaviate::Error.new(error.response.data.get.errors.messages.to_h)
end