Class: Marqo::Index
- Inherits:
-
Object
- Object
- Marqo::Index
- Defined in:
- lib/marqo/index.rb
Class Method Summary collapse
- .create(endpoint, index_name, options = {}) ⇒ Object
- .delete(endpoint, index_name) ⇒ Object
- .health(endpoint, index_name) ⇒ Object
- .list(endpoint) ⇒ Object
- .refresh(endpoint, index_name) ⇒ Object
Class Method Details
.create(endpoint, index_name, options = {}) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/marqo/index.rb', line 17 def create(endpoint, index_name, = {}) # valid options - default value # - index_defaults: "" # - number_of_shards: 3 # - number_of_replicas: 0 # more detail see in url https://docs.marqo.ai/1.2.0/API-Reference/indexes/ # example # { # "index_defaults": { # "treat_urls_and_pointers_as_images": false, # "model": "hf/all_datasets_v4_MiniLM-L6", # "normalize_embeddings": true, # "text_preprocessing": { # "split_length": 2, # "split_overlap": 0, # "split_method": "sentence" # }, # "image_preprocessing": { # "patch_method": null # }, # "ann_parameters" : { # "space_type": "cosinesimil", # "parameters": { # "ef_construction": 128, # "m": 16 # } # } # }, # "number_of_shards": 3, # "number_of_replicas": 0 # } url = Marqo::UrlHelpers.create_index_endpoint(endpoint, index_name) http = Net::HTTP.new(url.host, url.port) http.use_ssl = url.scheme == "https" request = Net::HTTP::Post.new(url) request['Content-type'] = 'application/json' request.body = JSON.dump() unless .empty? http.request(request) end |
.delete(endpoint, index_name) ⇒ Object
60 61 62 63 64 65 66 67 |
# File 'lib/marqo/index.rb', line 60 def delete(endpoint, index_name) url = Marqo::UrlHelpers.delete_index_endpoint(endpoint, index_name) http = Net::HTTP.new(url.host, url.port) http.use_ssl = url.scheme == "https" request = Net::HTTP::Delete.new(url) http.request(request) end |
.health(endpoint, index_name) ⇒ Object
80 81 82 83 84 85 86 87 |
# File 'lib/marqo/index.rb', line 80 def health(endpoint, index_name) url = Marqo::UrlHelpers.health_endpoint(endpoint, index_name) http = Net::HTTP.new(url.host, url.port) http.use_ssl = url.scheme == "https" request = Net::HTTP::Get.new(url) http.request(request) end |
.list(endpoint) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/marqo/index.rb', line 7 def list(endpoint) url = Marqo::UrlHelpers.index_endpoint(endpoint) http = Net::HTTP.new(url.host, url.port) http.use_ssl = url.scheme == "https" request = Net::HTTP::Get.new(url) http.request(request) end |
.refresh(endpoint, index_name) ⇒ Object
70 71 72 73 74 75 76 77 |
# File 'lib/marqo/index.rb', line 70 def refresh(endpoint, index_name) url = Marqo::UrlHelpers.refresh_endpoint(endpoint, index_name) http = Net::HTTP.new(url.host, url.port) http.use_ssl = url.scheme == "https" request = Net::HTTP::Post.new(url) http.request(request) end |