stretchy-model 0.6.0 → 0.6.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (191) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +2 -1
  3. data/README.md +28 -10
  4. data/Rakefile +56 -0
  5. data/containers/Dockerfile.opensearch +4 -3
  6. data/docker-compose.yml +32 -19
  7. data/docs/.nojekyll +0 -0
  8. data/docs/README.md +147 -0
  9. data/docs/_coverpage.md +14 -0
  10. data/docs/_sidebar.md +14 -0
  11. data/docs/examples/_sidebar.md +15 -0
  12. data/docs/examples/data_analysis.md +216 -0
  13. data/docs/examples/semantic_search_with_llm.md +83 -0
  14. data/docs/examples/simple-ingest-pipeline.md +326 -0
  15. data/docs/guides/_sidebar.md +14 -0
  16. data/docs/guides/aggregations.md +142 -0
  17. data/docs/guides/machine-learning.md +154 -0
  18. data/docs/guides/models.md +372 -0
  19. data/docs/guides/pipelines.md +151 -0
  20. data/docs/guides/querying.md +361 -0
  21. data/docs/guides/quick-start.md +72 -0
  22. data/docs/guides/scopes.md +125 -0
  23. data/docs/index.html +113 -0
  24. data/docs/stretchy.cover.png +0 -0
  25. data/docs/stretchy.logo.png +0 -0
  26. data/docs/styles.css +90 -0
  27. data/lib/elasticsearch/api/actions/machine_learning/models/delete_model.rb +33 -0
  28. data/lib/elasticsearch/api/actions/machine_learning/models/deploy.rb +31 -0
  29. data/lib/elasticsearch/api/actions/machine_learning/models/get_model.rb +43 -0
  30. data/lib/elasticsearch/api/actions/machine_learning/models/get_status.rb +31 -0
  31. data/lib/elasticsearch/api/actions/machine_learning/models/params_registry.rb +45 -0
  32. data/lib/elasticsearch/api/actions/machine_learning/models/register.rb +45 -0
  33. data/lib/elasticsearch/api/actions/machine_learning/models/undeploy.rb +32 -0
  34. data/lib/elasticsearch/api/actions/machine_learning/models/update_model.rb +39 -0
  35. data/lib/elasticsearch/api/namespace/machine_learning/model.rb +27 -0
  36. data/lib/opensearch/api/actions/machine_learning/models/delete_model.rb +33 -0
  37. data/lib/opensearch/api/actions/machine_learning/models/deploy.rb +31 -0
  38. data/lib/opensearch/api/actions/machine_learning/models/get_model.rb +44 -0
  39. data/lib/opensearch/api/actions/machine_learning/models/get_status.rb +31 -0
  40. data/lib/opensearch/api/actions/machine_learning/models/params_registry.rb +45 -0
  41. data/lib/opensearch/api/actions/machine_learning/models/register.rb +45 -0
  42. data/lib/opensearch/api/actions/machine_learning/models/undeploy.rb +31 -0
  43. data/lib/opensearch/api/actions/machine_learning/models/update_model.rb +39 -0
  44. data/lib/opensearch/api/namespace/machine_learning/model.rb +27 -0
  45. data/lib/stretchy/attributes/transformers/keyword_transformer.rb +41 -35
  46. data/lib/stretchy/attributes/type/array.rb +24 -1
  47. data/lib/stretchy/attributes/type/base.rb +6 -2
  48. data/lib/stretchy/attributes/type/binary.rb +24 -17
  49. data/lib/stretchy/attributes/type/boolean.rb +29 -22
  50. data/lib/stretchy/attributes/type/completion.rb +18 -10
  51. data/lib/stretchy/attributes/type/constant_keyword.rb +35 -26
  52. data/lib/stretchy/attributes/type/date_time.rb +81 -20
  53. data/lib/stretchy/attributes/type/dense_vector.rb +46 -49
  54. data/lib/stretchy/attributes/type/flattened.rb +28 -19
  55. data/lib/stretchy/attributes/type/geo_point.rb +21 -12
  56. data/lib/stretchy/attributes/type/geo_shape.rb +21 -12
  57. data/lib/stretchy/attributes/type/hash.rb +24 -10
  58. data/lib/stretchy/attributes/type/histogram.rb +25 -0
  59. data/lib/stretchy/attributes/type/ip.rb +26 -17
  60. data/lib/stretchy/attributes/type/join.rb +16 -7
  61. data/lib/stretchy/attributes/type/keyword.rb +21 -26
  62. data/lib/stretchy/attributes/type/knn_vector.rb +47 -0
  63. data/lib/stretchy/attributes/type/match_only_text.rb +22 -1
  64. data/lib/stretchy/attributes/type/nested.rb +16 -11
  65. data/lib/stretchy/attributes/type/numeric/base.rb +30 -22
  66. data/lib/stretchy/attributes/type/numeric/byte.rb +20 -0
  67. data/lib/stretchy/attributes/type/numeric/double.rb +20 -0
  68. data/lib/stretchy/attributes/type/numeric/float.rb +20 -0
  69. data/lib/stretchy/attributes/type/numeric/half_float.rb +20 -0
  70. data/lib/stretchy/attributes/type/numeric/integer.rb +21 -1
  71. data/lib/stretchy/attributes/type/numeric/long.rb +20 -0
  72. data/lib/stretchy/attributes/type/numeric/scaled_float.rb +16 -7
  73. data/lib/stretchy/attributes/type/numeric/short.rb +20 -0
  74. data/lib/stretchy/attributes/type/numeric/unsigned_long.rb +21 -1
  75. data/lib/stretchy/attributes/type/percolator.rb +16 -4
  76. data/lib/stretchy/attributes/type/point.rb +19 -9
  77. data/lib/stretchy/attributes/type/range/base.rb +24 -1
  78. data/lib/stretchy/attributes/type/range/date_range.rb +21 -5
  79. data/lib/stretchy/attributes/type/range/double_range.rb +20 -4
  80. data/lib/stretchy/attributes/type/range/float_range.rb +21 -5
  81. data/lib/stretchy/attributes/type/range/integer_range.rb +20 -4
  82. data/lib/stretchy/attributes/type/range/ip_range.rb +20 -4
  83. data/lib/stretchy/attributes/type/range/long_range.rb +20 -4
  84. data/lib/stretchy/attributes/type/rank_feature.rb +16 -6
  85. data/lib/stretchy/attributes/type/rank_features.rb +27 -10
  86. data/lib/stretchy/attributes/type/search_as_you_type.rb +28 -18
  87. data/lib/stretchy/attributes/type/shape.rb +19 -9
  88. data/lib/stretchy/attributes/type/sparse_vector.rb +25 -21
  89. data/lib/stretchy/attributes/type/string.rb +42 -1
  90. data/lib/stretchy/attributes/type/text.rb +53 -28
  91. data/lib/stretchy/attributes/type/token_count.rb +21 -11
  92. data/lib/stretchy/attributes/type/version.rb +16 -6
  93. data/lib/stretchy/attributes/type/wildcard.rb +36 -25
  94. data/lib/stretchy/attributes.rb +30 -0
  95. data/lib/stretchy/delegation/gateway_delegation.rb +86 -2
  96. data/lib/stretchy/index_setting.rb +94 -0
  97. data/lib/stretchy/indexing/bulk.rb +75 -3
  98. data/lib/stretchy/machine_learning/model.rb +192 -0
  99. data/lib/stretchy/model/callbacks.rb +1 -0
  100. data/lib/stretchy/model/common.rb +157 -0
  101. data/lib/stretchy/model/persistence.rb +144 -0
  102. data/lib/stretchy/model/refreshable.rb +26 -0
  103. data/lib/stretchy/open_search_compatibility.rb +4 -0
  104. data/lib/stretchy/pipeline.rb +124 -0
  105. data/lib/stretchy/pipelines/processor.rb +57 -0
  106. data/lib/stretchy/querying.rb +7 -7
  107. data/lib/stretchy/rails/instrumentation/publishers.rb +31 -0
  108. data/lib/{rails → stretchy/rails}/instrumentation/railtie.rb +11 -6
  109. data/lib/stretchy/record.rb +5 -4
  110. data/lib/stretchy/relation.rb +230 -28
  111. data/lib/stretchy/relations/aggregation_methods/aggregation.rb +59 -0
  112. data/lib/stretchy/relations/aggregation_methods/avg.rb +45 -0
  113. data/lib/stretchy/relations/aggregation_methods/bucket_script.rb +47 -0
  114. data/lib/stretchy/relations/aggregation_methods/bucket_selector.rb +47 -0
  115. data/lib/stretchy/relations/aggregation_methods/bucket_sort.rb +47 -0
  116. data/lib/stretchy/relations/aggregation_methods/cardinality.rb +47 -0
  117. data/lib/stretchy/relations/aggregation_methods/children.rb +47 -0
  118. data/lib/stretchy/relations/aggregation_methods/composite.rb +41 -0
  119. data/lib/stretchy/relations/aggregation_methods/date_histogram.rb +53 -0
  120. data/lib/stretchy/relations/aggregation_methods/date_range.rb +53 -0
  121. data/lib/stretchy/relations/aggregation_methods/extended_stats.rb +48 -0
  122. data/lib/stretchy/relations/aggregation_methods/filter.rb +47 -0
  123. data/lib/stretchy/relations/aggregation_methods/filters.rb +47 -0
  124. data/lib/stretchy/relations/aggregation_methods/geo_bounds.rb +40 -0
  125. data/lib/stretchy/relations/aggregation_methods/geo_centroid.rb +40 -0
  126. data/lib/stretchy/relations/aggregation_methods/global.rb +39 -0
  127. data/lib/stretchy/relations/aggregation_methods/histogram.rb +43 -0
  128. data/lib/stretchy/relations/aggregation_methods/ip_range.rb +41 -0
  129. data/lib/stretchy/relations/aggregation_methods/max.rb +40 -0
  130. data/lib/stretchy/relations/aggregation_methods/min.rb +41 -0
  131. data/lib/stretchy/relations/aggregation_methods/missing.rb +40 -0
  132. data/lib/stretchy/relations/aggregation_methods/nested.rb +40 -0
  133. data/lib/stretchy/relations/aggregation_methods/percentile_ranks.rb +45 -0
  134. data/lib/stretchy/relations/aggregation_methods/percentiles.rb +45 -0
  135. data/lib/stretchy/relations/aggregation_methods/range.rb +42 -0
  136. data/lib/stretchy/relations/aggregation_methods/reverse_nested.rb +40 -0
  137. data/lib/stretchy/relations/aggregation_methods/sampler.rb +40 -0
  138. data/lib/stretchy/relations/aggregation_methods/scripted_metric.rb +43 -0
  139. data/lib/stretchy/relations/aggregation_methods/significant_terms.rb +45 -0
  140. data/lib/stretchy/relations/aggregation_methods/stats.rb +42 -0
  141. data/lib/stretchy/relations/aggregation_methods/sum.rb +42 -0
  142. data/lib/stretchy/relations/aggregation_methods/terms.rb +46 -0
  143. data/lib/stretchy/relations/aggregation_methods/top_hits.rb +42 -0
  144. data/lib/stretchy/relations/aggregation_methods/top_metrics.rb +44 -0
  145. data/lib/stretchy/relations/aggregation_methods/value_count.rb +41 -0
  146. data/lib/stretchy/relations/aggregation_methods/weighted_avg.rb +42 -0
  147. data/lib/stretchy/relations/aggregation_methods.rb +20 -749
  148. data/lib/stretchy/relations/finder_methods.rb +2 -18
  149. data/lib/stretchy/relations/null_relation.rb +55 -0
  150. data/lib/stretchy/relations/query_builder.rb +139 -23
  151. data/lib/stretchy/relations/query_methods/bind.rb +19 -0
  152. data/lib/stretchy/relations/query_methods/extending.rb +29 -0
  153. data/lib/stretchy/relations/query_methods/fields.rb +70 -0
  154. data/lib/stretchy/relations/query_methods/filter_query.rb +53 -0
  155. data/lib/stretchy/relations/query_methods/has_field.rb +40 -0
  156. data/lib/stretchy/relations/query_methods/highlight.rb +75 -0
  157. data/lib/stretchy/relations/query_methods/hybrid.rb +60 -0
  158. data/lib/stretchy/relations/query_methods/ids.rb +40 -0
  159. data/lib/stretchy/relations/query_methods/match.rb +52 -0
  160. data/lib/stretchy/relations/query_methods/must_not.rb +54 -0
  161. data/lib/stretchy/relations/query_methods/neural.rb +58 -0
  162. data/lib/stretchy/relations/query_methods/neural_sparse.rb +43 -0
  163. data/lib/stretchy/relations/query_methods/none.rb +21 -0
  164. data/lib/stretchy/relations/query_methods/or_filter.rb +21 -0
  165. data/lib/stretchy/relations/query_methods/order.rb +63 -0
  166. data/lib/stretchy/relations/query_methods/query_string.rb +44 -0
  167. data/lib/stretchy/relations/query_methods/regexp.rb +61 -0
  168. data/lib/stretchy/relations/query_methods/should.rb +51 -0
  169. data/lib/stretchy/relations/query_methods/size.rb +44 -0
  170. data/lib/stretchy/relations/query_methods/skip_callbacks.rb +47 -0
  171. data/lib/stretchy/relations/query_methods/source.rb +59 -0
  172. data/lib/stretchy/relations/query_methods/where.rb +113 -0
  173. data/lib/stretchy/relations/query_methods.rb +51 -540
  174. data/lib/stretchy/relations/scoping/default.rb +136 -0
  175. data/lib/stretchy/relations/scoping/named.rb +70 -0
  176. data/lib/stretchy/relations/scoping/scope_registry.rb +36 -0
  177. data/lib/stretchy/relations/scoping.rb +30 -0
  178. data/lib/stretchy/relations/search_option_methods.rb +2 -0
  179. data/lib/stretchy/shared_scopes.rb +6 -1
  180. data/lib/stretchy/version.rb +1 -1
  181. data/lib/stretchy.rb +23 -11
  182. metadata +147 -18
  183. data/lib/rails/instrumentation/publishers.rb +0 -29
  184. data/lib/stretchy/common.rb +0 -33
  185. data/lib/stretchy/null_relation.rb +0 -53
  186. data/lib/stretchy/persistence.rb +0 -43
  187. data/lib/stretchy/refreshable.rb +0 -15
  188. data/lib/stretchy/scoping/default.rb +0 -134
  189. data/lib/stretchy/scoping/named.rb +0 -68
  190. data/lib/stretchy/scoping/scope_registry.rb +0 -34
  191. data/lib/stretchy/scoping.rb +0 -28
