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.
- checksums.yaml +4 -4
- data/.yardopts +2 -1
- data/README.md +28 -10
- data/Rakefile +56 -0
- data/containers/Dockerfile.opensearch +4 -3
- data/docker-compose.yml +32 -19
- data/docs/.nojekyll +0 -0
- data/docs/README.md +147 -0
- data/docs/_coverpage.md +14 -0
- data/docs/_sidebar.md +14 -0
- data/docs/examples/_sidebar.md +15 -0
- data/docs/examples/data_analysis.md +216 -0
- data/docs/examples/semantic_search_with_llm.md +83 -0
- data/docs/examples/simple-ingest-pipeline.md +326 -0
- data/docs/guides/_sidebar.md +14 -0
- data/docs/guides/aggregations.md +142 -0
- data/docs/guides/machine-learning.md +154 -0
- data/docs/guides/models.md +372 -0
- data/docs/guides/pipelines.md +151 -0
- data/docs/guides/querying.md +361 -0
- data/docs/guides/quick-start.md +72 -0
- data/docs/guides/scopes.md +125 -0
- data/docs/index.html +113 -0
- data/docs/stretchy.cover.png +0 -0
- data/docs/stretchy.logo.png +0 -0
- data/docs/styles.css +90 -0
- data/lib/elasticsearch/api/actions/machine_learning/models/delete_model.rb +33 -0
- data/lib/elasticsearch/api/actions/machine_learning/models/deploy.rb +31 -0
- data/lib/elasticsearch/api/actions/machine_learning/models/get_model.rb +43 -0
- data/lib/elasticsearch/api/actions/machine_learning/models/get_status.rb +31 -0
- data/lib/elasticsearch/api/actions/machine_learning/models/params_registry.rb +45 -0
- data/lib/elasticsearch/api/actions/machine_learning/models/register.rb +45 -0
- data/lib/elasticsearch/api/actions/machine_learning/models/undeploy.rb +32 -0
- data/lib/elasticsearch/api/actions/machine_learning/models/update_model.rb +39 -0
- data/lib/elasticsearch/api/namespace/machine_learning/model.rb +27 -0
- data/lib/opensearch/api/actions/machine_learning/models/delete_model.rb +33 -0
- data/lib/opensearch/api/actions/machine_learning/models/deploy.rb +31 -0
- data/lib/opensearch/api/actions/machine_learning/models/get_model.rb +44 -0
- data/lib/opensearch/api/actions/machine_learning/models/get_status.rb +31 -0
- data/lib/opensearch/api/actions/machine_learning/models/params_registry.rb +45 -0
- data/lib/opensearch/api/actions/machine_learning/models/register.rb +45 -0
- data/lib/opensearch/api/actions/machine_learning/models/undeploy.rb +31 -0
- data/lib/opensearch/api/actions/machine_learning/models/update_model.rb +39 -0
- data/lib/opensearch/api/namespace/machine_learning/model.rb +27 -0
- data/lib/stretchy/attributes/transformers/keyword_transformer.rb +41 -35
- data/lib/stretchy/attributes/type/array.rb +24 -1
- data/lib/stretchy/attributes/type/base.rb +6 -2
- data/lib/stretchy/attributes/type/binary.rb +24 -17
- data/lib/stretchy/attributes/type/boolean.rb +29 -22
- data/lib/stretchy/attributes/type/completion.rb +18 -10
- data/lib/stretchy/attributes/type/constant_keyword.rb +35 -26
- data/lib/stretchy/attributes/type/date_time.rb +81 -20
- data/lib/stretchy/attributes/type/dense_vector.rb +46 -49
- data/lib/stretchy/attributes/type/flattened.rb +28 -19
- data/lib/stretchy/attributes/type/geo_point.rb +21 -12
- data/lib/stretchy/attributes/type/geo_shape.rb +21 -12
- data/lib/stretchy/attributes/type/hash.rb +24 -10
- data/lib/stretchy/attributes/type/histogram.rb +25 -0
- data/lib/stretchy/attributes/type/ip.rb +26 -17
- data/lib/stretchy/attributes/type/join.rb +16 -7
- data/lib/stretchy/attributes/type/keyword.rb +21 -26
- data/lib/stretchy/attributes/type/knn_vector.rb +47 -0
- data/lib/stretchy/attributes/type/match_only_text.rb +22 -1
- data/lib/stretchy/attributes/type/nested.rb +16 -11
- data/lib/stretchy/attributes/type/numeric/base.rb +30 -22
- data/lib/stretchy/attributes/type/numeric/byte.rb +20 -0
- data/lib/stretchy/attributes/type/numeric/double.rb +20 -0
- data/lib/stretchy/attributes/type/numeric/float.rb +20 -0
- data/lib/stretchy/attributes/type/numeric/half_float.rb +20 -0
- data/lib/stretchy/attributes/type/numeric/integer.rb +21 -1
- data/lib/stretchy/attributes/type/numeric/long.rb +20 -0
- data/lib/stretchy/attributes/type/numeric/scaled_float.rb +16 -7
- data/lib/stretchy/attributes/type/numeric/short.rb +20 -0
- data/lib/stretchy/attributes/type/numeric/unsigned_long.rb +21 -1
- data/lib/stretchy/attributes/type/percolator.rb +16 -4
- data/lib/stretchy/attributes/type/point.rb +19 -9
- data/lib/stretchy/attributes/type/range/base.rb +24 -1
- data/lib/stretchy/attributes/type/range/date_range.rb +21 -5
- data/lib/stretchy/attributes/type/range/double_range.rb +20 -4
- data/lib/stretchy/attributes/type/range/float_range.rb +21 -5
- data/lib/stretchy/attributes/type/range/integer_range.rb +20 -4
- data/lib/stretchy/attributes/type/range/ip_range.rb +20 -4
- data/lib/stretchy/attributes/type/range/long_range.rb +20 -4
- data/lib/stretchy/attributes/type/rank_feature.rb +16 -6
- data/lib/stretchy/attributes/type/rank_features.rb +27 -10
- data/lib/stretchy/attributes/type/search_as_you_type.rb +28 -18
- data/lib/stretchy/attributes/type/shape.rb +19 -9
- data/lib/stretchy/attributes/type/sparse_vector.rb +25 -21
- data/lib/stretchy/attributes/type/string.rb +42 -1
- data/lib/stretchy/attributes/type/text.rb +53 -28
- data/lib/stretchy/attributes/type/token_count.rb +21 -11
- data/lib/stretchy/attributes/type/version.rb +16 -6
- data/lib/stretchy/attributes/type/wildcard.rb +36 -25
- data/lib/stretchy/attributes.rb +30 -0
- data/lib/stretchy/delegation/gateway_delegation.rb +86 -2
- data/lib/stretchy/index_setting.rb +94 -0
- data/lib/stretchy/indexing/bulk.rb +75 -3
- data/lib/stretchy/machine_learning/model.rb +192 -0
- data/lib/stretchy/model/callbacks.rb +1 -0
- data/lib/stretchy/model/common.rb +157 -0
- data/lib/stretchy/model/persistence.rb +144 -0
- data/lib/stretchy/model/refreshable.rb +26 -0
- data/lib/stretchy/open_search_compatibility.rb +4 -0
- data/lib/stretchy/pipeline.rb +124 -0
- data/lib/stretchy/pipelines/processor.rb +57 -0
- data/lib/stretchy/querying.rb +7 -7
- data/lib/stretchy/rails/instrumentation/publishers.rb +31 -0
- data/lib/{rails → stretchy/rails}/instrumentation/railtie.rb +11 -6
- data/lib/stretchy/record.rb +5 -4
- data/lib/stretchy/relation.rb +230 -28
- data/lib/stretchy/relations/aggregation_methods/aggregation.rb +59 -0
- data/lib/stretchy/relations/aggregation_methods/avg.rb +45 -0
- data/lib/stretchy/relations/aggregation_methods/bucket_script.rb +47 -0
- data/lib/stretchy/relations/aggregation_methods/bucket_selector.rb +47 -0
- data/lib/stretchy/relations/aggregation_methods/bucket_sort.rb +47 -0
- data/lib/stretchy/relations/aggregation_methods/cardinality.rb +47 -0
- data/lib/stretchy/relations/aggregation_methods/children.rb +47 -0
- data/lib/stretchy/relations/aggregation_methods/composite.rb +41 -0
- data/lib/stretchy/relations/aggregation_methods/date_histogram.rb +53 -0
- data/lib/stretchy/relations/aggregation_methods/date_range.rb +53 -0
- data/lib/stretchy/relations/aggregation_methods/extended_stats.rb +48 -0
- data/lib/stretchy/relations/aggregation_methods/filter.rb +47 -0
- data/lib/stretchy/relations/aggregation_methods/filters.rb +47 -0
- data/lib/stretchy/relations/aggregation_methods/geo_bounds.rb +40 -0
- data/lib/stretchy/relations/aggregation_methods/geo_centroid.rb +40 -0
- data/lib/stretchy/relations/aggregation_methods/global.rb +39 -0
- data/lib/stretchy/relations/aggregation_methods/histogram.rb +43 -0
- data/lib/stretchy/relations/aggregation_methods/ip_range.rb +41 -0
- data/lib/stretchy/relations/aggregation_methods/max.rb +40 -0
- data/lib/stretchy/relations/aggregation_methods/min.rb +41 -0
- data/lib/stretchy/relations/aggregation_methods/missing.rb +40 -0
- data/lib/stretchy/relations/aggregation_methods/nested.rb +40 -0
- data/lib/stretchy/relations/aggregation_methods/percentile_ranks.rb +45 -0
- data/lib/stretchy/relations/aggregation_methods/percentiles.rb +45 -0
- data/lib/stretchy/relations/aggregation_methods/range.rb +42 -0
- data/lib/stretchy/relations/aggregation_methods/reverse_nested.rb +40 -0
- data/lib/stretchy/relations/aggregation_methods/sampler.rb +40 -0
- data/lib/stretchy/relations/aggregation_methods/scripted_metric.rb +43 -0
- data/lib/stretchy/relations/aggregation_methods/significant_terms.rb +45 -0
- data/lib/stretchy/relations/aggregation_methods/stats.rb +42 -0
- data/lib/stretchy/relations/aggregation_methods/sum.rb +42 -0
- data/lib/stretchy/relations/aggregation_methods/terms.rb +46 -0
- data/lib/stretchy/relations/aggregation_methods/top_hits.rb +42 -0
- data/lib/stretchy/relations/aggregation_methods/top_metrics.rb +44 -0
- data/lib/stretchy/relations/aggregation_methods/value_count.rb +41 -0
- data/lib/stretchy/relations/aggregation_methods/weighted_avg.rb +42 -0
- data/lib/stretchy/relations/aggregation_methods.rb +20 -749
- data/lib/stretchy/relations/finder_methods.rb +2 -18
- data/lib/stretchy/relations/null_relation.rb +55 -0
- data/lib/stretchy/relations/query_builder.rb +139 -23
- data/lib/stretchy/relations/query_methods/bind.rb +19 -0
- data/lib/stretchy/relations/query_methods/extending.rb +29 -0
- data/lib/stretchy/relations/query_methods/fields.rb +70 -0
- data/lib/stretchy/relations/query_methods/filter_query.rb +53 -0
- data/lib/stretchy/relations/query_methods/has_field.rb +40 -0
- data/lib/stretchy/relations/query_methods/highlight.rb +75 -0
- data/lib/stretchy/relations/query_methods/hybrid.rb +60 -0
- data/lib/stretchy/relations/query_methods/ids.rb +40 -0
- data/lib/stretchy/relations/query_methods/match.rb +52 -0
- data/lib/stretchy/relations/query_methods/must_not.rb +54 -0
- data/lib/stretchy/relations/query_methods/neural.rb +58 -0
- data/lib/stretchy/relations/query_methods/neural_sparse.rb +43 -0
- data/lib/stretchy/relations/query_methods/none.rb +21 -0
- data/lib/stretchy/relations/query_methods/or_filter.rb +21 -0
- data/lib/stretchy/relations/query_methods/order.rb +63 -0
- data/lib/stretchy/relations/query_methods/query_string.rb +44 -0
- data/lib/stretchy/relations/query_methods/regexp.rb +61 -0
- data/lib/stretchy/relations/query_methods/should.rb +51 -0
- data/lib/stretchy/relations/query_methods/size.rb +44 -0
- data/lib/stretchy/relations/query_methods/skip_callbacks.rb +47 -0
- data/lib/stretchy/relations/query_methods/source.rb +59 -0
- data/lib/stretchy/relations/query_methods/where.rb +113 -0
- data/lib/stretchy/relations/query_methods.rb +51 -540
- data/lib/stretchy/relations/scoping/default.rb +136 -0
- data/lib/stretchy/relations/scoping/named.rb +70 -0
- data/lib/stretchy/relations/scoping/scope_registry.rb +36 -0
- data/lib/stretchy/relations/scoping.rb +30 -0
- data/lib/stretchy/relations/search_option_methods.rb +2 -0
- data/lib/stretchy/shared_scopes.rb +6 -1
- data/lib/stretchy/version.rb +1 -1
- data/lib/stretchy.rb +23 -11
- metadata +147 -18
- data/lib/rails/instrumentation/publishers.rb +0 -29
- data/lib/stretchy/common.rb +0 -33
- data/lib/stretchy/null_relation.rb +0 -53
- data/lib/stretchy/persistence.rb +0 -43
- data/lib/stretchy/refreshable.rb +0 -15
- data/lib/stretchy/scoping/default.rb +0 -134
- data/lib/stretchy/scoping/named.rb +0 -68
- data/lib/stretchy/scoping/scope_registry.rb +0 -34
- data/lib/stretchy/scoping.rb +0 -28
@@ -1,29 +1,37 @@
|
|
1
1
|
module Stretchy::Attributes::Type::Numeric
|
2
|
-
#
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
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
|
-
|
25
|
-
|
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
|
-
|
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
|
-
#
|
3
|
+
# The ScaledFloat attribute type
|
4
4
|
#
|
5
|
-
#
|
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
|
-
#
|
7
|
+
# ### Parameters
|
9
8
|
#
|
10
|
-
#
|
11
|
-
#
|
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
|
-
|
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
|
-
#
|
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
|
-
#
|
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
|
-
#
|
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
|
-
#
|
2
|
+
# The Point attribute type
|
3
3
|
#
|
4
|
-
#
|
5
|
-
#
|
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
|
-
#
|
7
|
+
# ### Parameters
|
10
8
|
#
|
11
|
-
#
|
12
|
-
#
|
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
|
-
|
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
|
-
#
|
2
|
+
# The Range attribute type
|
3
3
|
#
|
4
|
-
#
|
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
|
-
#
|
7
|
-
#
|
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
|
-
#
|
2
|
+
# The DoubleRange attribute type
|
3
3
|
#
|
4
|
-
#
|
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
|
-
#
|
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
|
-
#
|
2
|
+
# The DoubleRange attribute type
|
3
3
|
#
|
4
|
-
#
|
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
|
-
#
|
7
|
-
#
|
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
|
-
#
|
2
|
+
# The IntegerRange attribute type
|
3
3
|
#
|
4
|
-
#
|
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
|
-
#
|
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
|
-
#
|
2
|
+
# The IpRange attribute type
|
3
3
|
#
|
4
|
-
#
|
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
|
-
#
|
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
|
-
#
|
2
|
+
# The LongRange attribute type
|
3
3
|
#
|
4
|
-
#
|
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
|
-
#
|
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
|
-
#
|
2
|
+
# The RankFeature attribute type
|
3
3
|
#
|
4
|
-
#
|
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
|
-
#
|
6
|
+
# ### Parameters
|
8
7
|
#
|
9
|
-
#
|
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
|
|