feliperazeek / playframework-elasticsearch

Integrate Elastic Search in a Play! Framework Application. This module uses JPA events to notify Elastic Search of events of their own. It embeds a running Elastic Search instance for Rapid Development.
http://geeks.aretotally.in/play-framework-module-elastic-search-distributed-searching-with-json-http-rest-or-java
84 stars 43 forks source link

Be able to control field mappings #11

Closed rschellhorn closed 13 years ago

rschellhorn commented 13 years ago

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?

feliperazeek commented 13 years ago

That's exactly why I created that annotation.

bgooren commented 13 years ago

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.

bgooren commented 13 years ago

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.

feliperazeek commented 13 years ago

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!

bgooren commented 13 years ago

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.

feliperazeek commented 13 years ago

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.

bgooren commented 13 years ago

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:

feliperazeek commented 13 years ago

cool let me check it out

bgooren commented 13 years ago

This is now possible from release 0.3 and onwards