@@ -1,29 +1,37 @@
1
1
  module Stretchy::Attributes::Type::Numeric
2
- # Public: Defines a numeric attribute for the model. This is a base class for numeric types.
3
- #
4
- # opts - The Hash options used to refine the attribute (default: {}):
5
- # :coerce - The Boolean indicating if strings should be converted to numbers and fractions truncated for integers. Defaults to true.
6
- # :doc_values - The Boolean indicating if the field should be stored on disk in a column-stride fashion. Defaults to true.
7
- # :ignore_malformed - The Boolean indicating if malformed numbers should be ignored. Defaults to false.
8
- # :index - The Boolean indicating if the field should be quickly searchable. Defaults to true.
9
- # :meta - The Hash metadata about the field.
10
- # :null_value - The Numeric value to be substituted for any explicit null values. Defaults to null.
11
- # :on_script_error - The String defining what to do if the script defined by the :script parameter throws an error at indexing time. Can be 'fail' or 'continue'.
12
- # :script - The String script that will index values generated by this script, rather than reading the values directly from the source.
13
- # :store - The Boolean indicating if the field value should be stored and retrievable separately from the _source field. Defaults to false.
14
- # :time_series_dimension - The Boolean indicating if the field is a time series dimension. Defaults to false.
15
- # :time_series_metric - The String indicating if the field is a time series metric. Can be 'counter', 'gauge', or 'null'.
16
- #
17
- # Examples
18
- #
19
- # class MyModel
20
- # include StretchyModel
2
+ # The Base class for numeric attribute types
3
+ #
4
+ # This class is used to define a base for numeric attribute types for a model. It provides support for the Elasticsearch numeric data types, which are types of data that can hold numeric values.
5
+ #
6
+ # ### Parameters
7
+ #
8
+ # - `options:` The Hash of options for the attribute.
9
+ # - `:coerce:` The Boolean indicating if strings should be converted to numbers and fractions truncated for integers. Defaults to true.
10
+ # - `:doc_values:` The Boolean indicating if the field should be stored on disk in a column-stride fashion. Defaults to true.
11
+ # - `:ignore_malformed:` The Boolean indicating if malformed numbers should be ignored. Defaults to false.
12
+ # - `:index:` The Boolean indicating if the field should be quickly searchable. Defaults to true.
13
+ # - `:meta:` The Hash metadata about the field.
14
+ # - `:null_value:` The Numeric value to be substituted for any explicit null values. Defaults to null.
15
+ # - `:on_script_error:` The String defining what to do if the script defined by the :script parameter throws an error at indexing time. Can be 'fail' or 'continue'.
16
+ # - `:script:` The String script that will index values generated by this script, rather than reading the values directly from the source.
17
+ # - `:store:` The Boolean indicating if the field value should be stored and retrievable separately from the _source field. Defaults to false.
18
+ # - `:time_series_dimension:` The Boolean indicating if the field is a time series dimension. Defaults to false.
19
+ # - `:time_series_metric:` The String indicating if the field is a time series metric. Can be 'counter', 'gauge', or 'null'.
20
+ #
21
+ # ---
22
+ #
23
+ # ### Examples
24
+ #
25
+ # #### Define a numeric attribute
26
+ #
27
+ # ```ruby
28
+ # class MyModel < Stretchy::Record
21
29
  # attribute :age, :integer, coerce: false, time_series_dimension: true
