feliperazeek/playframework-elasticsearch

Be able to control field mappings

Closed this issue · 9 comments

Currently all fields are mapped as is, setting just a basic type. It would be really nice if I were able to control other mappings as well, e.g. setting index=not_analysed. This is especially useful for a local client in a dev/test environment.

I suppose you created the @ElasticSearchField annotation with that purpose in mind?

That's exactly why I created that annotation.

I'm currently thinking of a clean way to do this. When these settings change after the index was created, the index needs to be updated. Since this could be a potentially time-consuming operation for ElasticSearch (haven't tested it on a sufficiently sized dataset yet), I'll probably add a function to ElasticSearch called updateMapping(Class) which allows you to control when to update the mapping.

Of course this only applies for changes to an existing index. Using the settings on index creation should not be a problem.

Ok, I've got some code locally which employs a ModelMapper and FieldMapper interface with matching implementations. Those classes control the mapping from the model to the index mapping and model-to-document translation.

Felipe: what's the best way to proceed? I can push the changes to my fork but the code is not necessarily ready for inclusion in the main branch.

Just create a branch, git branch mapper or you can add to the main branch if you think it won't break anything not the main branch. Dude you are a rock star!

Let's first see how my pull + push based on your merge of #8 turns out before I start doing more complex things with git haha.

I am writing some unit tests to test the new mapping code I've written. That way we have a baseline for "it works as expected". I am also coding it in such a way that the behavior will be the same as before. It would be great if you add some more unit tests for the mapping code later on, based on your own use-cases.

I will do it, I am actually working with a client now. I am working out some legal issues with it for some code I would like to backport to the open source module.

Ok, please have a look at my mapping branch. I have just commited my initial version of mapping support and some basic mapping tests.

Todo:

  • write tests for object->document mapping, now only index creation mapping is tested.
  • update ElasticSearchAdapter and ElasticSearchPlugin to use the new mapping code

cool let me check it out

This is now possible from release 0.3 and onwards