Search: remove reliance upon ruby gem
Problem to solve
We are currently locked to a specific gem version for Elasticsearch.
Proposal
Refactor search so that it does not need to utilize the ruby gem for search, count and retrieval from database/gitaly operations.
Initial idea:
- search
- records
- count
- use any client
Each indexed document needs to provide a translation method to go from Elasticsearch (or search backend) to data object for display (database record or other PORO). Similar to how indexing works (translation from data to indexed json)
# frozen_string_literal: true
module Search
module Elastic
module Search
def initialize(client)
@client = client
end
def search(index, query, options = {})
end
def count(index, query, options = {})
end
def records
end
private
attr_reader :client
end
end
end
Translation layer between rails and Elasticsearch:
indexing: record -> reference -> ES document
searching: ES document -> reference -> record
But we would also support non-ActiveRecord references.
indexing: arbitrary data -> reference -> ES document
searching: ES document -> reference -> arbitrary data