22
30
  # end
31
+ # ```
23
32
  #
24
- # Returns nothing.
25
- class Base < Stretchy::Attributes::Type::Base
26
- OPTIONS = [:coerce, :doc_values, :ignore_malformed, :index, :meta, :null_value, :on_script_error, :script, :store, :time_series_dimension, :time_series_metric]
33
+ class Base < Stretchy::Attributes::Type::Base #:nodoc:
34
+ OPTIONS = [:coerce, :doc_values, :ignore_malformed, :index, :meta, :null_value, :on_script_error, :script, :store, :time_series_dimension, :time_series_metric] + self.superclass::OPTIONS
27
35
 
28
36
  def type
29
37
  raise NotImplementedError, "You must use one of the numeric types: integer, long, short, byte, double, float, half_float, scaled_float."
@@ -1,4 +1,24 @@
1
1
  module Stretchy::Attributes::Type::Numeric
2
+ # The Byte attribute type
3
+ #
4
+ # This class is used to define a byte attribute for a model. It provides support for the Elasticsearch numeric data type, which is a type of data type that can hold byte values.
5
+ #
6
+ # ### Parameters
7
+ #
8
+ # - `type:` `:byte`.
9
+ #
10
+ # ---
11
+ #
12
+ # ### Examples
13
+ #
14
+ # #### Define a byte attribute
15
+ #
16
+ # ```ruby
17
+ # class MyModel < StretchyModel
18
+ # attribute :data, :byte
19
+ # end
20
+ # ```
21
+ #
2
22
  class Byte < Base
