Skip to content

Update Index documents methods #621

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions lib/meilisearch/index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ def set_base_properties(index_hash)

### DOCUMENTS

def document(document_id, fields: nil)
def document(document_id, fields: nil, retrieve_vectors: false)
encode_document = URI.encode_www_form_component(document_id)
body = { fields: fields&.join(',') }.compact
body = { fields: fields&.join(','), retrieveVectors: retrieve_vectors }.compact

http_get("/indexes/#{@uid}/documents/#{encode_document}", body)
end
Expand All @@ -73,16 +73,11 @@ def document(document_id, fields: nil)
# :fields - Array of document attributes to show (optional).
# :filter - Filter queries by an attribute's value.
# Available ONLY with Meilisearch v1.2 and newer (optional).
# :retrieve_vectors - Return document vector data with search result (optional).
#
# Returns the documents results object.
def documents(options = {})
Utils.version_error_handler(__method__) do
if options.key?(:filter)
http_post "/indexes/#{@uid}/documents/fetch", Utils.filter(options, [:limit, :offset, :fields, :filter])
else
http_get "/indexes/#{@uid}/documents", Utils.parse_query(options, [:limit, :offset, :fields])
end
end
http_post "/indexes/#{@uid}/documents/fetch", Utils.filter(options, [:limit, :offset, :fields, :filter, :retrieve_vectors])
end
alias get_documents documents

Expand Down