elasticsearch/elasticsearch — Issue #1493: DocumentMapper.java wrong order on build rootMappers
Author: gustavobbamaia
Created: 2011-11-23 20:03:24+00:00
State: open

It was some problems when you restart the ES and noticed that some filters were not being applied all of the field.
It was observed that the class AllFieldMapper, in the line 182
context.analyzer analyzer = ();
this analyzer was null.

So I went deeper and noticed that the class DocumentMapper Map rootMappers The order of the objects changed, sometimes
this.rootMappers.put (AllFieldMapper.class, AllFieldMapper new ());
came before the
this.rootMappers.put (AnalyzerMapper.class, AnalyzerMapper new ());
soon context.analyzer () class was null.

I changed the order of the puts and also changed the Map of rootMappers, I started using a LinkedHashMap.

Below is the change in class DocumentMapper.

Line: 136
private Map , RootMapper> rootMappers = new LinkedHashMap , RootMapper >();// Maps.newHashMap ();

Line: 171
this.rootMappers.put (SourceFieldMapper.class, SourceFieldMapper new ());
this.rootMappers.put (TypeFieldMapper.class, TypeFieldMapper new ());
this.rootMappers.put (AnalyzerMapper.class, AnalyzerMapper new ());
this.rootMappers.put (AllFieldMapper.class, AllFieldMapper new ());
this.rootMappers.put (BoostFieldMapper.class, BoostFieldMapper new ());
this.rootMappers.put (RoutingFieldMapper.class, RoutingFieldMapper new ());