3
23
  def type
4
24
  :byte
@@ -1,4 +1,24 @@
1
1
  module Stretchy::Attributes::Type::Numeric
2
+ # The Double attribute type
3
+ #
4
+ # This class is used to define a double attribute for a model. It provides support for the Elasticsearch numeric data type, which is a type of data type that can hold double-precision 64-bit IEEE 754 floating point values.
5
+ #
6
+ # ### Parameters
7
+ #
8
+ # - `type:` `:double`.
9
+ #
10
+ # ---
11
+ #
12
+ # ### Examples
13
+ #
14
+ # #### Define a double attribute
15
+ #
16
+ # ```ruby
17
+ # class MyModel < StretchyModel
18
+ # attribute :rating, :double
19
+ # end
20
+ # ```
21
+ #
2
22
  class Double < Base
3
23
  def type
4
24
  :double
@@ -1,4 +1,24 @@
1
1
  module Stretchy::Attributes::Type::Numeric
2
+ # The Float attribute type
3
+ #
4
+ # This class is used to define a float attribute for a model. It provides support for the Elasticsearch numeric data type, which is a type of data type that can hold single-precision 32-bit IEEE 754 floating point values.
5
+ #
6
+ # ### Parameters
7
+ #
8
+ # - `type:` `:float`.
9
+ #
10
+ # ---
11
+ #
12
+ # ### Examples
13
+ #
14
+ # #### Define a float attribute
15
+ #
16
+ # ```ruby
17
+ # class MyModel < StretchyModel
18
+ # attribute :rating, :float
19
+ # end
20
+ # ```
21
+ #
2
22
  class Float < Base
