search_flip 2.2.0 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +2 -1
- data/CHANGELOG.md +14 -0
- data/README.md +32 -30
- data/lib/search_flip/aggregatable.rb +2 -2
- data/lib/search_flip/aggregation.rb +1 -1
- data/lib/search_flip/connection.rb +19 -19
- data/lib/search_flip/criteria.rb +47 -29
- data/lib/search_flip/filterable.rb +5 -3
- data/lib/search_flip/http_client.rb +1 -1
- data/lib/search_flip/index.rb +30 -30
- data/lib/search_flip/post_filterable.rb +2 -2
- data/lib/search_flip/response.rb +13 -13
- data/lib/search_flip/version.rb +1 -1
- data/search_flip.gemspec +3 -3
- data/spec/search_flip/criteria_spec.rb +58 -1
- data/spec/search_flip/index_spec.rb +1 -1
- metadata +9 -11
- data/logo.svg +0 -96
data/lib/search_flip/criteria.rb
CHANGED
|
@@ -3,7 +3,7 @@ module SearchFlip
|
|
|
3
3
|
# The SearchFlip::Criteria class serves the purpose of chaining various
|
|
4
4
|
# filtering and aggregation methods. Each chainable method creates a new
|
|
5
5
|
# criteria object until a method is called that finally sends the respective
|
|
6
|
-
# request to
|
|
6
|
+
# request to Elasticsearch and returns the result.
|
|
7
7
|
#
|
|
8
8
|
# @example
|
|
9
9
|
# CommentIndex.where(public: true).sort(id: "desc").limit(1_000).records
|
|
@@ -22,7 +22,7 @@ module SearchFlip
|
|
|
22
22
|
attr_accessor :target, :profile_value, :source_value, :sort_values, :highlight_values, :suggest_values,
|
|
23
23
|
:offset_value, :limit_value, :includes_values, :eager_load_values, :preload_values, :failsafe_value,
|
|
24
24
|
:scroll_args, :custom_value, :terminate_after_value, :timeout_value, :preference_value,
|
|
25
|
-
:search_type_value, :routing_value, :track_total_hits_value
|
|
25
|
+
:search_type_value, :routing_value, :track_total_hits_value, :explain_value
|
|
26
26
|
|
|
27
27
|
# Creates a new criteria while merging the attributes (constraints,
|
|
28
28
|
# settings, etc) of the current criteria with the attributes of another one
|
|
@@ -52,6 +52,7 @@ module SearchFlip
|
|
|
52
52
|
criteria.search_type_value = other.search_type_value if other.search_type_value
|
|
53
53
|
criteria.routing_value = other.routing_value if other.routing_value
|
|
54
54
|
criteria.track_total_hits_value = other.track_total_hits_value unless other.track_total_hits_value.nil?
|
|
55
|
+
criteria.explain_value = other.explain_value unless other.explain_value.nil?
|
|
55
56
|
|
|
56
57
|
criteria.sort_values = (criteria.sort_values || []) + other.sort_values if other.sort_values
|
|
57
58
|
criteria.includes_values = (criteria.includes_values || []) + other.includes_values if other.includes_values
|
|
@@ -75,6 +76,22 @@ module SearchFlip
|
|
|
75
76
|
end
|
|
76
77
|
end
|
|
77
78
|
|
|
79
|
+
# Specifies whether or not to enable explanation for each hit on how
|
|
80
|
+
# its score was computed.
|
|
81
|
+
#
|
|
82
|
+
# @example
|
|
83
|
+
# CommentIndex.explain(true)
|
|
84
|
+
#
|
|
85
|
+
# @param value [Boolean] The value for explain
|
|
86
|
+
#
|
|
87
|
+
# @return [SearchFlip::Criteria] A newly created extended criteria
|
|
88
|
+
|
|
89
|
+
def explain(value)
|
|
90
|
+
fresh.tap do |criteria|
|
|
91
|
+
criteria.explain_value = value
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
|
|
78
95
|
# Specifies if or how many hits should be counted/tracked. Check out the
|
|
79
96
|
# elasticsearch docs for futher details.
|
|
80
97
|
#
|
|
@@ -185,7 +202,7 @@ module SearchFlip
|
|
|
185
202
|
# @return [SearchFlip::Criteria] A newly created extended criteria
|
|
186
203
|
|
|
187
204
|
def unscope(*scopes)
|
|
188
|
-
warn "[DEPRECATION] unscope is deprecated"
|
|
205
|
+
warn "[DEPRECATION] unscope is deprecated and will be removed in search_flip 3"
|
|
189
206
|
|
|
190
207
|
unknown = scopes - [:search, :post_search, :sort, :highlight, :suggest, :custom, :aggregate]
|
|
191
208
|
|
|
@@ -281,6 +298,7 @@ module SearchFlip
|
|
|
281
298
|
res.update from: offset_value_with_default, size: limit_value_with_default
|
|
282
299
|
|
|
283
300
|
res[:track_total_hits] = track_total_hits_value unless track_total_hits_value.nil?
|
|
301
|
+
res[:explain] = explain_value unless explain_value.nil?
|
|
284
302
|
res[:timeout] = timeout_value if timeout_value
|
|
285
303
|
res[:terminate_after] = terminate_after_value if terminate_after_value
|
|
286
304
|
res[:highlight] = highlight_values if highlight_values
|
|
@@ -331,9 +349,9 @@ module SearchFlip
|
|
|
331
349
|
# query.results[0].highlight.title # => "<em>hello</em> world"
|
|
332
350
|
#
|
|
333
351
|
# @param fields [Hash, Array, String, Symbol] The fields to highligt.
|
|
334
|
-
# Supports raw
|
|
352
|
+
# Supports raw Elasticsearch values by passing a Hash.
|
|
335
353
|
#
|
|
336
|
-
# @param options [Hash] Extra highlighting options. Check out the
|
|
354
|
+
# @param options [Hash] Extra highlighting options. Check out the Elasticsearch
|
|
337
355
|
# docs for further details.
|
|
338
356
|
#
|
|
339
357
|
# @return [SearchFlip::Criteria] A new criteria including the highlighting
|
|
@@ -363,7 +381,7 @@ module SearchFlip
|
|
|
363
381
|
#
|
|
364
382
|
# @param name [String, Symbol] The name of the suggestion section
|
|
365
383
|
#
|
|
366
|
-
# @param options [Hash] Additional suggestion options. Check out the
|
|
384
|
+
# @param options [Hash] Additional suggestion options. Check out the Elasticsearch
|
|
367
385
|
# docs for further details.
|
|
368
386
|
#
|
|
369
387
|
# @return [SearchFlip::Criteria] A new criteria including the suggestion section
|
|
@@ -416,8 +434,8 @@ module SearchFlip
|
|
|
416
434
|
end
|
|
417
435
|
end
|
|
418
436
|
|
|
419
|
-
# Sends a delete by query request to
|
|
420
|
-
# matching the query get deleted. Please note, for certain
|
|
437
|
+
# Sends a delete by query request to Elasticsearch, such that all documents
|
|
438
|
+
# matching the query get deleted. Please note, for certain Elasticsearch
|
|
421
439
|
# versions you need to install the delete-by-query plugin to get support
|
|
422
440
|
# for this feature. Refreshes the index if the auto_refresh is enabled.
|
|
423
441
|
# Raises SearchFlip::ResponseError in case any errors occur.
|
|
@@ -444,7 +462,7 @@ module SearchFlip
|
|
|
444
462
|
true
|
|
445
463
|
end
|
|
446
464
|
|
|
447
|
-
# Use to specify which fields of the source document you want
|
|
465
|
+
# Use to specify which fields of the source document you want Elasticsearch
|
|
448
466
|
# to return for each matching result.
|
|
449
467
|
#
|
|
450
468
|
# @example
|
|
@@ -519,10 +537,10 @@ module SearchFlip
|
|
|
519
537
|
end
|
|
520
538
|
end
|
|
521
539
|
|
|
522
|
-
# Specify the sort order you want
|
|
540
|
+
# Specify the sort order you want Elasticsearch to use for sorting the
|
|
523
541
|
# results. When you call this multiple times, the sort orders are appended
|
|
524
542
|
# to the already existing ones. The sort arguments get passed to
|
|
525
|
-
#
|
|
543
|
+
# Elasticsearch without modifications, such that you can use sort by
|
|
526
544
|
# script, etc here as well.
|
|
527
545
|
#
|
|
528
546
|
# @example Default usage
|
|
@@ -542,7 +560,7 @@ module SearchFlip
|
|
|
542
560
|
# @example Sort by native script
|
|
543
561
|
# CommentIndex.sort("_script" => "sort_script", lang: "native", order: "asc", type: "number")
|
|
544
562
|
#
|
|
545
|
-
# @param args The sort values that get passed to
|
|
563
|
+
# @param args The sort values that get passed to Elasticsearch
|
|
546
564
|
#
|
|
547
565
|
# @return [SearchFlip::Criteria] A newly created extended criteria
|
|
548
566
|
|
|
@@ -554,7 +572,7 @@ module SearchFlip
|
|
|
554
572
|
|
|
555
573
|
alias_method :order, :sort
|
|
556
574
|
|
|
557
|
-
# Specify the sort order you want
|
|
575
|
+
# Specify the sort order you want Elasticsearch to use for sorting the
|
|
558
576
|
# results with already existing sort orders being removed.
|
|
559
577
|
#
|
|
560
578
|
# @example
|
|
@@ -577,7 +595,7 @@ module SearchFlip
|
|
|
577
595
|
alias_method :reorder, :resort
|
|
578
596
|
|
|
579
597
|
# Adds a fully custom field/section to the request, such that upcoming or
|
|
580
|
-
# minor
|
|
598
|
+
# minor Elasticsearch features as well as other custom requirements can be
|
|
581
599
|
# used without having yet specialized criteria methods.
|
|
582
600
|
#
|
|
583
601
|
# @note Use with caution, because using #custom will potentiall override
|
|
@@ -623,7 +641,7 @@ module SearchFlip
|
|
|
623
641
|
(offset_value || 0).to_i
|
|
624
642
|
end
|
|
625
643
|
|
|
626
|
-
# Sets the request limit, ie
|
|
644
|
+
# Sets the request limit, ie Elasticsearch's size parameter that is used
|
|
627
645
|
# to restrict the results that get returned.
|
|
628
646
|
#
|
|
629
647
|
# @example
|
|
@@ -649,7 +667,7 @@ module SearchFlip
|
|
|
649
667
|
end
|
|
650
668
|
|
|
651
669
|
# Sets pagination parameters for the criteria by using offset and limit,
|
|
652
|
-
# ie
|
|
670
|
+
# ie Elasticsearch's from and size parameters.
|
|
653
671
|
#
|
|
654
672
|
# @example
|
|
655
673
|
# CommentIndex.paginate(page: 3)
|
|
@@ -677,7 +695,7 @@ module SearchFlip
|
|
|
677
695
|
|
|
678
696
|
# Fetches the records specified by the criteria in batches using the
|
|
679
697
|
# ElasicSearch scroll API and yields each batch. The batch size and scroll
|
|
680
|
-
# API timeout can be specified. Check out the
|
|
698
|
+
# API timeout can be specified. Check out the Elasticsearch docs for
|
|
681
699
|
# further details.
|
|
682
700
|
#
|
|
683
701
|
# @example
|
|
@@ -689,7 +707,7 @@ module SearchFlip
|
|
|
689
707
|
# @option options batch_size [Fixnum] The number of records to fetch per
|
|
690
708
|
# batch. Uses #limit to control the batch size.
|
|
691
709
|
# @option options timeout [String] The timeout per scroll request, ie how
|
|
692
|
-
# long
|
|
710
|
+
# long Elasticsearch will keep the request handle open.
|
|
693
711
|
|
|
694
712
|
def find_in_batches(options = {})
|
|
695
713
|
return enum_for(:find_in_batches, options) unless block_given?
|
|
@@ -700,8 +718,8 @@ module SearchFlip
|
|
|
700
718
|
end
|
|
701
719
|
|
|
702
720
|
# Fetches the results specified by the criteria in batches using the
|
|
703
|
-
#
|
|
704
|
-
# API timeout can be specified. Checkout out the
|
|
721
|
+
# Elasticsearch scroll API and yields each batch. The batch size and scroll
|
|
722
|
+
# API timeout can be specified. Checkout out the Elasticsearch docs for
|
|
705
723
|
# further details.
|
|
706
724
|
#
|
|
707
725
|
# @example
|
|
@@ -713,7 +731,7 @@ module SearchFlip
|
|
|
713
731
|
# @option options batch_size [Fixnum] The number of records to fetch per
|
|
714
732
|
# batch. Uses #limit to control the batch size.
|
|
715
733
|
# @option options timeout [String] The timeout per scroll request, ie how
|
|
716
|
-
# long
|
|
734
|
+
# long Elasticsearch will keep the request handle open.
|
|
717
735
|
|
|
718
736
|
def find_results_in_batches(options = {})
|
|
719
737
|
return enum_for(:find_results_in_batches, options) unless block_given?
|
|
@@ -724,8 +742,8 @@ module SearchFlip
|
|
|
724
742
|
end
|
|
725
743
|
|
|
726
744
|
# Fetches the records specified by the relatin in batches using the
|
|
727
|
-
#
|
|
728
|
-
# scroll API timeout can be specified. Check out the
|
|
745
|
+
# Elasticsearch scroll API and yields each record. The batch size and
|
|
746
|
+
# scroll API timeout can be specified. Check out the Elasticsearch docs for
|
|
729
747
|
# further details.
|
|
730
748
|
#
|
|
731
749
|
# @example
|
|
@@ -737,7 +755,7 @@ module SearchFlip
|
|
|
737
755
|
# @option options batch_size [Fixnum] The number of records to fetch per
|
|
738
756
|
# batch. Uses #limit to control the batch size.
|
|
739
757
|
# @option options timeout [String] The timeout per scroll request, ie how
|
|
740
|
-
# long
|
|
758
|
+
# long Elasticsearch will keep the request handle open.
|
|
741
759
|
|
|
742
760
|
def find_each(options = {})
|
|
743
761
|
return enum_for(:find_each, options) unless block_given?
|
|
@@ -752,8 +770,8 @@ module SearchFlip
|
|
|
752
770
|
alias_method :each, :find_each
|
|
753
771
|
|
|
754
772
|
# Fetches the results specified by the criteria in batches using the
|
|
755
|
-
#
|
|
756
|
-
# API timeout can be specified. Checkout out the
|
|
773
|
+
# Elasticsearch scroll API and yields each result. The batch size and scroll
|
|
774
|
+
# API timeout can be specified. Checkout out the Elasticsearch docs for
|
|
757
775
|
# further details.
|
|
758
776
|
#
|
|
759
777
|
# @example
|
|
@@ -765,7 +783,7 @@ module SearchFlip
|
|
|
765
783
|
# @option options batch_size [Fixnum] The number of records to fetch per
|
|
766
784
|
# batch. Uses #limit to control the batch size.
|
|
767
785
|
# @option options timeout [String] The timeout per scroll request, ie how
|
|
768
|
-
# long
|
|
786
|
+
# long Elasticsearch will keep the request handle open.
|
|
769
787
|
|
|
770
788
|
def find_each_result(options = {})
|
|
771
789
|
return enum_for(:find_each_result, options) unless block_given?
|
|
@@ -778,7 +796,7 @@ module SearchFlip
|
|
|
778
796
|
end
|
|
779
797
|
|
|
780
798
|
# Executes the search request for the current criteria, ie sends the
|
|
781
|
-
# request to
|
|
799
|
+
# request to Elasticsearch and returns the response. Connection and
|
|
782
800
|
# response errors will be rescued if you specify the criteria to be
|
|
783
801
|
# #failsafe, such that an empty response is returned instead.
|
|
784
802
|
#
|
|
@@ -825,7 +843,7 @@ module SearchFlip
|
|
|
825
843
|
alias_method :response, :execute
|
|
826
844
|
|
|
827
845
|
# Marks the criteria to be failsafe, ie certain exceptions raised due to
|
|
828
|
-
# invalid queries, inavailability of
|
|
846
|
+
# invalid queries, inavailability of Elasticsearch, etc get rescued and an
|
|
829
847
|
# empty criteria is returned instead.
|
|
830
848
|
#
|
|
831
849
|
# @see #execute See #execute for further details
|
|
@@ -16,7 +16,7 @@ module SearchFlip
|
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
# Adds a query string query to the criteria while using AND as the default
|
|
19
|
-
# operator unless otherwise specified. Check out the
|
|
19
|
+
# operator unless otherwise specified. Check out the Elasticsearch docs
|
|
20
20
|
# for further details.
|
|
21
21
|
#
|
|
22
22
|
# @example
|
|
@@ -158,6 +158,8 @@ module SearchFlip
|
|
|
158
158
|
# @return [SearchFlip::Criteria] A newly created extended criteria
|
|
159
159
|
|
|
160
160
|
def should(*args)
|
|
161
|
+
warn "[DEPRECATION] should will change in search_flip 3. Please use .must(bool: { should: ... }) until release."
|
|
162
|
+
|
|
161
163
|
fresh.tap do |criteria|
|
|
162
164
|
criteria.should_values = (should_values || []) + args
|
|
163
165
|
end
|
|
@@ -166,7 +168,7 @@ module SearchFlip
|
|
|
166
168
|
# Adds a range filter to the criteria without being forced to specify the
|
|
167
169
|
# left and right end of the range, such that you can eg simply specify lt,
|
|
168
170
|
# lte, gt and gte. For fully specified ranges, you can as well use #where,
|
|
169
|
-
# etc. Check out the
|
|
171
|
+
# etc. Check out the Elasticsearch docs for further details regarding the
|
|
170
172
|
# range filter.
|
|
171
173
|
#
|
|
172
174
|
# @example
|
|
@@ -184,7 +186,7 @@ module SearchFlip
|
|
|
184
186
|
|
|
185
187
|
# Adds a match all filter/query to the criteria, which simply matches all
|
|
186
188
|
# documents. This can be eg be used within filter aggregations or for
|
|
187
|
-
# filter chaining. Check out the
|
|
189
|
+
# filter chaining. Check out the Elasticsearch docs for further details.
|
|
188
190
|
#
|
|
189
191
|
# @example Basic usage
|
|
190
192
|
# CommentIndex.match_all
|
|
@@ -4,7 +4,7 @@ module SearchFlip
|
|
|
4
4
|
#
|
|
5
5
|
# The SearchFlip::HTTPClient class wraps the http gem, is for internal use
|
|
6
6
|
# and responsible for the http request/response handling, ie communicating
|
|
7
|
-
# with
|
|
7
|
+
# with Elasticsearch.
|
|
8
8
|
|
|
9
9
|
class HTTPClient
|
|
10
10
|
attr_accessor :request
|
data/lib/search_flip/index.rb
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
|
|
2
2
|
module SearchFlip
|
|
3
3
|
# The SearchFlip::Index mixin makes your class correspond to an
|
|
4
|
-
#
|
|
4
|
+
# Elasticsearch index. Your class can then create or delete the index, modify
|
|
5
5
|
# the mapping, import records, delete records and query the index. This gem
|
|
6
|
-
# uses an individual
|
|
7
|
-
#
|
|
6
|
+
# uses an individual Elasticsearch index for each index class, because
|
|
7
|
+
# Elasticsearch requires to have the same mapping for the same field name,
|
|
8
8
|
# even if the field is living in different types of the same index.
|
|
9
9
|
#
|
|
10
10
|
# @example Simple index class
|
|
@@ -255,11 +255,11 @@ module SearchFlip
|
|
|
255
255
|
:page, :per, :search, :highlight, :suggest, :custom, :find_in_batches, :find_results_in_batches,
|
|
256
256
|
:find_each, :find_each_result, :failsafe, :total_entries, :total_count, :timeout, :terminate_after,
|
|
257
257
|
:records, :results, :should, :should_not, :must, :must_not, :preference, :search_type, :routing,
|
|
258
|
-
:track_total_hits
|
|
258
|
+
:track_total_hits, :explain
|
|
259
259
|
|
|
260
|
-
# Override to specify the type name used within
|
|
260
|
+
# Override to specify the type name used within Elasticsearch. Recap,
|
|
261
261
|
# this gem uses an individual index for each index class, because
|
|
262
|
-
#
|
|
262
|
+
# Elasticsearch requires to have the same mapping for the same field
|
|
263
263
|
# name, even if the field is living in different types of the same index.
|
|
264
264
|
#
|
|
265
265
|
# @return [String] The name used for the type within the index
|
|
@@ -268,7 +268,7 @@ module SearchFlip
|
|
|
268
268
|
"_doc"
|
|
269
269
|
end
|
|
270
270
|
|
|
271
|
-
# Returns the base name of the index within
|
|
271
|
+
# Returns the base name of the index within Elasticsearch, ie the index
|
|
272
272
|
# name without prefix.
|
|
273
273
|
#
|
|
274
274
|
# @return [String] The base name of the index, ie without prefix
|
|
@@ -279,7 +279,7 @@ module SearchFlip
|
|
|
279
279
|
|
|
280
280
|
# @api private
|
|
281
281
|
#
|
|
282
|
-
# Returns the full name of the index within
|
|
282
|
+
# Returns the full name of the index within Elasticsearch, ie with prefix
|
|
283
283
|
# specified via SearchFlip::Config[:index_prefix].
|
|
284
284
|
#
|
|
285
285
|
# @return [String] The full index name
|
|
@@ -307,7 +307,7 @@ module SearchFlip
|
|
|
307
307
|
{}
|
|
308
308
|
end
|
|
309
309
|
|
|
310
|
-
# Returns whether or not the associated
|
|
310
|
+
# Returns whether or not the associated Elasticsearch index already
|
|
311
311
|
# exists.
|
|
312
312
|
#
|
|
313
313
|
# @return [Boolean] Whether or not the index exists
|
|
@@ -316,7 +316,7 @@ module SearchFlip
|
|
|
316
316
|
connection.index_exists?(index_name_with_prefix)
|
|
317
317
|
end
|
|
318
318
|
|
|
319
|
-
# Fetches the index settings from
|
|
319
|
+
# Fetches the index settings from Elasticsearch. Sends a GET request to
|
|
320
320
|
# index_url/_settings. Raises SearchFlip::ResponseError in case any
|
|
321
321
|
# errors occur.
|
|
322
322
|
#
|
|
@@ -326,7 +326,7 @@ module SearchFlip
|
|
|
326
326
|
connection.get_index_settings(index_name_with_prefix)
|
|
327
327
|
end
|
|
328
328
|
|
|
329
|
-
# Creates the index within
|
|
329
|
+
# Creates the index within Elasticsearch and applies index settings, if
|
|
330
330
|
# specified. Raises SearchFlip::ResponseError in case any errors
|
|
331
331
|
# occur.
|
|
332
332
|
#
|
|
@@ -336,7 +336,7 @@ module SearchFlip
|
|
|
336
336
|
connection.create_index(index_name_with_prefix, index_settings)
|
|
337
337
|
end
|
|
338
338
|
|
|
339
|
-
# Closes the index within
|
|
339
|
+
# Closes the index within Elasticsearch. Raises SearchFlip::ResponseError
|
|
340
340
|
# in case any errors occur.
|
|
341
341
|
#
|
|
342
342
|
# @return [Boolean] Returns true or raises SearchFlip::ResponseError
|
|
@@ -345,7 +345,7 @@ module SearchFlip
|
|
|
345
345
|
connection.close_index(index_name_with_prefix)
|
|
346
346
|
end
|
|
347
347
|
|
|
348
|
-
# Opens the index within
|
|
348
|
+
# Opens the index within Elasticsearch. Raises SearchFlip::ResponseError
|
|
349
349
|
# in case any errors occur.
|
|
350
350
|
#
|
|
351
351
|
# @return [Boolean] Returns true or raises SearchFlip::ResponseError
|
|
@@ -354,7 +354,7 @@ module SearchFlip
|
|
|
354
354
|
connection.open_index(index_name_with_prefix)
|
|
355
355
|
end
|
|
356
356
|
|
|
357
|
-
# Updates the index settings within
|
|
357
|
+
# Updates the index settings within Elasticsearch according to the index
|
|
358
358
|
# settings specified. Raises SearchFlip::ResponseError in case any
|
|
359
359
|
# errors occur.
|
|
360
360
|
#
|
|
@@ -364,7 +364,7 @@ module SearchFlip
|
|
|
364
364
|
connection.update_index_settings(index_name_with_prefix, index_settings)
|
|
365
365
|
end
|
|
366
366
|
|
|
367
|
-
# Deletes the index from
|
|
367
|
+
# Deletes the index from Elasticsearch. Raises SearchFlip::ResponseError
|
|
368
368
|
# in case any errors occur.
|
|
369
369
|
|
|
370
370
|
def delete_index
|
|
@@ -389,7 +389,7 @@ module SearchFlip
|
|
|
389
389
|
{}
|
|
390
390
|
end
|
|
391
391
|
|
|
392
|
-
# Updates the type mapping within
|
|
392
|
+
# Updates the type mapping within Elasticsearch according to the mapping
|
|
393
393
|
# currently specified. Raises SearchFlip::ResponseError in case any
|
|
394
394
|
# errors occur.
|
|
395
395
|
|
|
@@ -401,7 +401,7 @@ module SearchFlip
|
|
|
401
401
|
end
|
|
402
402
|
end
|
|
403
403
|
|
|
404
|
-
# Retrieves the current type mapping from
|
|
404
|
+
# Retrieves the current type mapping from Elasticsearch. Raises
|
|
405
405
|
# SearchFlip::ResponseError in case any errors occur.
|
|
406
406
|
#
|
|
407
407
|
# @return [Hash] The current type mapping
|
|
@@ -424,7 +424,7 @@ module SearchFlip
|
|
|
424
424
|
type_name != "_doc" || connection.version.to_i < 7
|
|
425
425
|
end
|
|
426
426
|
|
|
427
|
-
# Retrieves the document specified by id from
|
|
427
|
+
# Retrieves the document specified by id from Elasticsearch. Raises
|
|
428
428
|
# SearchFlip::ResponseError specific exceptions in case any errors
|
|
429
429
|
# occur.
|
|
430
430
|
#
|
|
@@ -457,7 +457,7 @@ module SearchFlip
|
|
|
457
457
|
connection.http_client.headers(accept: "application/json").post("#{type_url}/_mget", json: request, params: params).parse
|
|
458
458
|
end
|
|
459
459
|
|
|
460
|
-
# Sends an analyze request to
|
|
460
|
+
# Sends an analyze request to Elasticsearch. Raises
|
|
461
461
|
# SearchFlip::ResponseError in case any errors occur.
|
|
462
462
|
#
|
|
463
463
|
# @example
|
|
@@ -469,7 +469,7 @@ module SearchFlip
|
|
|
469
469
|
connection.http_client.headers(accept: "application/json").post("#{index_url}/_analyze", json: request, params: params).parse
|
|
470
470
|
end
|
|
471
471
|
|
|
472
|
-
# Sends a index refresh request to
|
|
472
|
+
# Sends a index refresh request to Elasticsearch. Raises
|
|
473
473
|
# SearchFlip::ResponseError in case any errors occur.
|
|
474
474
|
|
|
475
475
|
def refresh
|
|
@@ -487,7 +487,7 @@ module SearchFlip
|
|
|
487
487
|
|
|
488
488
|
# Indexes the given record set, array of records or individual record. A
|
|
489
489
|
# record set usually is an ActiveRecord::Relation, but can be any other
|
|
490
|
-
# ORM as well. Uses the
|
|
490
|
+
# ORM as well. Uses the Elasticsearch bulk API no matter what is
|
|
491
491
|
# provided. Refreshes the index if auto_refresh is enabled. Raises
|
|
492
492
|
# SearchFlip::ResponseError in case any errors occur.
|
|
493
493
|
#
|
|
@@ -525,9 +525,9 @@ module SearchFlip
|
|
|
525
525
|
end
|
|
526
526
|
|
|
527
527
|
# Indexes the given record set, array of records or individual record
|
|
528
|
-
# using
|
|
528
|
+
# using Elasticsearch's create operation via the Bulk API, such that the
|
|
529
529
|
# request will fail if a record with a particular primary key already
|
|
530
|
-
# exists in
|
|
530
|
+
# exists in Elasticsearch.
|
|
531
531
|
#
|
|
532
532
|
# @see #index See #index for more details regarding available
|
|
533
533
|
# params and return values
|
|
@@ -543,9 +543,9 @@ module SearchFlip
|
|
|
543
543
|
end
|
|
544
544
|
|
|
545
545
|
# Indexes the given record set, array of records or individual record
|
|
546
|
-
# using
|
|
546
|
+
# using Elasticsearch's update operation via the Bulk API, such that the
|
|
547
547
|
# request will fail if a record you want to update does not already exist
|
|
548
|
-
# in
|
|
548
|
+
# in Elasticsearch.
|
|
549
549
|
#
|
|
550
550
|
# @see #index See #index for more details regarding available
|
|
551
551
|
# params and return values
|
|
@@ -561,7 +561,7 @@ module SearchFlip
|
|
|
561
561
|
end
|
|
562
562
|
|
|
563
563
|
# Deletes the given record set, array of records or individual record
|
|
564
|
-
# from
|
|
564
|
+
# from Elasticsearch using the Bulk API.
|
|
565
565
|
#
|
|
566
566
|
# @see #index See #index for more details regarding available
|
|
567
567
|
# params and return values
|
|
@@ -615,19 +615,19 @@ module SearchFlip
|
|
|
615
615
|
refresh if SearchFlip::Config[:auto_refresh]
|
|
616
616
|
end
|
|
617
617
|
|
|
618
|
-
# Returns the full
|
|
618
|
+
# Returns the full Elasticsearch type URL, ie base URL, index name with
|
|
619
619
|
# prefix and type name.
|
|
620
620
|
#
|
|
621
|
-
# @return [String] The
|
|
621
|
+
# @return [String] The Elasticsearch type URL
|
|
622
622
|
|
|
623
623
|
def type_url
|
|
624
624
|
connection.type_url(index_name_with_prefix, type_name)
|
|
625
625
|
end
|
|
626
626
|
|
|
627
|
-
# Returns the
|
|
627
|
+
# Returns the Elasticsearch index URL, ie base URL and index name with
|
|
628
628
|
# prefix.
|
|
629
629
|
#
|
|
630
|
-
# @return [String] The
|
|
630
|
+
# @return [String] The Elasticsearch index URL
|
|
631
631
|
|
|
632
632
|
def index_url
|
|
633
633
|
connection.index_url(index_name_with_prefix)
|