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

Move data type from string to text to be compatibel with ES 5.1 #649

Closed
wants to merge 1 commit into from

Conversation

jalberto
Copy link
Contributor

No description provided.

@karmi
Copy link
Contributor

karmi commented Dec 19, 2016

Hi @jalberto, thanks for the patch! I'm afraid the codebase, and especially the examples will need much more updates to be compatible with 5.x, and I have to set up some branches and versioning scheme for that. Would you be up for going over more places in the codebase? I've run the integration tests for elasticsearch-model against 5.x now, and there's just errors related to multi_field, but I think there'll be more.

@jalberto
Copy link
Contributor Author

jalberto commented Dec 19, 2016

@karmi I started to do so but I found several issues relates to mappings (the text/keyword thing & the properties keyword is not supported) I am afraid there will be more changes as you point out.

I am afraid this will require a deeper change so this not happens again in next versions (probably 1st step will be to remove virtus and add a DSL for ActiveRecord pattern).
Thinking in all this changes I wonder if is not better just to deprecate ActiveRecord pattern in favour of repository pattern (as it allows more flexibility for changes)

I find the AR pattern confusing & error prune as ES cannot be used as an regular AR DB (thinking in PG, mongo, etc) as you cannot have migrations, some changes requires reindexing, etc

Another option would e to implement the persistence layer using dry-rb, it's flexible enough to use for both, the repository and AR patterns.

@karmi
Copy link
Contributor

karmi commented Feb 11, 2017

So, I've spent couple of days last week fixing the Rails application templates for the ActiveRecord integration, and while it's time-consuming to verify and double-check everything, the changes are relatively straightforward.

I guess it will be a bit harder for the elasticsearch-persistence examples, but mostly similar.

This change, from string to text is pretty straightforward, and I'll have to do a similar change in the indexes method.

Thinking in all this changes I wonder if is not better just to deprecate ActiveRecord pattern in favour of repository pattern (as it allows more flexibility for changes).

It's a very interesting idea. In my experience, the ActiveRecord pattern is indeed confusing and error-prone, not so much because of the Elasticsearch layer, but because of subtle problems and insufficient implementations in the elasticsearch-persistence gem. When I consider the issues and patches for this project, most are connected to the ActiveRecord pattern in one way or another, eating resources which could be spent on other parts of the library. And I definitely agree that the Repository pattern is much more easy to develop in the library, and arguably easier to use in application code. I'll think about it.

@karmi karmi closed this in 757c57a Feb 11, 2017
@jalberto
Copy link
Contributor Author

Thansk for your work @karmi

I already moved my projects to repository pattern, it required a small refactor, but was quite stright forward.
I suggest to promote the repository pattern as the recommended one, the lexx people using the AR pattern the better :)

is indeed confusing and error-prone, not so much because of the Elasticsearch layer

Is not because the layer, but in how different ES. Providing an AR pattern that lacks some of the behavious AR users expect is very error prone.

karmi added a commit that referenced this pull request Feb 12, 2017
The default type for properties defined with the `indexes` method
has been changed to the `text` field type.

Also, fixed the integration test to have the correct mapping
and to use the `bool` query instead of the old `filtered` query.

See:

* https://www.elastic.co/guide/en/elasticsearch/reference/current/string.html
* https://www.elastic.co/guide/en/elasticsearch/reference/current/text.html

Related: #649
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants