Class: Weaviate::Query

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

Constant Summary collapse

ENUM_KEYS =

Fields whose values are GraphQL enums, so strings are sent unquoted, e.g. operator: "Equal"

%w[operator order fusionType].freeze
GRAPHQL_NAME =
/\A[_A-Za-z][_0-9A-Za-z]*\z/

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, limit: nil, with_hybrid: nil) ⇒ json

Parameters:

  • class_name: (String)
  • fields: (String, nil) (defaults to: nil)
  • tenant: (String, nil) (defaults to: nil)
  • where: (graphql_argument, nil) (defaults to: nil)
  • object_limit: (Integer, String, nil) (defaults to: nil)
  • near_text: (graphql_argument, nil) (defaults to: nil)
  • near_vector: (graphql_argument, nil) (defaults to: nil)
  • near_image: (graphql_argument, nil) (defaults to: nil)
  • near_object: (graphql_argument, nil) (defaults to: nil)
  • group_by: (Array[String], String, nil) (defaults to: nil)
  • limit: (Integer, String, nil) (defaults to: nil)
  • with_hybrid: (graphql_argument, nil) (defaults to: nil)

Returns:

  • (json)


55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/weaviate/query.rb', line 55

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,
  limit: nil,
  with_hybrid: nil
)
  data = client.graphql.execute(
    aggs_query(
      class_name: class_name,
      fields: fields,
      tenant: tenant,
      where: where,
      object_limit: object_limit,
      near_text: near_text,
      near_vector: near_vector,
      near_image: near_image,
      near_object: near_object,
      group_by: group_by,
      limit: limit,
      with_hybrid: with_hybrid
    )
  )
  data.dig("Aggregate", class_name)
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) ⇒ json

Deprecated.

Parameters:

  • fields: (String)
  • after: (String, nil) (defaults to: nil)
  • limit: (Integer, String, nil) (defaults to: nil)
  • offset: (Integer, String, nil) (defaults to: nil)
  • sort: (graphql_argument, nil) (defaults to: nil)
  • where: (graphql_argument, nil) (defaults to: nil)
  • near_text: (graphql_argument, nil) (defaults to: nil)
  • near_vector: (graphql_argument, nil) (defaults to: nil)
  • near_image: (graphql_argument, nil) (defaults to: nil)
  • near_object: (graphql_argument, nil) (defaults to: nil)

Returns:

  • (json)


89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/weaviate/query.rb', line 89

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
)
  unless @explore_deprecation_warned
    warn "[weaviate-ruby] query.explore is deprecated: Weaviate disables Explore when more than one vectorizer module is enabled, " \
      "which is the default on recent versions and on Weaviate Cloud. Use query.get on each collection instead."
    @explore_deprecation_warned = true
  end

  # `after` is accepted for backwards compatibility, but Explore does not support it
  data = client.graphql.execute(
    explore_query(
      fields: fields,
      limit: limit,
      offset: offset,
      sort: sort,
      where: where,
      near_text: near_text,
      near_vector: near_vector,
      near_image: near_image,
      near_object: near_object
    )
  )
  data["Explore"]
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, group_by: nil) ⇒ json

Parameters:

  • class_name: (String)
  • fields: (String)
  • after: (String, nil) (defaults to: nil)
  • tenant: (String, nil) (defaults to: nil)
  • limit: (Integer, String, nil) (defaults to: nil)
  • autocut: (Integer, String, nil) (defaults to: nil)
  • offset: (Integer, String, nil) (defaults to: nil)
  • sort: (graphql_argument, nil) (defaults to: nil)
  • where: (graphql_argument, nil) (defaults to: nil)
  • near_text: (graphql_argument, nil) (defaults to: nil)
  • near_vector: (graphql_argument, nil) (defaults to: nil)
  • near_image: (graphql_argument, nil) (defaults to: nil)
  • near_object: (graphql_argument, nil) (defaults to: nil)
  • with_hybrid: (graphql_argument, nil) (defaults to: nil)
  • bm25: (graphql_argument, nil) (defaults to: nil)
  • ask: (graphql_argument, nil) (defaults to: nil)
  • group_by: (graphql_argument, nil) (defaults to: nil)

Returns:

  • (json)


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
47
48
49
50
51
52
53
# File 'lib/weaviate/query.rb', line 12

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,
  group_by: nil
)
  data = client.graphql.execute(
    get_query(
      class_name: class_name,
      fields: fields,
      after: after,
      tenant: tenant,
      limit: limit,
      autocut: autocut,
      offset: offset,
      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,
      group_by: group_by
    )
  )
  data.dig("Get", class_name)
end