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
           
static class MapperService.SmartNameObjectMapper
           
 
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)
           
 AnalysisService analysisService()
           
 void close()
           
 DocumentMapper documentMapper(java.lang.String type)
           
 DocumentMapperParser documentMapperParser()
           
 DocumentMapper documentMapperWithAutoCreate(java.lang.String type)
           
 FieldMappers fullName(java.lang.String fullName)
          Returns the FieldMappers 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 FieldMappers 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 FieldMappers for all the FieldMappers that are registered under the given name across all the different DocumentMapper types.
 ObjectMappers objectMapper(java.lang.String path)
          Returns objects mappers based on the full path of the object.
 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()
           
 org.apache.lucene.search.Filter searchFilter(java.lang.String... types)
          A filter for search.
 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.
 MapperService.SmartNameObjectMapper smartNameObjectMapper(java.lang.String smartName)
           
 java.util.Collection<java.lang.String> types()
           
 org.apache.lucene.search.Filter typesFilterFailOnMissing(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

close

public void close()

iterator

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

analysisService

public AnalysisService analysisService()

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)

types

public java.util.Collection<java.lang.String> types()

documentMapper

public DocumentMapper documentMapper(java.lang.String type)

documentMapperWithAutoCreate

public DocumentMapper documentMapperWithAutoCreate(java.lang.String type)

searchFilter

public org.apache.lucene.search.Filter searchFilter(java.lang.String... types)
A filter for search. If a filter is required, will return it, otherwise, will return null.


typesFilterFailOnMissing

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

Throws:
TypeMissingException

name

public FieldMappers name(java.lang.String name)
Returns FieldMappers 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 FieldMappers for across all DocumentMappers.
Returns:
All the FieldMappers for across all DocumentMappers

indexName

public FieldMappers indexName(java.lang.String indexName)
Returns FieldMappers 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 FieldMappers for across all DocumentMappers.
Returns:
All the FieldMappers across all DocumentMappers for the given indexName.

fullName

public FieldMappers fullName(java.lang.String fullName)
Returns the FieldMappers 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 FieldMappers across all the DocumentMappers for the given fullName.

objectMapper

public ObjectMappers objectMapper(java.lang.String path)
Returns objects mappers based on the full path of the object.


smartNameObjectMapper

public MapperService.SmartNameObjectMapper smartNameObjectMapper(java.lang.String smartName)

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 FieldMappers 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()