Elasticsearch works fine in localhost, but gives connection error while testing

243 Views Asked by At

I'm new to Elasticsearch and Docker. I'm getting search results with my application, But when I run test against the same , I'm getting connection error like this

cannot assign requested address - cannot assign requested address - connect(2) for "localhost" port 9200 (localhost:9200)

I'm using chewy gem of ruby on rails to implement Elasticsearch

here is the sample code of search

result = TestIndex::Test
                     .filter(match: { test_id: testid })
                     .query(something
                      })
                     .highlight({something
                                  }
                                })
                   .paginate(page: page, per_page: page_size).as_json

I'm testing using Rspec Note that search is working fine in application. This error occurs when running the test file

0

There are 0 best solutions below