XPCegeka / ElasticUp

Easy ElasticSearch migrations for continuous delivery!
MIT License
8 stars 3 forks source link

Method not found:vget_Records() #20

Open tigerhaolu727 opened 6 years ago

tigerhaolu727 commented 6 years ago

When I was trying to use ElasticUp to run Migrations, I got the following error:

Method not found: 'System.Collections.Generic.IEnumerable1<!0> Nest.ICatResponse1.get_Records()'.

I am using 1.1.65, is that possible anyone can tell me what is wrong with it?

The following is the stacktrace:

at ElasticUp.History.MigrationHistoryHelper.InitMigrationHistory() at ElasticUp.ElasticUp.Run() at Unibet.BetHistory.ElasticSearchMigration.Service.Program.Main(String[] args) in D:\Bitbucket\unibet-bet-history\src\Unibet.BetHistory.ElasticSearchMigration.Service\Program.cs:line 25 at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart()

tomboon commented 6 years ago

Hi!

thanks for logging an issue.

Your stacktrace indicates a problem the method in "InitMigrationHistory". This method checks if the "MigrationHistory" index already exists, and if not initializes it.

The failing code is a purely a call to ElasticSearch using the NEST library. The fact that you get a "Method not found" exception makes us suspect you may be using a newer (or much older version) of the NEST package that does not support this method anymore.

We are using ElasticUp successfully in our current project using ElasticSearch.net 2.5.4 and NEST 2.5.4 against ElasticSearch 2.3.5.

Can you tell us

This way we can try to reproduce and fix your problem.

Regards

tigerhaolu727 commented 6 years ago

@tomboon thanks for replying my question. I am using NEST 5.4 and ElasticSearch.Net 5.4. Version for ElasticSearch is 5.4.3. I am starting a new project which is based on elastic search, so everything is using the latest version. Just ask for a favor, when do you think it can be done? Thanks a lot.

tomboon commented 6 years ago

@tigerhaolu727 we will try to fix this in the next few days. We'll update this issue as soon as we have an update. We hope this does not delay you too much.

As a sidenote: as mentioned above we have not yet used ElasticUp with Elastic/Nest 5.x. If you run into any other issues, please let us know. We hope to upgrade our own project using ElasticSearch to 5.x by the end of this year, so ElasticUp will definitely run correctly against 5.x in the future.

tomboon commented 6 years ago

@tigerhaolu727 we have investigated the issue. It seems there are multiple changes to NEST 5.x that are not compatible with 2.x. This means we cannot simply make 1 version of ElasticUp that is compatible with both NEST 2.x and 5.x (and by extension with ElasticSearch 2.x and 5.x).

We need to change our development process and release versions of ElasticUp with the same versioning as Nest and ElasticSearch. (Meaning ElasticUp 2.3.x will be compatible with Nest and ElasticSearch 2.3.x and ElasticUp 5.4.x will be compatible with Nest and ElasticSearch 5.4 and so on).

However, this will take a bit longer to implement compared to just fixing and releasing 1 bug. We will try to implement this as soon as possible and when our project planning allows. This may take several weeks.

Unfortunately this means that "for now", ElasticUp is not compatible with Nest/ElasticSearch 5.x. We will try to give updates on this topic as soon as possible.

tigerhaolu727 commented 6 years ago

@tomboon Thanks a lot for letting me know, I have folked ElasticUp locally and upgrade to NEST 5.X. I realized there were breaking changes between NEST 2.X and 5.X. I manually fixed the compilation errors and verified it is actually working with ElasticSearch 5.X now. Just want to confirm one thing, with new NEST client I have to manually create the target index that I try to migrate to. Code as below:

public class Migration_001_InitialIndexAlias : ElasticUpVersionedIndexMigration { ...... protected override void DefineOperations() { this.Operation( new CreateIndexOperation(this.ToIndexName)) } ........... }

Was the same operation need to be done with NEST 2.4?

I can continue with my project for now. Once you guys have upgraded to NEST 5.X, I will update my nuget package.

Thanks a lot for creating such a good framework. Once I have finish my project, I will look forward to contribute the ElasticUp if you guys are open for pull requests from public contributors.

:)

tomboon commented 6 years ago

@tigerhaolu727 Thanks for your feedback. Great work making it work with 5.X! We are definitely open for pull requests from public contributors. We will do our best to make the changes mentioned above as soon as possible, as we would like to upgrade our own project using ElasticUp to 5.X too.

As for your question about the CreateIndexOperation, some thoughts:

ElasticSearch 2.X itself can be configured to allow or disallow automatic creation of indices.

In our own project we found it best practice to always add a CreateIndexOperation explicitely before doing a ReindexOperation or BatchUpdateOperation. Two reasons for this:

  1. First, we always work with versioned indices. Meaning if we want to Reindex my-index-2 (with alias my-index) we have a few operations: CreateIndexOperation to create my-index-3, BatchUpdateOperation from my-index-2 to my-index-3, SwitchAliasOperation to delete the alias my-index from my-index-2 and put it on my-index-3, DeleteIndexOperation to delete the old index.

  2. Second, we also consider it a best practice to explicitily set a Mapping for your Index, even if you don't have any mappings differing from the defaults (e.g. NOT_ANALYZED). You can create mappings using the Nest attributes on your model and passing a Func<MappingsDescriptor, IPromise>into the CreateIndexOperatoin using Nests' AutoMap method. You can pass this Mapping func into the CreateIndexOperation.

Again, thank you for your enthusiasm for ElasticUp. We hope to hear more from you. We are always open for suggestions.

tomboon commented 6 years ago

I just remembered that because of the reasons mentioned above, we added a check at the start of the Reindex and BatchUpdateOperations that the source and target index should exist before the operation starts executing.

If you check the Reindex and BatchUpdateOperation - Validate method you can see the checks.

tigerhaolu727 commented 6 years ago

@tomboon I am trying to fork elastic up and upgrade it to 5.X NEST, I realize the existing tests was based on the elastic service in the test resource folder and there are two plugins delete by query and head, just want to ask how possibly I can upgrade the elasticsearch service in the resource folder to 5.X. Thanks a lot.

tomboon commented 6 years ago

@tigerhaolu727 ElasticUp runs its integration tests by starting an instance of ElasticSearch on port 9201. As you already found out, it unzips and runs ElasticSearch from a Resource file.

The Easiest way to start using ElasticSearch 5.X in the tests is:

  1. download and unzip ElasticSearch 5.X somewhere

  2. set the correct configuration in config/elasticsearch.yml We have 2 settings in the 2.X ElasticSearch:

  3. create zip archive of your ElasticSearch 5.X directory

  4. put the zip archive in the Resources directory of ElasticUp.Tests and add it as a resource in Resources.resx

  5. Configure the class ElasticUpTestConfig to use that resource instead of the old one (around line 25).

That should do it! Good luck.

tigerhaolu727 commented 6 years ago

@tomboon Thanks a lot for your hints. I finally got all tests passed on ElasticSearch 5.5 with a few adjustments. You guys are doing a great job. I will continue on my journey to use the ElasticUp. Thanks again.

edoua commented 6 years ago

@tigerhaolu727 would it be possible for you to make the fork public so we could use your forked version until ElasticUp officially support newer version of ElasticSearch? That would be super helpful. Ended up having the same problem.