3
23
  def type
4
24
  :float
@@ -1,4 +1,24 @@
1
1
  module Stretchy::Attributes::Type::Numeric
2
+ # The HalfFloat attribute type
3
+ #
4
+ # This class is used to define a half_float attribute for a model. It provides support for the Elasticsearch numeric data type, which is a type of data type that can hold half-precision 16-bit IEEE 754 floating point values.
5
+ #
6
+ # ### Parameters
7
+ #
8
+ # - `type:` `:half_float`.
9
+ #
10
+ # ---
11
+ #
12
+ # ### Examples
13
+ #
14
+ # #### Define a half_float attribute
15
+ #
16
+ # ```ruby
17
+ # class MyModel < StretchyModel
18
+ # attribute :rating, :half_float
19
+ # end
20
+ # ```
21
+ #
2
22
  class HalfFloat < Base
3
23
  def type
4
24
  :half_float
@@ -1,5 +1,25 @@
1
1
  module Stretchy::Attributes::Type::Numeric
2
- class Integer < Stretchy::Attributes::Type::Base # :nodoc:
2
+ # The HalfFloat attribute type
3
+ #
4
+ # This class is used to define a half_float attribute for a model. It provides support for the Elasticsearch numeric data type, which is a type of data type that can hold half-precision 16-bit IEEE 754 floating point values.
5
+ #
6
+ # ### Parameters
7
+ #
8
+ # - `type:` `:half_float`.
9
+ #
10
+ # ---
11
+ #
12
+ # ### Examples
13
+ #
14
+ # #### Define a half_float attribute
15
+ #
16
+ # ```ruby
17
+ # class MyModel < StretchyModel
18
+ # attribute :rating, :half_float
19
+ # end
20
+ # ```
21
+ #
22
+ class Integer < Base
3
23
  def type
4
24
  :integer
5
25
  end
@@ -1,4 +1,24 @@
1
1
  module Stretchy::Attributes::Type::Numeric
2
+ # The Long attribute type
3
+ #
4
+ # This class is used to define a long attribute for a model. It provides support for the Elasticsearch numeric data type, which is a type of data type that can hold long integer values.
5
+ #
6
+ # ### Parameters
7
+ #
8
+ # - `type:` `:long`.
9
+ #
10
+ # ---
11
+ #
12
+ # ### Examples
13
+ #
14
+ # #### Define a long attribute
15
+ #
16
+ # ```ruby
17
+ # class MyModel < StretchyModel
18
+ # attribute :population, :long
19
+ # end
20
+ # ```
21
+ #
2
22
  class Long < Base
3
23
  def type
4
24
  :long
@@ -1,18 +1,27 @@
1
1
  module Stretchy::Attributes::Type::Numeric
2
2
 
3
- # Public: Defines a scaled_float attribute for the model.
3
+ # The ScaledFloat attribute type
4
4
  #
5
- # opts - The Hash options used to refine the attribute (default: {}):
6
- # :scaling_factor - The Integer scaling factor to use when encoding values. This parameter is required.
5
+ # This class is used to define a scaled_float attribute for a model. It provides support for the Elasticsearch numeric data type, which is a type of data type that can hold floating point values scaled by a fixed double precision factor.
7
6
  #
8
- # Examples
7
+ # ### Parameters
9
8
  #
10
- # class MyModel
11
- # include StretchyModel
9
+ # - `type:` `:scaled_float`.
10
+ # - `options:` The Hash of options for the attribute.
11
+ # - `:scaling_factor:` The Integer scaling factor to use when encoding values. This parameter is required.
12
+ #
13
+ # ---
14
+ #
15
+ # ### Examples
16
+ #
17
+ # #### Define a scaled_float attribute
18
+ #
19
+ # ```ruby
20
+ # class MyModel < StretchyModel
12
21
  # attribute :rating, :scaled_float, scaling_factor: 10
13
22
  # end
23
+ # ```
14
24
  #
15
- # Returns nothing.
16
25
  class ScaledFloat < Base
17
26
  OPTIONS = Base::OPTIONS + [:scaling_factor]
18
27
 
@@ -1,4 +1,24 @@
1
1
  module Stretchy::Attributes::Type::Numeric
2
+ # The Short attribute type
3
+ #
4
+ # This class is used to define a short attribute for a model. It provides support for the Elasticsearch numeric data type, which is a type of data type that can hold short integer values.
5
+ #
6
+ # ### Parameters
7
+ #
8
+ # - `type:` `:short`.
9
+ #
10
+ # ---
11
+ #
12
+ # ### Examples
13
+ #
14
+ # #### Define a short attribute
15
+ #
16
+ # ```ruby
17
+ # class MyModel < StretchyModel
18
+ # attribute :short_number, :short
19
+ # end
20
+ # ```
21
+ #
2
22
  class Short < Base
3
23
  def type
4
24
  :short
@@ -1,5 +1,25 @@
1
1
  module Stretchy::Attributes::Type::Numeric
