org.elasticsearch.index.mapper
Class MapperService

java.lang.Object
  extended by org.elasticsearch.index.AbstractIndexComponent
      extended by org.elasticsearch.index.mapper.MapperService
All Implemented Interfaces:
java.lang.Iterable<DocumentMapper>, IndexComponent

@ThreadSafe
public class MapperService
extends AbstractIndexComponent
implements java.lang.Iterable<DocumentMapper>


Nested Class Summary
static class MapperService.SmartNameFieldMappers
           
 
Field Summary
static java.lang.String DEFAULT_MAPPING
           
 
Fields inherited from class org.elasticsearch.index.AbstractIndexComponent
componentSettings, index, indexSettings, logger
 
Constructor Summary
MapperService(Index index, Settings indexSettings, Environment environment, AnalysisService analysisService)
           
 
Method Summary
 void add(java.lang.String type, java.lang.String mappingSource)
           
 DocumentMapper documentMapper(java.lang.String type)
           
 DocumentMapperParser documentMapperParser()
           
 FieldMappers fullName(java.lang.String fullName)
          Returns the MapperService.SmartNameFieldMappers of all the FieldMappers that are registered under the give fullName across all the different DocumentMapper types.
 boolean hasMapping(java.lang.String mappingType)
           
 FieldMappers indexName(java.lang.String indexName)
          Returns MapperService.SmartNameFieldMappers for all the FieldMappers that are registered under the given indexName across all the different DocumentMapper types.
 org.elasticsearch.common.collect.UnmodifiableIterator<DocumentMapper> iterator()
           
 FieldMappers name(java.lang.String name)
          Returns MapperService.SmartNameFieldMappers for all the FieldMappers that are registered under the given name across all the different DocumentMapper types.
 DocumentMapper parse(java.lang.String mappingType, java.lang.String mappingSource)
          Just parses and returns the mapper without adding it.
 void remove(java.lang.String type)
           
 org.apache.lucene.analysis.Analyzer searchAnalyzer()
           
 java.util.Set<java.lang.String> simpleMatchToIndexNames(java.lang.String pattern)
           
 MapperService.SmartNameFieldMappers smartName(java.lang.String smartName)
          Returns smart field mappers based on a smart name.
 FieldMapper smartNameFieldMapper(java.lang.String smartName)
          Same as smartNameFieldMappers(String) but returns the first field mapper for it.
 FieldMappers smartNameFieldMappers(java.lang.String smartName)
          Same as smartName(String), except it returns just the field mappers.
 DocumentMapper type(java.lang.String type)
           
 org.apache.lucene.search.Filter typesFilter(java.lang.String... types)
          A filter to filter based on several types.
 
Methods inherited from class org.elasticsearch.index.AbstractIndexComponent
index, nodeName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_MAPPING

public static final java.lang.String DEFAULT_MAPPING
See Also:
Constant Field Values
Constructor Detail

MapperService

@Inject
public MapperService(Index index,
                            @IndexSettings
                            Settings indexSettings,
                            Environment environment,
                            AnalysisService analysisService)
Method Detail

iterator

public org.elasticsearch.common.collect.UnmodifiableIterator<DocumentMapper> iterator()
Specified by:
iterator in interface java.lang.Iterable<DocumentMapper>

type

public DocumentMapper type(java.lang.String type)

documentMapperParser

public DocumentMapperParser documentMapperParser()

add

public void add(java.lang.String type,
                java.lang.String mappingSource)

remove

public void remove(java.lang.String type)

parse

public DocumentMapper parse(java.lang.String mappingType,
                            java.lang.String mappingSource)
                     throws MapperParsingException
Just parses and returns the mapper without adding it.

Throws:
MapperParsingException

hasMapping

public boolean hasMapping(java.lang.String mappingType)

documentMapper

public DocumentMapper documentMapper(java.lang.String type)

typesFilter

public org.apache.lucene.search.Filter typesFilter(java.lang.String... types)
A filter to filter based on several types.


name

public FieldMappers name(java.lang.String name)
Returns MapperService.SmartNameFieldMappers for all the FieldMappers that are registered under the given name across all the different DocumentMapper types.

Parameters:
name - The name to return all the MapperService.SmartNameFieldMappers for across all DocumentMappers.
Returns:
All the MapperService.SmartNameFieldMappers for across all DocumentMappers

indexName

public FieldMappers indexName(java.lang.String indexName)
Returns MapperService.SmartNameFieldMappers for all the FieldMappers that are registered under the given indexName across all the different DocumentMapper types.

Parameters:
indexName - The indexName to return all the MapperService.SmartNameFieldMappers for across all DocumentMappers.
Returns:
All the MapperService.SmartNameFieldMappers across all DocumentMappers for the given indexName.

fullName

public FieldMappers fullName(java.lang.String fullName)
Returns the MapperService.SmartNameFieldMappers of all the FieldMappers that are registered under the give fullName across all the different DocumentMapper types.

Parameters:
fullName - The full name
Returns:
All teh MapperService.SmartNameFieldMappers across all the DocumentMappers for the given fullName.

smartNameFieldMapper

public FieldMapper smartNameFieldMapper(java.lang.String smartName)
Same as smartNameFieldMappers(String) but returns the first field mapper for it. Returns null if there is none.


simpleMatchToIndexNames

public java.util.Set<java.lang.String> simpleMatchToIndexNames(java.lang.String pattern)

smartNameFieldMappers

public FieldMappers smartNameFieldMappers(java.lang.String smartName)
Same as smartName(String), except it returns just the field mappers.


smartName

public MapperService.SmartNameFieldMappers smartName(java.lang.String smartName)
Returns smart field mappers based on a smart name. A smart name is one that can optioannly be prefixed with a type (and then a '.'). If it is, then the MapperService.SmartNameFieldMappers will have the doc mapper set.

It also (without the optional type prefix) try and find the MapperService.SmartNameFieldMappers for the specific name. It will first try to find it based on the full name (with the dots if its a compound name). If it is not found, will try and find it based on the indexName (which can be controlled in the mapping), and last, will try it based no the name itself.

If nothing is found, returns null.


searchAnalyzer

public org.apache.lucene.analysis.Analyzer searchAnalyzer()