Sha256: 05bb20f665fd65735000c49a2cbbd2eaf06d5cc967608268a2523b74f862d9ce

Contents?: true

Size: 1.77 KB

Versions: 6

Compression:

Stored size: 1.77 KB

Contents

# Licensed to Elasticsearch B.V. under one or more contributor
# license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright
# ownership. Elasticsearch B.V. licenses this file to you under
# the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.

# frozen_string_literal: true

require_relative './api_spec_helper'

describe Elastic::EnterpriseSearch::AppSearch::Client do
  let(:engine_name) { 'books' }

  context 'single search' do
    it 'performs a single query search' do
      VCR.use_cassette('app_search/single_query_search') do
        response = @client.search(engine_name, query: 'Herman')
        expect(response.status).to eq 200
        expect(response.body).not_to be nil
        expect(response.body['results'].count).to be > 1
      end
    end
  end

  context 'multi query search' do
    it 'performs a multi query search' do
      VCR.use_cassette('app_search/multi_query_search') do
        response = @client.multi_search('books', body: [{ query: 'Herman' }, { query: 'Edgar' }])
        expect(response.status).to eq 200
        expect(response.body.class).to be Array
        expect(response.body.count).to be 2
        expect(response.body[0]['results']).to_not be nil
        expect(response.body[1]['results']).to_not be nil
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
elastic-enterprise-search-7.14.1 spec/app-search/api_search_and_multi_search_spec.rb
elastic-enterprise-search-7.14.0 spec/app-search/api_search_and_multi_search_spec.rb
elastic-enterprise-search-7.12.1 spec/app-search/api_search_and_multi_search_spec.rb
elastic-enterprise-search-7.13.0 spec/app-search/api_search_and_multi_search_spec.rb
elastic-enterprise-search-7.13.0.pre spec/app-search/api_search_and_multi_search_spec.rb
elastic-enterprise-search-7.12.0 spec/app-search/api_search_and_multi_search_spec.rb