2
- class UnsignedLong < Stretchy::Attributes::Type::Numeric::Base
2
+ # The UnsignedLong attribute type
3
+ #
4
+ # This class is used to define an unsigned_long attribute for a model. It provides support for the Elasticsearch numeric data type, which is a type of data type that can hold unsigned long integer values.
5
+ #
6
+ # ### Parameters
7
+ #
8
+ # - `type:` `:unsigned_long`.
9
+ #
10
+ # ---
11
+ #
12
+ # ### Examples
13
+ #
14
+ # #### Define an unsigned_long attribute
15
+ #
16
+ # ```ruby
17
+ # class MyModel < Stretchy::Record
18
+ # attribute :large_number, :unsigned_long
19
+ # end
20
+ # ```
21
+ #
22
+ class UnsignedLong < Base
3
23
  def type
4
24
  :unsigned_long
5
25
  end
@@ -1,5 +1,7 @@
1
1
  module Stretchy::Attributes::Type
2
- # Public: Defines a percolator attribute for the model.
2
+ # The Percolator attribute type
3
+ #
4
+ # This class is used to define a percolator attribute for a model.
3
5
  #
4
6
  # The percolator field type parses a JSON structure into a native query and stores that query,
5
7
  # so that the percolate query can use it to match provided documents.
@@ -8,13 +10,23 @@ module Stretchy::Attributes::Type
8
10
  # The percolator field type has no settings. Just configuring the percolator field type
9
11
  # is sufficient to instruct Elasticsearch to treat a field as a query.
10
12
  #
11
- # Examples
13
+ # ### Parameters
14
+ #
15
+ # - `type:` `:percolator`.
16
+ # - `options:` The Hash of options for the attribute. This type does not have any specific options.
17
+ #
18
+ # ---
19
+ #
20
+ # ### Examples
21
+ #
22
+ # #### Define a percolator attribute
12
23
  #
13
- # class MyModel < Stretchy::Record
24
+ # ```ruby
25
+ # class MyModel < StretchyModel
14
26
  # attribute :query, :percolator
15
27
  # end
28
+ # ```
16
29
  #
17
- # Returns nothing.
18
30
  class Percolator < Stretchy::Attributes::Type::Base
19
31
  def type
20
32
  :percolator
@@ -1,19 +1,29 @@
1
1
  module Stretchy::Attributes::Type
2
- # Public: Defines a point attribute for the model.
2
+ # The Point attribute type
3
3
  #
4
- # opts - The Hash options used to refine the attribute (default: {}):
5
- # :ignore_malformed - The Boolean indicating if malformed points should be ignored. Defaults to false.
6
- # :ignore_z_value - The Boolean indicating if the z value of three dimension points should be ignored. Defaults to true.
7
- # :null_value - The Point value to be substituted for any explicit null values. Defaults to null.
4
+ # This class is used to define a point attribute for a model. It provides support for the Elasticsearch point data type, which is
5
+ # a type of data type that can hold geographical points (latitude and longitude).
8
6
  #
9
- # Examples
7
+ # ### Parameters
10
8
  #
11
- # class MyModel
12
- # include StretchyModel
9
+ # - `type:` `:point`.
10
+ # - `options:` The Hash of options for the attribute.
11
+ # - `:ignore_malformed:` The Boolean indicating if malformed points should be ignored. Defaults to false.
12
+ # - `:ignore_z_value:` The Boolean indicating if the z value of three dimension points should be ignored. Defaults to true.
13
+ # - `:null_value:` The Point value to be substituted for any explicit null values. Defaults to null.
14
+ #
15
+ # ---
16
+ #
17
+ # ### Examples
18
+ #
19
+ # #### Define a point attribute
20
+ #
21
+ # ```ruby
22
+ # class MyModel < StretchyModel
13
23
  # attribute :location, :point, ignore_malformed: true
14
24
  # end
25
+ # ```
15
26
  #
16
- # Returns nothing.
17
27
  class Point < Stretchy::Attributes::Type::Base
18
28
  OPTIONS = [:ignore_malformed, :ignore_z_value, :null_value]
19
29
 
@@ -1,5 +1,28 @@
1
1
  module Stretchy::Attributes::Type::Range
2
- class Base < Stretchy::Attributes::Type::Base
2
+ # The Base class for range attribute types
3
+ #
4
+ # This class is used to define a base for range attribute types for a model. It provides support for the Elasticsearch range data types, which are types of data that can hold range of values.
5
+ #
6
+ # ### Parameters
7
+ #
8
+ # - `options:` The Hash of options for the attribute.
9
+ # - `:coerce:` The Boolean indicating if strings should be converted to numbers and fractions truncated for integers. Defaults to true.
10
+ # - `:index:` The Boolean indicating if the field should be quickly searchable. Defaults to true.
11
+ # - `:store:` The Boolean indicating if the field value should be stored and retrievable separately from the _source field. Defaults to false.
12
+ #
13
+ # ---
14
+ #
15
+ # ### Examples
16
+ #
17
+ # #### Define a range attribute
18
+ #
19
+ # ```ruby
20
+ # class MyModel < Stretchy::Record
21
+ # attribute :age_range, :integer_range, coerce: false
22
+ # end
23
+ # ```
24
+ #
25
+ class Base < Stretchy::Attributes::Type::Base #:nodoc:
3
26
  OPTIONS = [:coerce, :index, :store]
4
27
 
5
28
  def type
@@ -1,13 +1,29 @@
1
1
  module Stretchy::Attributes::Type::Range
2
- # Public: Defines a date_range attribute for the model.
2
+ # The Range attribute type
3
3
  #
