Blog Posts

Hackday: FOQElasticaBundle and Elastica

 The goal of this hackday, done by Lukas Smith and me, was to adapt the FOQElasticaBundle and the Elastica library so we can use it for one of our current projects. The two main problems were the following:

  • Missing support of the FOQElasticaBundle for nested mapping definitions
  • Missing support of the Elastica library to process objects for indexing

In the following I'm going to explain in more details what the problems were and how we tried to fix them.

Nested mapping definitions

Elasticsearch supports nested field types 'object', 'array' and 'nested' ( As long as we did not want to configure fields in these nested types, i.e. define a specific mapping for them, this was no problem at all. If a field is not defined in the mapping elasticsearch guesses its type and configuration based on the data it gets when creating the index. But in order to get substring mapping and fuzzy search we needed to be able to add a specific mapping for fields in nested types. Now, there was already a pull request adding the possibility to define a mapping for fields in objects and nested types and this pull request got merged into master in the meanwhile. But the changes done there are still not enough for what we need. First of all, the configuration still does not allow to add the 'fields' configuration to the mapping of nested fields. We need this configuration to define fields of type 'multi_field' in the nested types ( To solve this problem quickly and be able to do the index configuration as we need it for our project as quickly as possible we created a first pull request that simply adds the 'fields' configuration option to the accepted configurations for fields in nested types. Secondly, we think that just adding one more level of configuration is a quick fix to our current problem, but what if we need at some point a nested type inside a nested type? So, in a second pull request we changed the Bundle's Configuration class to accept an infinite number of nesting levels. We're not entirely happy with that solution though. E.g. we had to duplicate the code verifying the type of value assigned to a certain configuration, i.e. if it's a scalar or not. Also we couldn't yet figure out how to display the full path of a wrongly typed configuration value in the error message because we're missing the context of the node we're currently looking at. There is already quite some discussion going on on github and hopefully we'll find good/better solution for this problem.

Object processing for indexing

So far, the elastica library just accepts objects of type Elastica_Document to be added to the index. The data property of this object needs to be an array.

For us this meant that we had to do the whole work of putting the properties of our Doctrine entities into an array ourselves. So we thought it would be an improvement to the library if you could configure it to use a serializer and then you can just pass whatever object you want to be indexed and the library takes over the job of serializing the object into the right format, creating the Elastica_Document and adding it to the index. We also added support for serializer groups, used by the JSMSerializerBundle to be able to define which properties of an object should be serialized or excluded from serialization. The pull request is also waiting to be merged at the moment.

If you have any feedback/ideas on any of these pull requests please don't hesitate to enter the discussion on github.

About the author

Comments [16]

paulrodgers, 20.02.2013 22:43 CEST

It's an ongoing quest within an organization to help discover the location, ownership, value and use of knowledge artifacts, to learn the roles and expertise of people, to identify constraints to the flow of knowledge, and to highlight opportunities to leverage existing knowledge. hotel in Oceanside

maxwell, 20.02.2013 22:48 CEST

Knowledge mapping is about making knowledge that is available within an organisation transparent, and is about providing the insights into its quality. classic car restoration san diego

bernardbert, 11.11.2013 14:49 CEST

Herbalcost Organic & Natural products The best source for organic foods, supplements, health foods, vitamins . Your Organic food store with over 12000 items.

James anderson, 13.11.2013 07:42 CEST

There are a lot of blogs and articles out there on this topic, but you have acquired another side of the subject. This is reliable content thank you for sharing it.
Transmission Repair Kansas City

Martin Cooper, 14.11.2013 13:31 CEST

This post is very simple to read and appreciate without leaving any details out. Great work!

Michael john, 14.11.2013 13:32 CEST

emergency plumber Dallas To create a such kind of article is really amazing,I daily read your blogs and give my announcement for that here this article is too great and so entertaining.

neetin, 23.11.2013 12:55 CEST

Unless the bag is made from high-grade polypropylene, you cannot be sure about their quality and durability. Using inferior quality bags can actually cause more harm to the environment.Prada Handbags USA

Anjali, 23.11.2013 14:43 CEST

The term "Prada Handbags USA" initially called a small case for having loose change. Within British isles Uk, it's nevertheless accustomed to make reference to a small coin case. A new "handbag" is often a bigger essential accent, in which holds things outside of forex, for example a ladies particular things as well as urgent situation items to endure with.

James anderson, 25.11.2013 12:56 CEST

Your article definitely worth looking through. I recently found the application well written and then quickly logical. I must personally we understand the time you devote to create the application. I’m sure very pleased in addition to lose time waiting for your blog post.

rakesh, 27.11.2013 13:18 CEST

protein bielkovinyTravel is the activity of going from one place to another place. When a person makes the same trip every day to work or school, this type of travelling is usually called "commuting." Some people travel to other cities as part of their job.

sanjeev, 27.11.2013 13:23 CEST

svadobny fotograf presov Using social media for networking is one of many not only the one way. Young people, audlts, a different kind of organisations etc. are using social media for joining with their friends, fans, children and many others. In some cases it's especially about promotion, of course.

pinkey, 27.11.2013 14:07 CEST

bodog88 Some hosting services offer a tool to build your own website. Use this tool to create a very basic layout but do most of the coding yourself. In order to personalize your site, you will want to add features that differentiate your site from the millions of generic cookie cutter website online.

andyyu, 15.01.2014 09:02 CEST

Great!This article is creative,there are a lot of new idea,it gives me inspiration.

Gifts Sweden, 20.01.2014 07:45 CEST

Your article definitely worth looking through. I recently found the application well written and then quickly logical. I must personally we understand the time you devote to create the application. I’m sure very pleased in addition to lose time waiting for your blog post.

Anonymous, 22.01.2014 13:02 CEST

As you surely pass4sure 74-335 braindumps know it is possible to control whether the js/css will be included into the page by sticking to the particular layout handles. The condition parameter gives you an ability to provide even more sophisticated configuration.

roshni, 18.03.2014 07:58 CEST

Our highly-popular and unique "Guide to Posing the Female Model" book has been getting super reviews from photographers and models around the world. This practical posing book has been purchased not only by photographers and models, but also by artists, colleges and schools.
wollongong photographers

Add a comment

Your email adress will never be published. Comment spam will be deleted!