glynnbird / couchmigrate

CouchDB command-line design document migration tool
Apache License 2.0
13 stars 9 forks source link

Cloudant search indexes support #7

Open papahmsolo opened 6 years ago

papahmsolo commented 6 years ago

Does couchmigrate work with Cloudant search indexes? As I can see form the code, when migrating design docs with views, couchmigrate wait until the view is completely built. According to Cloudant docs: https://console.bluemix.net/docs/services/Cloudant/guides/design_document_management.html#multiple-views-in-the-same-design-document

Note: This behaviour does not apply to Lucene search indexes. They can be altered within the same design document without invalidating other unchanged indexes in the same document.

So my question is: would couchmigrate support search indexes migration out of the box? Or respective code should be added to check whether search index is completely built, in order to safely migrate search index? I know this tool is couchmigrate, not cloudantmigrate :slightly_smiling_face:, but I'm curious to know this as I'm using it for deployments to Cloudant. Thanks!

glynnbird commented 6 years ago

The way it works at the moment is that it puts your design document into Cloudant the queries the first view (MapReduce) view to see if indexing is complete. If you only have Cloudant search views then you'll get an error (as your previous issue stated). If you have a mix of MapReduce and Search, then it'll only check the MapReduce view, but that should be a good indicator that all the views in the design document are built.

You could add a dummy MapReduce view that never emits anything?

{
   views: {
       dummy: {
           map: "function(doc) { }",
        } 
   }
   ...
}

?

papahmsolo commented 6 years ago

We tend to separate views and search indexes and store them in the different design docs. So I'm trying to understand whether couchmigrate gonna work with design docs that have only search indexes and no views in it and deploy it safely according to "Move and Switch" strategy or I'll need to patch couchmigrate for that.

Yes, adding dummy view could do the trick, but it's a little bit 'ugly'. I'm storing all the design docs formatted under version control and export them as modules so I'd rather not add any redundant code to the repository.

Thanks for replying, I appreciate it!

glynnbird commented 6 years ago

It should be possible to do the same trick with only search indicies but it would require a change to couchmigrate. If you patch before I do, a PR would be appreciated ;)