4
- # Examples
4
+ # This class is used to define a range attribute for a model. It provides support for the Elasticsearch range data type, which is a type of data type that can hold range of values.
5
5
  #
6
- # class MyModel < Stretchy::Record
7
- # attribute :birth_date_range, :date_range
6
+ # ### Parameters
7
+ #
8
+ # - `type:` `:range`.
9
+ # - `options:` The Hash of options for the attribute.
10
+ # - `:doc_values:` The Boolean indicating if the field should be stored on disk in a column-stride fashion. This allows it to be used later for sorting, aggregations, or scripting. Defaults to true.
11
+ # - `:index:` The Boolean indicating if the field should be searchable. Defaults to true.
12
+ # - `:store:` The Boolean indicating if the field value should be stored and retrievable separately from the _source field. Defaults to false.
13
+ # - `:coerce:` The Boolean indicating if the field should automatically coerce the values to the data type. Defaults to true.
14
+ #
15
+ # ---
16
+ #
17
+ # ### Examples
18
+ #
19
+ # #### Define a range attribute
20
+ #
21
+ # ```ruby
22
+ # class MyModel < StretchyModel
23
+ # attribute :age_range, :range
8
24
  # end
25
+ # ```
9
26
  #
10
- # Returns nothing.
11
27
  class DateRange < Base
12
28
 
13
29
  def type
@@ -1,13 +1,29 @@
1
1
  module Stretchy::Attributes::Type::Range
2
- # Public: Defines a double_range attribute for the model.
2
+ # The DoubleRange attribute type
3
3
  #
4
- # Examples
4
+ # This class is used to define a double_range attribute for a model. It provides support for the Elasticsearch range data type, which is a type of data type that can hold range of double values.
5
5
  #
6
- # class MyModel < Stretchy::Record
6
+ # ### Parameters
7
+ #
8
+ # - `type:` `:double_range`.
9
+ # - `options:` The Hash of options for the attribute.
10
+ # - `:doc_values:` The Boolean indicating if the field should be stored on disk in a column-stride fashion. This allows it to be used later for sorting, aggregations, or scripting. Defaults to true.
11
+ # - `:index:` The Boolean indicating if the field should be searchable. Defaults to true.
12
+ # - `:store:` The Boolean indicating if the field value should be stored and retrievable separately from the _source field. Defaults to false.
13
+ # - `:coerce:` The Boolean indicating if the field should automatically coerce the values to the data type. Defaults to true.
14
+ #
15
+ # ---
16
+ #
17
+ # ### Examples
18
+ #
19
+ # #### Define a double_range attribute
20
+ #
21
+ # ```ruby
22
+ # class MyModel < StretchyModel
7
23
  # attribute :weight_range, :double_range
8
24
  # end
25
+ # ```
9
26
  #
10
- # Returns nothing.
11
27
  class DoubleRange < Base
12
28
 
13
29
  def type
@@ -1,13 +1,29 @@
1
1
  module Stretchy::Attributes::Type::Range
2
- # Public: Defines a float_range attribute for the model.
2
+ # The DoubleRange attribute type
3
3
  #
4
- # Examples
4
+ # This class is used to define a double_range attribute for a model. It provides support for the Elasticsearch range data type, which is a type of data type that can hold range of double values.
5
5
  #
6
- # class MyModel < Stretchy::Record
7
- # attribute :rating_range, :float_range
6
+ # ### Parameters
7
+ #
8
+ # - `type:` `:double_range`.
9
+ # - `options:` The Hash of options for the attribute.
10
+ # - `:doc_values:` The Boolean indicating if the field should be stored on disk in a column-stride fashion. This allows it to be used later for sorting, aggregations, or scripting. Defaults to true.
11
+ # - `:index:` The Boolean indicating if the field should be searchable. Defaults to true.
12
+ # - `:store:` The Boolean indicating if the field value should be stored and retrievable separately from the _source field. Defaults to false.
13
+ # - `:coerce:` The Boolean indicating if the field should automatically coerce the values to the data type. Defaults to true.
14
+ #
15
+ # ---
16
+ #
17
+ # ### Examples
18
+ #
19
+ # #### Define a double_range attribute
20
+ #
21
+ # ```ruby
22
+ # class MyModel < StretchyModel
23
+ # attribute :weight_range, :double_range
8
24
  # end
25
+ # ```
9
26
  #
10
- # Returns nothing.
11
27
  class FloatRange < Base
12
28
  def type
13
29
  :float_range
@@ -1,13 +1,29 @@
1
1
  module Stretchy::Attributes::Type::Range
2
- # Public: Defines an integer_range attribute for the model.
2
+ # The IntegerRange attribute type
3
3
  #
4
- # Examples
4
+ # This class is used to define an integer_range attribute for a model. It provides support for the Elasticsearch range data type, which is a type of data type that can hold range of integer values.
5
5
  #
