Reputation: 7220
In my Rails 7.0.1 app with Ruby 3.0.3 I get this error when performing a search with SearchKick:
19:13:13 web.1 | Started GET "/search?q=nemesis" for ::1 at 2022-01-24 19:13:13 +0000 19:13:13 web.1 | Processing by SearchController#index as HTML 19:13:13 web.1 | Parameters: {"q"=>"nemesis"} 19:13:13 web.1 | Completed 500 Internal Server Error in 32ms (ActiveRecord: 0.0ms | Allocations: 4163) 19:13:13 web.1 | 19:13:13 web.1 | 19:13:13 web.1 | 19:13:13 web.1 | Faraday::ConnectionFailed (end of file reached): 19:13:13 web.1 | 19:13:13 web.1 | app/controllers/search_controller.rb:20:in `index'
My controller for search looks like:
class SearchController < ApplicationController
def index
if params[:q].present?
query_string = ActiveSupport::Inflector.transliterate(params[:q]).gsub('/', '\\/')
type = params[:type]
where = {}
if type
where[:type] = type
end
@results = Searchkick.search query_string, models: [Coaster, Park, Ride, Album], where: where, aggs: [:type], misspellings: {edit_distance: 1}, match: :word_start, load: true
if @results.count == 1
result = @results.first
if result.class.to_s.underscore.downcase == 'coaster'
redirect_to park_coaster_path(result.park, result)
end
if result.class.to_s.underscore.downcase == 'park'
redirect_to park_path(result)
end
end
end
end
end
I'm running OpenSearch in Docker and the entry for it in my Docker Compose file is:
search:
image: 'opensearchproject/opensearch:1.2.4'
restart: always
env_file:
- .env
environment: # https://opensearch.org/docs/latest/opensearch/install/docker/#sample-docker-compose-file-for-development
- cluster.name=opensearch-cluster
- node.name=opensearch-node1
- bootstrap.memory_lock=true # along with the memlock settings below, disables swapping
- "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m" # minimum and maximum Java heap size, recommend setting both to 50% of system RAM
- "DISABLE_INSTALL_DEMO_CONFIG=true" # disables execution of install_demo_configuration.sh bundled with security plugin, which installs demo certificates and security configurations to OpenSearch
- "DISABLE_SECURITY_PLUGIN=true" # disables security plugin entirely in OpenSearch by setting plugins.security.disabled: true in opensearch.yml
- "discovery.type=single-node" # disables bootstrap checks that are enabled when network.host is set to a non-loopback address
volumes:
- search-volume:/usr/share/opensearch/data:rw,delegated
ports:
- '9200:9200'
Any suggestions?
Upvotes: 3
Views: 369