Skip to content
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

[WIP] Update specs for v6 elasticsearch #67

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: ruby
before_install:
- gem update bundler
- curl -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.1.1.deb && sudo dpkg -i --force-confnew elasticsearch-5.1.1.deb && sudo service elasticsearch restart
- curl -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.6.1.deb && sudo dpkg -i --force-confnew elasticsearch-6.6.1.deb && sudo service elasticsearch restart
rvm:
- 2.2.2
- 2.2.3
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
v0.13.0
- update test to run against 6.6.1
v0.12.0
- warn when configuring a index with subclasses if using ES version that does support them
- raise exception when creating or adding document to an index configured with subclasses if using
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Or install it yourself as:
### Version Support
This gem has [elasticsearch-ruby](https://github.com/elastic/elasticsearch-ruby) as a dependency. In order to use different versions of elasticsearch you will need to match your version of elasticsearch-ruby to the version of elasticsearch you want to use ([see here](https://github.com/elastic/elasticsearch-ruby#compatibility). Elasticity should work across all versions of elastisearch-ruby, although they have not all been tested so there are likely edge cases.

Currently tests are run on travis ci against elasticsearch 5.1.1 with elasticsearch-ruby 5.0.3.
Currently tests are run on travis ci against elasticsearch 6.6.1 with elasticsearch-ruby 5.0.3.

### Configuration

Expand Down
Binary file removed es-elasticity-0.12.0.pre.rc1.gem
Binary file not shown.
2 changes: 1 addition & 1 deletion lib/elasticity/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Elasticity
VERSION = "0.12.0"
VERSION = "0.13.0"
end
82 changes: 0 additions & 82 deletions spec/functional/persistence_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,88 +71,6 @@ def to_document
end
end

describe 'multi mapping index' do
class Animal < Elasticity::Document
configure do |c|
c.index_base_name = "cats_and_dogs"
c.strategy = Elasticity::Strategies::SingleIndex
c.subclasses = { cat: "Cat", dog: "Dog" }
end
end

class Cat < Animal
configure do |c|
c.index_base_name = "cats_and_dogs"
c.strategy = Elasticity::Strategies::SingleIndex
c.document_type = "cat"

c.mapping = { "properties" => {
name: { type: "text", index: true },
age: { type: "integer" }
} }
end

attr_accessor :name, :age

def to_document
{ name: name, age: age }
end
end

class Dog < Animal
configure do |c|
c.index_base_name = "cats_and_dogs"
c.strategy = Elasticity::Strategies::SingleIndex
c.document_type = "dog"
c.mapping = { "properties" => {
name: { type: "text", index: true },
age: { type: "integer" },
hungry: { type: "boolean" }
} }
end
attr_accessor :name, :age, :hungry

def to_document
{ name: name, age: age, hungry: hungry }
end
end

before do
Animal.recreate_index
@elastic_search_client.cluster.health wait_for_status: 'yellow'
end

it "successful index, update, search, count and deletes" do
cat = Cat.new(name: "felix", age: 10)
dog = Dog.new(name: "fido", age: 4, hungry: true)

cat.update
dog.update

Animal.flush_index

results = Animal.search({})
expect(results.total).to eq 2
expect(results.map(&:class)).to include(Cat, Dog)

results = Cat.search({})
expect(results.total).to eq 1
expect(results.first.class).to eq Cat

results = Dog.search({})
expect(results.total).to eq 1
expect(results.first.class).to eq Dog

cat.delete
Animal.flush_index

results = Animal.search({})
expect(results.total).to eq 1
expect(results.map(&:class)).to include(Dog)
expect(results.scan_documents.count).to eq(1)
end
end

describe "alias index strategy" do
subject do
Class.new(Elasticity::Document) do
Expand Down
2 changes: 1 addition & 1 deletion spec/units/strategies/single_index_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
subject.flush

expect { subject.get_document("document", 1) }.to raise_error(Elasticsearch::Transport::Transport::Errors::NotFound)
expect(subject.get_document("document", 2)).to eq({"_index"=>"test_index_name", "_type"=>"document", "_id"=>"2", "_version"=>1, "found"=>true, "_source"=>{"name"=>"bar"}})
expect(subject.get_document("document", 2)).to include({"_index"=>"test_index_name", "_type"=>"document", "_id"=>"2", "_version"=>1, "found"=>true, "_source"=>{"name"=>"bar"}})
end

it "allows deleting by query" do
Expand Down