6
- # class MyModel < Stretchy::Record
6
+ # ### Parameters
7
+ #
8
+ # - `type:` `:integer_range`.
9
+ # - `options:` The Hash of options for the attribute.
10
+ # - `:doc_values:` The Boolean indicating if the field should be stored on disk in a column-stride fashion. This allows it to be used later for sorting, aggregations, or scripting. Defaults to true.
11
+ # - `:index:` The Boolean indicating if the field should be searchable. Defaults to true.
12
+ # - `:store:` The Boolean indicating if the field value should be stored and retrievable separately from the _source field. Defaults to false.
13
+ # - `:coerce:` The Boolean indicating if the field should automatically coerce the values to the data type. Defaults to true.
14
+ #
15
+ # ---
16
+ #
17
+ # ### Examples
18
+ #
19
+ # #### Define an integer_range attribute
20
+ #
21
+ # ```ruby
22
+ # class MyModel < StretchyModel
7
23
  # attribute :age_range, :integer_range
8
24
  # end
25
+ # ```
9
26
  #
10
- # Returns nothing.
11
27
  class IntegerRange < Base
12
28
  def type
13
29
  :integer_range
@@ -1,13 +1,29 @@
1
1
  module Stretchy::Attributes::Type::Range
2
- # Public: Defines an ip_range attribute for the model.
2
+ # The IpRange attribute type
3
3
  #
4
- # Examples
4
+ # This class is used to define an ip_range attribute for a model. It provides support for the Elasticsearch range data type, which is a type of data type that can hold range of IP values.
5
5
  #
6
- # class MyModel < Stretchy::Record
6
+ # ### Parameters
7
+ #
8
+ # - `type:` `:ip_range`.
9
+ # - `options:` The Hash of options for the attribute.
10
+ # - `:doc_values:` The Boolean indicating if the field should be stored on disk in a column-stride fashion. This allows it to be used later for sorting, aggregations, or scripting. Defaults to true.
11
+ # - `:index:` The Boolean indicating if the field should be searchable. Defaults to true.
12
+ # - `:store:` The Boolean indicating if the field value should be stored and retrievable separately from the _source field. Defaults to false.
13
+ # - `:coerce:` The Boolean indicating if the field should automatically coerce the values to the data type. Defaults to true.
14
+ #
15
+ # ---
16
+ #
17
+ # ### Examples
18
+ #
19
+ # #### Define an ip_range attribute
20
+ #
21
+ # ```ruby
22
+ # class MyModel < StretchyModel
7
23
  # attribute :ip_range, :ip_range
8
24
  # end
25
+ # ```
9
26
  #
10
- # Returns nothing.
11
27
  class IpRange < Base
12
28
  def type
13
29
  :ip_range
@@ -1,13 +1,29 @@
1
1
  module Stretchy::Attributes::Type::Range
2
- # Public: Defines a long_range attribute for the model.
2
+ # The LongRange attribute type
3
3
  #
4
- # Examples
4
+ # This class is used to define a long_range attribute for a model. It provides support for the Elasticsearch range data type, which is a type of data type that can hold range of long integer values.
5
5
  #
6
- # class MyModel < Stretchy::Record
6
+ # ### Parameters
7
+ #
8
+ # - `type:` `:long_range`.
9
+ # - `options:` The Hash of options for the attribute.
10
+ # - `:doc_values:` The Boolean indicating if the field should be stored on disk in a column-stride fashion. This allows it to be used later for sorting, aggregations, or scripting. Defaults to true.
11
+ # - `:index:` The Boolean indicating if the field should be searchable. Defaults to true.
12
+ # - `:store:` The Boolean indicating if the field value should be stored and retrievable separately from the _source field. Defaults to false.
13
+ # - `:coerce:` The Boolean indicating if the field should automatically coerce the values to the data type. Defaults to true.
14
+ #
15
+ # ---
16
+ #
17
+ # ### Examples
18
+ #
19
+ # #### Define a long_range attribute
20
+ #
21
+ # ```ruby
22
+ # class MyModel < StretchyModel
7
23
  # attribute :population_range, :long_range
8
24
  # end
25
+ # ```
9
26
  #
10
- # Returns nothing.
11
27
  class LongRange < Base
12
28
  def type
13
29
  :long_range
@@ -1,16 +1,26 @@
1
1
  module Stretchy::Attributes::Type
2
- # Public: Defines a rank_feature attribute for the model.
2
+ # The RankFeature attribute type
3
3
  #
4
- # opts - The Hash options used to refine the attribute (default: {}):
5
- # :positive_score_impact - The Boolean indicating if features correlate positively with the score. If set to false, the score decreases with the value of the feature instead of increasing. Defaults to true.
4
+ # This class is used to define a rank_feature attribute for a model. It provides support for the Elasticsearch rank_feature data type, which is a type of data type that can hold numerical features that should impact the relevance score of the documents.
6
5
  #
7
- # Examples
6
+ # ### Parameters
8
7
  #
9
- # class MyModel < Stretchy::Record
8
+ # - `type:` `:rank_feature`.
9
+ # - `options:` The Hash of options for the attribute.
10
+ # - `:positive_score_impact:` The Boolean indicating if features correlate positively with the score. If set to false, the score decreases with the value of the feature instead of increasing. Defaults to true.
11
+ #
12
+ # ---
13
+ #
14
+ # ### Examples
15
+ #
16
+ # #### Define a rank_feature attribute
17
+ #
18
+ # ```ruby
19
+ # class MyModel < StretchyModel
10
20
  # attribute :url_length, :rank_feature, positive_score_impact: false
11
21
  # end
22
+ # ```
12
23
  #
13
- # Returns nothing.
14
24
  class RankFeature < Stretchy::Attributes::Type::Base
15
25
  OPTIONS = [:positive_score_impact]
16
26