@@ -80,7 +80,7 @@ def get_task_status(index_name, task_id, opts = {})
80
80
end
81
81
82
82
# # # # # # # # # # # # # # # # # # # # #
83
- # MISC
83
+ # INDEX METHODS
84
84
# # # # # # # # # # # # # # # # # # # # #
85
85
86
86
# Initialize an index with a given name
@@ -594,12 +594,185 @@ def pending_mappings?(opts = {})
594
594
@transporter . read ( :GET , '/1/clusters/mapping/pending' + handle_params ( { getClusters : retrieve_mappings } ) , { } , request_options )
595
595
end
596
596
597
- #
598
597
# Aliases the pending_mappings? method
599
598
#
600
599
alias_method :has_pending_mappings , :pending_mappings?
601
600
601
+ # # # # # # # # # # # # # # # # # # # # #
602
+ # CUSTOM DICTIONARIES METHODS
603
+ # # # # # # # # # # # # # # # # # # # # #
604
+
605
+ # Save entries for a given dictionary
606
+ #
607
+ # @param dictionary [String] dictionary name. Can be either 'stopwords', 'plurals' or 'compounds'
608
+ # @param dictionary_entries [Array<Hash>] array of dictionary entries
609
+ # @param opts [Hash] contains extra parameters to send with your query
610
+ #
611
+ # @return DictionaryResponse
612
+ #
613
+ def save_dictionary_entries ( dictionary , dictionary_entries , opts = { } )
614
+ response = @transporter . write (
615
+ :POST ,
616
+ path_encode ( '/1/dictionaries/%s/batch' , dictionary ) ,
617
+ { clearExistingDictionaryEntries : false , requests : chunk ( 'addEntry' , dictionary_entries ) } ,
618
+ opts
619
+ )
620
+
621
+ DictionaryResponse . new ( self , response )
622
+ end
623
+
624
+ # Save entries for a given dictionary and wait for the task to finish
625
+ #
626
+ # @param dictionary [String] dictionary name. Can be either 'stopwords', 'plurals' or 'compounds'
627
+ # @param dictionary_entries [Array<Hash>] array of dictionary entries
628
+ # @param opts [Hash] contains extra parameters to send with your query
629
+ #
630
+ def save_dictionary_entries! ( dictionary , dictionary_entries , opts = { } )
631
+ response = save_dictionary_entries ( dictionary , dictionary_entries , opts )
632
+
633
+ response . wait ( opts )
634
+ end
635
+
636
+ # Replace entries for a given dictionary
637
+ #
638
+ # @param dictionary [String] dictionary name. Can be either 'stopwords', 'plurals' or 'compounds'
639
+ # @param dictionary_entries [Array<Hash>] array of dictionary entries
640
+ # @param opts [Hash] contains extra parameters to send with your query
641
+ #
642
+ # @return DictionaryResponse
643
+ #
644
+ def replace_dictionary_entries ( dictionary , dictionary_entries , opts = { } )
645
+ response = @transporter . write (
646
+ :POST ,
647
+ path_encode ( '/1/dictionaries/%s/batch' , dictionary ) ,
648
+ { clearExistingDictionaryEntries : true , requests : chunk ( 'addEntry' , dictionary_entries ) } ,
649
+ opts
650
+ )
651
+
652
+ DictionaryResponse . new ( self , response )
653
+ end
654
+
655
+ # Replace entries for a given dictionary and wait for the task to finish
656
+ #
657
+ # @param dictionary [String] dictionary name. Can be either 'stopwords', 'plurals' or 'compounds'
658
+ # @param dictionary_entries [Array<Hash>] array of dictionary entries
659
+ # @param opts [Hash] contains extra parameters to send with your query
660
+ #
661
+ def replace_dictionary_entries! ( dictionary , dictionary_entries , opts = { } )
662
+ response = replace_dictionary_entries ( dictionary , dictionary_entries , opts )
663
+
664
+ response . wait ( opts )
665
+ end
666
+
667
+ # Delete entries for a given dictionary
668
+ #
669
+ # @param dictionary [String] dictionary name. Can be either 'stopwords', 'plurals' or 'compounds'
670
+ # @param object_ids [Array<Hash>] array of object ids
671
+ # @param opts [Hash] contains extra parameters to send with your query
672
+ #
673
+ # @return DictionaryResponse
674
+ #
675
+ def delete_dictionary_entries ( dictionary , object_ids , opts = { } )
676
+ request = object_ids . map do |object_id |
677
+ { objectID : object_id }
678
+ end
679
+ response = @transporter . write (
680
+ :POST ,
681
+ path_encode ( '/1/dictionaries/%s/batch' , dictionary ) ,
682
+ { clearExistingDictionaryEntries : false , requests : chunk ( 'deleteEntry' , request ) } ,
683
+ opts
684
+ )
685
+
686
+ DictionaryResponse . new ( self , response )
687
+ end
688
+
689
+ # Delete entries for a given dictionary and wait for the task to finish
690
+ #
691
+ # @param dictionary [String] dictionary name. Can be either 'stopwords', 'plurals' or 'compounds'
692
+ # @param object_ids [Array<Hash>] array of object ids
693
+ # @param opts [Hash] contains extra parameters to send with your query
602
694
#
695
+ def delete_dictionary_entries! ( dictionary , object_ids , opts = { } )
696
+ response = delete_dictionary_entries ( dictionary , object_ids , opts )
697
+
698
+ response . wait ( opts )
699
+ end
700
+
701
+ # Clear all entries for a given dictionary
702
+ #
703
+ # @param dictionary [String] dictionary name. Can be either 'stopwords', 'plurals' or 'compounds'
704
+ # @param opts [Hash] contains extra parameters to send with your query
705
+ #
706
+ # @return DictionaryResponse
707
+ #
708
+ def clear_dictionary_entries ( dictionary , opts = { } )
709
+ replace_dictionary_entries ( dictionary , [ ] , opts )
710
+ end
711
+
712
+ # Clear all entries for a given dictionary and wait for the task to finish
713
+ #
714
+ # @param dictionary [String] dictionary name. Can be either 'stopwords', 'plurals' or 'compounds'
715
+ # @param opts [Hash] contains extra parameters to send with your query
716
+ #
717
+ def clear_dictionary_entries! ( dictionary , opts = { } )
718
+ response = replace_dictionary_entries ( dictionary , [ ] , opts )
719
+
720
+ response . wait ( opts )
721
+ end
722
+
723
+ # Search entries for a given dictionary
724
+ #
725
+ # @param dictionary [String] dictionary name. Can be either 'stopwords', 'plurals' or 'compounds'
726
+ # @param query [String] query to send
727
+ # @param opts [Hash] contains extra parameters to send with your query
728
+ #
729
+ def search_dictionary_entries ( dictionary , query , opts = { } )
730
+ @transporter . read (
731
+ :POST ,
732
+ path_encode ( '/1/dictionaries/%s/search' , dictionary ) ,
733
+ { query : query } ,
734
+ opts
735
+ )
736
+ end
737
+
738
+ # Set settings for all the dictionaries
739
+ #
740
+ # @param dictionary_settings [Hash]
741
+ # @param opts [Hash] contains extra parameters to send with your query
742
+ #
743
+ # @return DictionaryResponse
744
+ #
745
+ def set_dictionary_settings ( dictionary_settings , opts = { } )
746
+ response = @transporter . write ( :PUT , '/1/dictionaries/*/settings' , dictionary_settings , opts )
747
+
748
+ DictionaryResponse . new ( self , response )
749
+ end
750
+
751
+ # Set settings for all the dictionaries and wait for the task to finish
752
+ #
753
+ # @param dictionary_settings [Hash]
754
+ # @param opts [Hash] contains extra parameters to send with your query
755
+ #
756
+ # @return DictionaryResponse
757
+ #
758
+ def set_dictionary_settings! ( dictionary_settings , opts = { } )
759
+ response = set_dictionary_settings ( dictionary_settings , opts )
760
+
761
+ response . wait ( opts )
762
+ end
763
+
764
+ # Retrieve settings for all the dictionaries
765
+ #
766
+ # @param opts [Hash] contains extra parameters to send with your query
767
+ #
768
+ def get_dictionary_settings ( opts = { } )
769
+ @transporter . read ( :GET , '/1/dictionaries/*/settings' , { } , opts )
770
+ end
771
+
772
+ # # # # # # # # # # # # # # # # # # # # #
773
+ # MISC METHODS
774
+ # # # # # # # # # # # # # # # # # # # # #
775
+
603
776
# Method available to make custom requests to the API
604
777
#
605
778
def custom_request ( data , uri , method , call_type , opts = { } )
0 commit comments