lucene 4: Exposed Lucene's codec api
This feature adds the option to configure a `PostingsFormat` and assign it to a field in the mapping. This feature is very expert and in almost all cases Elasticsearch's defaults will suite your needs. ## Configuring a postingsformat per field There're several default postings formats configured by default which can be used in your mapping: a* `direct` - A codec that wraps the default postings format during write time, but loads the terms and postinglists into memory directly in memory during read time as raw arrays. This postings format is exceptional memory intensive, but can give a substantial increase in search performance. * `memory` - A codec that loads and stores terms and postinglists in memory using a FST. Acts like a cached postingslist. * `bloom_default` - Maintains a bloom filter for the indexed terms, which is stored to disk and builds on top of the `default` postings format. This postings format is useful for low document frequency terms and offers a fail fast for seeks to terms that don't exist. * `bloom_pulsing` - Similar to the `bloom_default` postings format, but builds on top of the `pulsing` postings format. * `default` - The default postings format. The default if none is specified. On all fields it possible to configure a `postings_format` attribute. Example mapping: ``` { "person" : { "properties" : { "second_person_id" : {"type" : "string", "postings_format" : "pulsing"} } } } ``` ## Configuring a custom postingsformat It is possible the instantiate custom postingsformats. This can be specified via the index settings. ``` { "codec" : { "postings_format" : { "my_format" : { "type" : "pulsing40" "freq_cut_off" : "5" } } } } ``` In the above example the `freq_cut_off` is set the 5 (defaults to 1). This tells the pulsing postings format to inline the postinglist of terms with a document frequency lower or equal to 5 in the term dictionary. Closes #2411
This commit is contained in:
parent
120560bd0a
commit
fd5bd102aa
|
@ -0,0 +1,99 @@
|
|||
package org.elasticsearch.index.codec;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import org.apache.lucene.codecs.PostingsFormat;
|
||||
import org.apache.lucene.codecs.bloom.BloomFilteringPostingsFormat;
|
||||
import org.apache.lucene.codecs.lucene40.Lucene40PostingsFormat;
|
||||
import org.apache.lucene.codecs.memory.DirectPostingsFormat;
|
||||
import org.apache.lucene.codecs.memory.MemoryPostingsFormat;
|
||||
import org.apache.lucene.codecs.pulsing.Pulsing40PostingsFormat;
|
||||
import org.elasticsearch.ElasticSearchIllegalArgumentException;
|
||||
import org.elasticsearch.common.inject.AbstractModule;
|
||||
import org.elasticsearch.common.inject.Scopes;
|
||||
import org.elasticsearch.common.inject.assistedinject.FactoryProvider;
|
||||
import org.elasticsearch.common.inject.multibindings.MapBinder;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.index.codec.postingsformat.PostingsFormatProvider;
|
||||
import org.elasticsearch.index.codec.postingsformat.PostingsFormatService;
|
||||
import org.elasticsearch.index.codec.postingsformat.PreBuiltPostingsFormatProvider;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class CodecModule extends AbstractModule {
|
||||
|
||||
public static final ImmutableList<PreBuiltPostingsFormatProvider.Factory> preConfiguredPostingFormats;
|
||||
|
||||
static {
|
||||
List<PreBuiltPostingsFormatProvider.Factory> preConfiguredPostingFormatsX = Lists.newArrayList();
|
||||
// add defaults ones
|
||||
for (String luceneName : PostingsFormat.availablePostingsFormats()) {
|
||||
preConfiguredPostingFormatsX.add(new PreBuiltPostingsFormatProvider.Factory(PostingsFormat.forName(luceneName)));
|
||||
}
|
||||
preConfiguredPostingFormatsX.add(new PreBuiltPostingsFormatProvider.Factory("direct", new DirectPostingsFormat()));
|
||||
preConfiguredPostingFormatsX.add(new PreBuiltPostingsFormatProvider.Factory("memory", new MemoryPostingsFormat()));
|
||||
// LUCENE UPGRADE: Need to change this to the relevant ones on a lucene upgrade
|
||||
preConfiguredPostingFormatsX.add(new PreBuiltPostingsFormatProvider.Factory("pulsing", new Pulsing40PostingsFormat()));
|
||||
preConfiguredPostingFormatsX.add(new PreBuiltPostingsFormatProvider.Factory("bloom_pulsing", new BloomFilteringPostingsFormat(new Pulsing40PostingsFormat())));
|
||||
preConfiguredPostingFormatsX.add(new PreBuiltPostingsFormatProvider.Factory("default", new Lucene40PostingsFormat()));
|
||||
preConfiguredPostingFormatsX.add(new PreBuiltPostingsFormatProvider.Factory("bloom_default", new BloomFilteringPostingsFormat(new Lucene40PostingsFormat())));
|
||||
|
||||
preConfiguredPostingFormats = ImmutableList.copyOf(preConfiguredPostingFormatsX);
|
||||
}
|
||||
|
||||
private final Settings indexSettings;
|
||||
|
||||
private Map<String, Class<? extends PostingsFormatProvider>> customProviders = Maps.newHashMap();
|
||||
|
||||
public CodecModule(Settings indexSettings) {
|
||||
this.indexSettings = indexSettings;
|
||||
}
|
||||
|
||||
public CodecModule addPostingFormat(String name, Class<? extends PostingsFormatProvider> provider) {
|
||||
this.customProviders.put(name, provider);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
|
||||
Map<String, Class<? extends PostingsFormatProvider>> postingFormatProviders = Maps.newHashMap(customProviders);
|
||||
|
||||
Map<String, Settings> postingsFormatsSettings = indexSettings.getGroups("index.codec.postings_format");
|
||||
for (Map.Entry<String, Settings> entry : postingsFormatsSettings.entrySet()) {
|
||||
String name = entry.getKey();
|
||||
Settings settings = entry.getValue();
|
||||
|
||||
Class<? extends PostingsFormatProvider> type =
|
||||
settings.getAsClass("type", null, "org.elasticsearch.index.codec.postingsformat.", "PostingsFormatProvider");
|
||||
|
||||
if (type == null) {
|
||||
// nothing found, see if its in bindings as a binding name
|
||||
throw new ElasticSearchIllegalArgumentException("PostingsFormat Factory [" + name + "] must have a type associated with it");
|
||||
}
|
||||
postingFormatProviders.put(name, type);
|
||||
}
|
||||
|
||||
// now bind
|
||||
MapBinder<String, PostingsFormatProvider.Factory> postingFormatFactoryBinder
|
||||
= MapBinder.newMapBinder(binder(), String.class, PostingsFormatProvider.Factory.class);
|
||||
|
||||
for (Map.Entry<String, Class<? extends PostingsFormatProvider>> entry : postingFormatProviders.entrySet()) {
|
||||
postingFormatFactoryBinder.addBinding(entry.getKey()).toProvider(FactoryProvider.newFactory(PostingsFormatProvider.Factory.class, entry.getValue())).in(Scopes.SINGLETON);
|
||||
}
|
||||
|
||||
for (PreBuiltPostingsFormatProvider.Factory factory : preConfiguredPostingFormats) {
|
||||
if (postingFormatProviders.containsKey(factory.name())) {
|
||||
continue;
|
||||
}
|
||||
postingFormatFactoryBinder.addBinding(factory.name()).toInstance(factory);
|
||||
}
|
||||
|
||||
bind(PostingsFormatService.class).asEagerSingleton();
|
||||
bind(CodecService.class).asEagerSingleton();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
package org.elasticsearch.index.codec;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import org.apache.lucene.codecs.Codec;
|
||||
import org.elasticsearch.ElasticSearchIllegalArgumentException;
|
||||
import org.elasticsearch.common.collect.MapBuilder;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.ImmutableSettings;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.index.AbstractIndexComponent;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.index.codec.postingsformat.PostingsFormatService;
|
||||
import org.elasticsearch.index.mapper.MapperService;
|
||||
import org.elasticsearch.index.settings.IndexSettings;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class CodecService extends AbstractIndexComponent {
|
||||
|
||||
private final PostingsFormatService postingsFormatService;
|
||||
private final MapperService mapperService;
|
||||
private final ImmutableMap<String, Codec> codecs;
|
||||
|
||||
public CodecService(Index index) {
|
||||
this(index, ImmutableSettings.Builder.EMPTY_SETTINGS);
|
||||
}
|
||||
|
||||
public CodecService(Index index, @IndexSettings Settings indexSettings) {
|
||||
this(index, indexSettings, new PostingsFormatService(index, indexSettings), null);
|
||||
}
|
||||
|
||||
@Inject
|
||||
public CodecService(Index index, @IndexSettings Settings indexSettings, PostingsFormatService postingsFormatService,
|
||||
MapperService mapperService) {
|
||||
super(index, indexSettings);
|
||||
this.postingsFormatService = postingsFormatService;
|
||||
this.mapperService = mapperService;
|
||||
MapBuilder<String, Codec> codecs = MapBuilder.<String, Codec>newMapBuilder();
|
||||
if (mapperService == null) {
|
||||
codecs.put("default", Codec.getDefault());
|
||||
} else {
|
||||
codecs.put("default", new PerFieldMappingPostingFormatCodec(mapperService, postingsFormatService.get("default").get()));
|
||||
}
|
||||
for (String codec : Codec.availableCodecs()) {
|
||||
codecs.put(codec, Codec.forName(codec));
|
||||
}
|
||||
this.codecs = codecs.immutableMap();
|
||||
}
|
||||
|
||||
public PostingsFormatService postingsFormatService() {
|
||||
return this.postingsFormatService;
|
||||
}
|
||||
|
||||
public MapperService mapperService() {
|
||||
return mapperService;
|
||||
}
|
||||
|
||||
public Codec codec(String name) throws ElasticSearchIllegalArgumentException {
|
||||
Codec codec = codecs.get(name);
|
||||
if (codec == null) {
|
||||
throw new ElasticSearchIllegalArgumentException("failed to find codec [" + name + "]");
|
||||
}
|
||||
return codec;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package org.elasticsearch.index.codec;
|
||||
|
||||
import org.apache.lucene.codecs.PostingsFormat;
|
||||
import org.apache.lucene.codecs.lucene40.Lucene40Codec;
|
||||
import org.elasticsearch.index.codec.postingsformat.PostingsFormatProvider;
|
||||
import org.elasticsearch.index.mapper.MapperService;
|
||||
|
||||
/**
|
||||
* This one is the "default" codec we use.
|
||||
*/
|
||||
// LUCENE UPGRADE: make sure to move to a new codec depending on the lucene version
|
||||
public class PerFieldMappingPostingFormatCodec extends Lucene40Codec {
|
||||
|
||||
private final MapperService mapperService;
|
||||
private final PostingsFormat defaultPostingFormat;
|
||||
|
||||
public PerFieldMappingPostingFormatCodec(MapperService mapperService, PostingsFormat defaultPostingFormat) {
|
||||
this.mapperService = mapperService;
|
||||
this.defaultPostingFormat = defaultPostingFormat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PostingsFormat getPostingsFormatForField(String field) {
|
||||
PostingsFormatProvider postingsFormat = mapperService.indexName(field).mapper().postingFormatProvider();
|
||||
return postingsFormat != null ? postingsFormat.get() : defaultPostingFormat;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package org.elasticsearch.index.codec.postingsformat;
|
||||
|
||||
/**
|
||||
*/
|
||||
public abstract class AbstractPostingsFormatProvider implements PostingsFormatProvider {
|
||||
|
||||
private final String name;
|
||||
|
||||
protected AbstractPostingsFormatProvider(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String name() {
|
||||
return name;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,78 @@
|
|||
package org.elasticsearch.index.codec.postingsformat;
|
||||
|
||||
import org.apache.lucene.codecs.PostingsFormat;
|
||||
import org.apache.lucene.codecs.bloom.BloomFilterFactory;
|
||||
import org.apache.lucene.codecs.bloom.BloomFilteringPostingsFormat;
|
||||
import org.apache.lucene.codecs.bloom.FuzzySet;
|
||||
import org.apache.lucene.index.FieldInfo;
|
||||
import org.apache.lucene.index.SegmentWriteState;
|
||||
import org.elasticsearch.common.Nullable;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.inject.assistedinject.Assisted;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.index.settings.IndexSettings;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class BloomFilterPostingsFormatProvider extends AbstractPostingsFormatProvider {
|
||||
|
||||
private final float desiredMaxSaturation;
|
||||
private final float saturationLimit;
|
||||
private final PostingsFormatProvider delegate;
|
||||
private final BloomFilteringPostingsFormat postingsFormat;
|
||||
|
||||
@Inject
|
||||
public BloomFilterPostingsFormatProvider(@IndexSettings Settings indexSettings, @Nullable Map<String, Factory> postingFormatFactories, @Assisted String name, @Assisted Settings postingsFormatSettings) {
|
||||
super(name);
|
||||
this.desiredMaxSaturation = postingsFormatSettings.getAsFloat("desired_max_saturation", 0.1f);
|
||||
this.saturationLimit = postingsFormatSettings.getAsFloat("saturation_limit", 0.9f);
|
||||
this.delegate = Helper.lookup(indexSettings, postingsFormatSettings.get("delegate"), postingFormatFactories);
|
||||
this.postingsFormat = new BloomFilteringPostingsFormat(
|
||||
delegate.get(),
|
||||
new CustomBloomFilterFactory(desiredMaxSaturation, saturationLimit)
|
||||
);
|
||||
}
|
||||
|
||||
public float desiredMaxSaturation() {
|
||||
return desiredMaxSaturation;
|
||||
}
|
||||
|
||||
public float saturationLimit() {
|
||||
return saturationLimit;
|
||||
}
|
||||
|
||||
public PostingsFormatProvider delegate() {
|
||||
return delegate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PostingsFormat get() {
|
||||
return postingsFormat;
|
||||
}
|
||||
|
||||
static class CustomBloomFilterFactory extends BloomFilterFactory {
|
||||
|
||||
private final float desiredMaxSaturation;
|
||||
private final float saturationLimit;
|
||||
|
||||
CustomBloomFilterFactory(float desiredMaxSaturation, float saturationLimit) {
|
||||
this.desiredMaxSaturation = desiredMaxSaturation;
|
||||
this.saturationLimit = saturationLimit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FuzzySet getSetForField(SegmentWriteState state, FieldInfo info) {
|
||||
//Assume all of the docs have a unique term (e.g. a primary key) and we hope to maintain a set with desiredMaxSaturation% of bits set
|
||||
return FuzzySet.createSetBasedOnQuality(state.segmentInfo.getDocCount(), desiredMaxSaturation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSaturated(FuzzySet bloomFilter, FieldInfo fieldInfo) {
|
||||
// Don't bother saving bitsets if > saturationLimit % of bits are set - we don't want to
|
||||
// throw any more memory at this problem.
|
||||
return bloomFilter.getSaturation() > saturationLimit;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package org.elasticsearch.index.codec.postingsformat;
|
||||
|
||||
import org.apache.lucene.codecs.PostingsFormat;
|
||||
import org.apache.lucene.codecs.memory.DirectPostingsFormat;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.inject.assistedinject.Assisted;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class DirectPostingsFormatProvider extends AbstractPostingsFormatProvider {
|
||||
|
||||
private final int minSkipCount;
|
||||
private final int lowFreqCutoff;
|
||||
private final DirectPostingsFormat postingsFormat;
|
||||
|
||||
@Inject
|
||||
public DirectPostingsFormatProvider(@Assisted String name, @Assisted Settings postingsFormatSettings) {
|
||||
super(name);
|
||||
this.minSkipCount = postingsFormatSettings.getAsInt("min_skip_count", 8); // See DirectPostingsFormat#DEFAULT_MIN_SKIP_COUNT
|
||||
this.lowFreqCutoff = postingsFormatSettings.getAsInt("low_freq_cutoff", 32); // See DirectPostingsFormat#DEFAULT_LOW_FREQ_CUTOFF
|
||||
this.postingsFormat = new DirectPostingsFormat(minSkipCount, lowFreqCutoff);
|
||||
}
|
||||
|
||||
public int minSkipCount() {
|
||||
return minSkipCount;
|
||||
}
|
||||
|
||||
public int lowFreqCutoff() {
|
||||
return lowFreqCutoff;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PostingsFormat get() {
|
||||
return postingsFormat;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
package org.elasticsearch.index.codec.postingsformat;
|
||||
|
||||
import org.apache.lucene.codecs.BlockTreeTermsWriter;
|
||||
import org.apache.lucene.codecs.PostingsFormat;
|
||||
import org.apache.lucene.codecs.lucene40.Lucene40PostingsFormat;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.inject.assistedinject.Assisted;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class Lucene40PostingsFormatProvider extends AbstractPostingsFormatProvider {
|
||||
|
||||
private final int minBlockSize;
|
||||
private final int maxBlockSize;
|
||||
private final Lucene40PostingsFormat postingsFormat;
|
||||
|
||||
@Inject
|
||||
public Lucene40PostingsFormatProvider(@Assisted String name, @Assisted Settings postingsFormatSettings) {
|
||||
super(name);
|
||||
this.minBlockSize = postingsFormatSettings.getAsInt("min_block_size", BlockTreeTermsWriter.DEFAULT_MIN_BLOCK_SIZE);
|
||||
this.maxBlockSize = postingsFormatSettings.getAsInt("max_block_size", BlockTreeTermsWriter.DEFAULT_MAX_BLOCK_SIZE);
|
||||
this.postingsFormat = new Lucene40PostingsFormat(minBlockSize, maxBlockSize);
|
||||
}
|
||||
|
||||
public int minBlockSize() {
|
||||
return minBlockSize;
|
||||
}
|
||||
|
||||
public int maxBlockSize() {
|
||||
return maxBlockSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PostingsFormat get() {
|
||||
return postingsFormat;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
package org.elasticsearch.index.codec.postingsformat;
|
||||
|
||||
import org.apache.lucene.codecs.PostingsFormat;
|
||||
import org.apache.lucene.codecs.memory.MemoryPostingsFormat;
|
||||
import org.apache.lucene.util.packed.PackedInts;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.inject.assistedinject.Assisted;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class MemoryPostingsFormatProvider extends AbstractPostingsFormatProvider {
|
||||
|
||||
private final boolean packFst;
|
||||
private final float acceptableOverheadRatio;
|
||||
private final MemoryPostingsFormat postingsFormat;
|
||||
|
||||
@Inject
|
||||
public MemoryPostingsFormatProvider(@Assisted String name, @Assisted Settings postingsFormatSettings) {
|
||||
super(name);
|
||||
this.packFst = postingsFormatSettings.getAsBoolean("pack_fst", false);
|
||||
this.acceptableOverheadRatio = postingsFormatSettings.getAsFloat("acceptable_overhead_ratio", PackedInts.DEFAULT);
|
||||
this.postingsFormat = new MemoryPostingsFormat(packFst, acceptableOverheadRatio);
|
||||
}
|
||||
|
||||
public boolean packFst() {
|
||||
return packFst;
|
||||
}
|
||||
|
||||
public float acceptableOverheadRatio() {
|
||||
return acceptableOverheadRatio;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PostingsFormat get() {
|
||||
return postingsFormat;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package org.elasticsearch.index.codec.postingsformat;
|
||||
|
||||
import org.apache.lucene.codecs.PostingsFormat;
|
||||
import org.elasticsearch.ElasticSearchIllegalArgumentException;
|
||||
import org.elasticsearch.common.settings.ImmutableSettings;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.index.settings.IndexSettings;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*/
|
||||
public interface PostingsFormatProvider {
|
||||
|
||||
public static class Helper {
|
||||
|
||||
public static PostingsFormatProvider lookup(@IndexSettings Settings indexSettings, String name, Map<String, Factory> postingFormatFactories) throws ElasticSearchIllegalArgumentException {
|
||||
Factory factory = postingFormatFactories.get(name);
|
||||
if (factory == null) {
|
||||
throw new ElasticSearchIllegalArgumentException("failed to find postings_format [" + name + "]");
|
||||
}
|
||||
Settings settings = indexSettings.getGroups("index.codec.postings_format").get(name);
|
||||
if (settings == null) {
|
||||
settings = ImmutableSettings.Builder.EMPTY_SETTINGS;
|
||||
}
|
||||
return factory.create(name, settings);
|
||||
}
|
||||
}
|
||||
|
||||
PostingsFormat get();
|
||||
|
||||
String name();
|
||||
|
||||
public interface Factory {
|
||||
PostingsFormatProvider create(String name, Settings settings);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
package org.elasticsearch.index.codec.postingsformat;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import org.elasticsearch.ElasticSearchIllegalArgumentException;
|
||||
import org.elasticsearch.common.collect.MapBuilder;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.ImmutableSettings;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.index.AbstractIndexComponent;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.index.codec.CodecModule;
|
||||
import org.elasticsearch.index.settings.IndexSettings;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class PostingsFormatService extends AbstractIndexComponent {
|
||||
|
||||
private final ImmutableMap<String, PostingsFormatProvider> providers;
|
||||
|
||||
public PostingsFormatService(Index index) {
|
||||
this(index, ImmutableSettings.Builder.EMPTY_SETTINGS);
|
||||
}
|
||||
|
||||
public PostingsFormatService(Index index, @IndexSettings Settings indexSettings) {
|
||||
this(index, indexSettings, ImmutableMap.<String, PostingsFormatProvider.Factory>of());
|
||||
}
|
||||
|
||||
@Inject
|
||||
public PostingsFormatService(Index index, @IndexSettings Settings indexSettings, Map<String, PostingsFormatProvider.Factory> postingFormatFactories) {
|
||||
super(index, indexSettings);
|
||||
|
||||
MapBuilder<String, PostingsFormatProvider> providers = MapBuilder.newMapBuilder();
|
||||
|
||||
Map<String, Settings> postingsFormatSettings = indexSettings.getGroups("index.codec.postings_format");
|
||||
for (Map.Entry<String, PostingsFormatProvider.Factory> entry : postingFormatFactories.entrySet()) {
|
||||
String name = entry.getKey();
|
||||
PostingsFormatProvider.Factory factory = entry.getValue();
|
||||
|
||||
Settings settings = postingsFormatSettings.get(name);
|
||||
if (settings == null) {
|
||||
settings = ImmutableSettings.Builder.EMPTY_SETTINGS;
|
||||
}
|
||||
providers.put(name, factory.create(name, settings));
|
||||
}
|
||||
|
||||
// even though we have this logic in the cache module (where it should be, so posting format with delegates will work properly wiht the pre initialized map)
|
||||
// we do it here as well so we can use just this instance for tests
|
||||
for (PreBuiltPostingsFormatProvider.Factory factory : CodecModule.preConfiguredPostingFormats) {
|
||||
if (providers.containsKey(factory.name())) {
|
||||
continue;
|
||||
}
|
||||
providers.put(factory.name(), factory.get());
|
||||
}
|
||||
|
||||
this.providers = providers.immutableMap();
|
||||
}
|
||||
|
||||
public PostingsFormatProvider get(String name) throws ElasticSearchIllegalArgumentException {
|
||||
PostingsFormatProvider provider = providers.get(name);
|
||||
if (name == null) {
|
||||
throw new ElasticSearchIllegalArgumentException("failed to find postings_format [" + name + "]");
|
||||
}
|
||||
return provider;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
package org.elasticsearch.index.codec.postingsformat;
|
||||
|
||||
import org.apache.lucene.codecs.PostingsFormat;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class PreBuiltPostingsFormatProvider implements PostingsFormatProvider {
|
||||
|
||||
public static final class Factory implements PostingsFormatProvider.Factory {
|
||||
|
||||
private final PreBuiltPostingsFormatProvider provider;
|
||||
|
||||
public Factory(PostingsFormat postingsFormat) {
|
||||
this(postingsFormat.getName(), postingsFormat);
|
||||
}
|
||||
|
||||
public Factory(String name, PostingsFormat postingsFormat) {
|
||||
this.provider = new PreBuiltPostingsFormatProvider(name, postingsFormat);
|
||||
}
|
||||
|
||||
public PostingsFormatProvider get() {
|
||||
return provider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PostingsFormatProvider create(String name, Settings settings) {
|
||||
return provider;
|
||||
}
|
||||
|
||||
public String name() {
|
||||
return provider.name();
|
||||
}
|
||||
}
|
||||
|
||||
private final String name;
|
||||
private final PostingsFormat postingsFormat;
|
||||
|
||||
public PreBuiltPostingsFormatProvider(PostingsFormat postingsFormat) {
|
||||
this(postingsFormat.getName(), postingsFormat);
|
||||
}
|
||||
|
||||
public PreBuiltPostingsFormatProvider(String name, PostingsFormat postingsFormat) {
|
||||
this.name = name;
|
||||
this.postingsFormat = postingsFormat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String name() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PostingsFormat get() {
|
||||
return postingsFormat;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
package org.elasticsearch.index.codec.postingsformat;
|
||||
|
||||
import org.apache.lucene.codecs.BlockTreeTermsWriter;
|
||||
import org.apache.lucene.codecs.PostingsFormat;
|
||||
import org.apache.lucene.codecs.pulsing.Pulsing40PostingsFormat;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.inject.assistedinject.Assisted;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class Pulsing40PostingsFormatProvider extends AbstractPostingsFormatProvider {
|
||||
|
||||
private final int freqCutOff;
|
||||
private final int minBlockSize;
|
||||
private final int maxBlockSize;
|
||||
private final Pulsing40PostingsFormat postingsFormat;
|
||||
|
||||
@Inject
|
||||
public Pulsing40PostingsFormatProvider(@Assisted String name, @Assisted Settings postingsFormatSettings) {
|
||||
super(name);
|
||||
this.freqCutOff = postingsFormatSettings.getAsInt("freq_cut_off", 1);
|
||||
this.minBlockSize = postingsFormatSettings.getAsInt("min_block_size", BlockTreeTermsWriter.DEFAULT_MIN_BLOCK_SIZE);
|
||||
this.maxBlockSize = postingsFormatSettings.getAsInt("max_block_size", BlockTreeTermsWriter.DEFAULT_MAX_BLOCK_SIZE);
|
||||
this.postingsFormat = new Pulsing40PostingsFormat(freqCutOff, minBlockSize, maxBlockSize);
|
||||
}
|
||||
|
||||
public int freqCutOff() {
|
||||
return freqCutOff;
|
||||
}
|
||||
|
||||
public int minBlockSize() {
|
||||
return minBlockSize;
|
||||
}
|
||||
|
||||
public int maxBlockSize() {
|
||||
return maxBlockSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PostingsFormat get() {
|
||||
return postingsFormat;
|
||||
}
|
||||
|
||||
}
|
|
@ -40,6 +40,7 @@ import org.elasticsearch.common.unit.TimeValue;
|
|||
import org.elasticsearch.common.util.concurrent.ConcurrentCollections;
|
||||
import org.elasticsearch.index.VersionType;
|
||||
import org.elasticsearch.index.analysis.AnalysisService;
|
||||
import org.elasticsearch.index.codec.CodecService;
|
||||
import org.elasticsearch.index.deletionpolicy.SnapshotDeletionPolicy;
|
||||
import org.elasticsearch.index.deletionpolicy.SnapshotIndexCommit;
|
||||
import org.elasticsearch.index.engine.*;
|
||||
|
@ -86,6 +87,7 @@ public class RobinEngine extends AbstractIndexShardComponent implements Engine {
|
|||
private volatile int indexConcurrency;
|
||||
private long gcDeletesInMillis;
|
||||
private volatile boolean enableGcDeletes = true;
|
||||
private volatile String codecName;
|
||||
|
||||
private final ThreadPool threadPool;
|
||||
|
||||
|
@ -100,6 +102,7 @@ public class RobinEngine extends AbstractIndexShardComponent implements Engine {
|
|||
private final MergeSchedulerProvider mergeScheduler;
|
||||
private final AnalysisService analysisService;
|
||||
private final SimilarityService similarityService;
|
||||
private final CodecService codecService;
|
||||
|
||||
|
||||
private final ReadWriteLock rwl = new ReentrantReadWriteLock();
|
||||
|
@ -147,7 +150,7 @@ public class RobinEngine extends AbstractIndexShardComponent implements Engine {
|
|||
IndexSettingsService indexSettingsService, ShardIndexingService indexingService, @Nullable IndicesWarmer warmer,
|
||||
Store store, SnapshotDeletionPolicy deletionPolicy, Translog translog,
|
||||
MergePolicyProvider mergePolicyProvider, MergeSchedulerProvider mergeScheduler,
|
||||
AnalysisService analysisService, SimilarityService similarityService) throws EngineException {
|
||||
AnalysisService analysisService, SimilarityService similarityService, CodecService codecService) throws EngineException {
|
||||
super(shardId, indexSettings);
|
||||
Preconditions.checkNotNull(store, "Store must be provided to the engine");
|
||||
Preconditions.checkNotNull(deletionPolicy, "Snapshot deletion policy must be provided to the engine");
|
||||
|
@ -157,6 +160,7 @@ public class RobinEngine extends AbstractIndexShardComponent implements Engine {
|
|||
this.indexingBufferSize = componentSettings.getAsBytesSize("index_buffer_size", new ByteSizeValue(64, ByteSizeUnit.MB)); // not really important, as it is set by the IndexingMemory manager
|
||||
this.termIndexInterval = indexSettings.getAsInt("index.term_index_interval", IndexWriterConfig.DEFAULT_TERM_INDEX_INTERVAL);
|
||||
this.termIndexDivisor = indexSettings.getAsInt("index.term_index_divisor", 1); // IndexReader#DEFAULT_TERMS_INDEX_DIVISOR
|
||||
this.codecName = indexSettings.get("index.codec", "default");
|
||||
|
||||
this.threadPool = threadPool;
|
||||
this.indexSettingsService = indexSettingsService;
|
||||
|
@ -169,6 +173,7 @@ public class RobinEngine extends AbstractIndexShardComponent implements Engine {
|
|||
this.mergeScheduler = mergeScheduler;
|
||||
this.analysisService = analysisService;
|
||||
this.similarityService = similarityService;
|
||||
this.codecService = codecService;
|
||||
|
||||
this.indexConcurrency = indexSettings.getAsInt("index.index_concurrency", IndexWriterConfig.DEFAULT_MAX_THREAD_STATES);
|
||||
this.versionMap = ConcurrentCollections.newConcurrentMap();
|
||||
|
@ -1331,6 +1336,7 @@ public class RobinEngine extends AbstractIndexShardComponent implements Engine {
|
|||
config.setTermIndexInterval(termIndexInterval);
|
||||
config.setReaderTermsIndexDivisor(termIndexDivisor);
|
||||
config.setMaxThreadStates(indexConcurrency);
|
||||
config.setCodec(codecService.codec(codecName));
|
||||
|
||||
indexWriter = new IndexWriter(store.directory(), config);
|
||||
} catch (IOException e) {
|
||||
|
@ -1345,7 +1351,8 @@ public class RobinEngine extends AbstractIndexShardComponent implements Engine {
|
|||
"index.term_index_interval",
|
||||
"index.term_index_divisor",
|
||||
"index.index_concurrency",
|
||||
"index.gc_deletes"
|
||||
"index.gc_deletes",
|
||||
"index.codec"
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1362,6 +1369,7 @@ public class RobinEngine extends AbstractIndexShardComponent implements Engine {
|
|||
int termIndexInterval = settings.getAsInt("index.term_index_interval", RobinEngine.this.termIndexInterval);
|
||||
int termIndexDivisor = settings.getAsInt("index.term_index_divisor", RobinEngine.this.termIndexDivisor); // IndexReader#DEFAULT_TERMS_INDEX_DIVISOR
|
||||
int indexConcurrency = settings.getAsInt("index.index_concurrency", RobinEngine.this.indexConcurrency);
|
||||
String codecName = settings.get("index.codec", RobinEngine.this.codecName);
|
||||
boolean requiresFlushing = false;
|
||||
if (termIndexInterval != RobinEngine.this.termIndexInterval || termIndexDivisor != RobinEngine.this.termIndexDivisor) {
|
||||
rwl.readLock().lock();
|
||||
|
@ -1384,6 +1392,12 @@ public class RobinEngine extends AbstractIndexShardComponent implements Engine {
|
|||
// we have to flush in this case, since it only applies on a new index writer
|
||||
requiresFlushing = true;
|
||||
}
|
||||
if (!codecName.equals(RobinEngine.this.codecName)) {
|
||||
logger.info("updating index.codec from [{}] to [{}]", RobinEngine.this.codecName, codecName);
|
||||
RobinEngine.this.codecName = codecName;
|
||||
// TODO: Lucene 4, I think once someones changes codec, it should be reflected immediately
|
||||
requiresFlushing = true;
|
||||
}
|
||||
} finally {
|
||||
rwl.readLock().unlock();
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ import org.elasticsearch.index.AbstractIndexComponent;
|
|||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.index.analysis.AnalysisService;
|
||||
import org.elasticsearch.index.analysis.NamedAnalyzer;
|
||||
import org.elasticsearch.index.codec.postingsformat.PostingsFormatService;
|
||||
import org.elasticsearch.index.mapper.core.*;
|
||||
import org.elasticsearch.index.mapper.geo.GeoPointFieldMapper;
|
||||
import org.elasticsearch.index.mapper.geo.GeoShapeFieldMapper;
|
||||
|
@ -56,6 +57,7 @@ import static org.elasticsearch.index.mapper.MapperBuilders.doc;
|
|||
public class DocumentMapperParser extends AbstractIndexComponent {
|
||||
|
||||
final AnalysisService analysisService;
|
||||
private final PostingsFormatService postingsFormatService;
|
||||
|
||||
private final RootObjectMapper.TypeParser rootObjectTypeParser = new RootObjectMapper.TypeParser();
|
||||
|
||||
|
@ -64,13 +66,14 @@ public class DocumentMapperParser extends AbstractIndexComponent {
|
|||
private volatile ImmutableMap<String, Mapper.TypeParser> typeParsers;
|
||||
private volatile ImmutableMap<String, Mapper.TypeParser> rootTypeParsers;
|
||||
|
||||
public DocumentMapperParser(Index index, AnalysisService analysisService) {
|
||||
this(index, ImmutableSettings.Builder.EMPTY_SETTINGS, analysisService);
|
||||
public DocumentMapperParser(Index index, AnalysisService analysisService, PostingsFormatService postingsFormatService) {
|
||||
this(index, ImmutableSettings.Builder.EMPTY_SETTINGS, analysisService, postingsFormatService);
|
||||
}
|
||||
|
||||
public DocumentMapperParser(Index index, @IndexSettings Settings indexSettings, AnalysisService analysisService) {
|
||||
public DocumentMapperParser(Index index, @IndexSettings Settings indexSettings, AnalysisService analysisService, PostingsFormatService postingsFormatService) {
|
||||
super(index, indexSettings);
|
||||
this.analysisService = analysisService;
|
||||
this.postingsFormatService = postingsFormatService;
|
||||
MapBuilder<String, Mapper.TypeParser> typeParsersBuilder = new MapBuilder<String, Mapper.TypeParser>()
|
||||
.put(ByteFieldMapper.CONTENT_TYPE, new ByteFieldMapper.TypeParser())
|
||||
.put(ShortFieldMapper.CONTENT_TYPE, new ShortFieldMapper.TypeParser())
|
||||
|
@ -129,7 +132,7 @@ public class DocumentMapperParser extends AbstractIndexComponent {
|
|||
}
|
||||
|
||||
public Mapper.TypeParser.ParserContext parserContext() {
|
||||
return new Mapper.TypeParser.ParserContext(analysisService, typeParsers);
|
||||
return new Mapper.TypeParser.ParserContext(postingsFormatService, analysisService, typeParsers);
|
||||
}
|
||||
|
||||
public DocumentMapper parse(String source) throws MapperParsingException {
|
||||
|
@ -163,7 +166,7 @@ public class DocumentMapperParser extends AbstractIndexComponent {
|
|||
}
|
||||
}
|
||||
|
||||
Mapper.TypeParser.ParserContext parserContext = new Mapper.TypeParser.ParserContext(analysisService, typeParsers);
|
||||
Mapper.TypeParser.ParserContext parserContext = new Mapper.TypeParser.ParserContext(postingsFormatService, analysisService, typeParsers);
|
||||
|
||||
DocumentMapper.Builder docBuilder = doc(index.name(), indexSettings, (RootObjectMapper.Builder) rootObjectTypeParser.parse(type, mapping, parserContext));
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.apache.lucene.search.Filter;
|
|||
import org.apache.lucene.search.MultiTermQuery;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.elasticsearch.common.Nullable;
|
||||
import org.elasticsearch.index.codec.postingsformat.PostingsFormatProvider;
|
||||
import org.elasticsearch.index.field.data.FieldDataType;
|
||||
import org.elasticsearch.index.query.QueryParseContext;
|
||||
|
||||
|
@ -221,4 +222,7 @@ public interface FieldMapper<T> {
|
|||
Filter nullValueFilter();
|
||||
|
||||
FieldDataType fieldDataType();
|
||||
|
||||
PostingsFormatProvider postingFormatProvider();
|
||||
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.elasticsearch.common.Strings;
|
|||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
import org.elasticsearch.index.analysis.AnalysisService;
|
||||
import org.elasticsearch.index.codec.postingsformat.PostingsFormatService;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
@ -76,11 +77,14 @@ public interface Mapper extends ToXContent {
|
|||
|
||||
public static class ParserContext {
|
||||
|
||||
private final PostingsFormatService postingsFormatService;
|
||||
|
||||
private final AnalysisService analysisService;
|
||||
|
||||
private final ImmutableMap<String, TypeParser> typeParsers;
|
||||
|
||||
public ParserContext(AnalysisService analysisService, ImmutableMap<String, TypeParser> typeParsers) {
|
||||
public ParserContext(PostingsFormatService postingsFormatService, AnalysisService analysisService, ImmutableMap<String, TypeParser> typeParsers) {
|
||||
this.postingsFormatService = postingsFormatService;
|
||||
this.analysisService = analysisService;
|
||||
this.typeParsers = typeParsers;
|
||||
}
|
||||
|
@ -89,6 +93,10 @@ public interface Mapper extends ToXContent {
|
|||
return analysisService;
|
||||
}
|
||||
|
||||
public PostingsFormatService postingFormatService() {
|
||||
return postingsFormatService;
|
||||
}
|
||||
|
||||
public TypeParser typeParser(String type) {
|
||||
return typeParsers.get(Strings.toUnderscoreCase(type));
|
||||
}
|
||||
|
|
|
@ -44,6 +44,7 @@ import org.elasticsearch.env.FailedToResolveConfigException;
|
|||
import org.elasticsearch.index.AbstractIndexComponent;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.index.analysis.AnalysisService;
|
||||
import org.elasticsearch.index.codec.postingsformat.PostingsFormatService;
|
||||
import org.elasticsearch.index.mapper.internal.TypeFieldMapper;
|
||||
import org.elasticsearch.index.mapper.object.ObjectMapper;
|
||||
import org.elasticsearch.index.search.nested.NonNestedDocsFilter;
|
||||
|
@ -54,7 +55,6 @@ import org.elasticsearch.indices.TypeMissingException;
|
|||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.Collection;
|
||||
|
@ -71,6 +71,7 @@ public class MapperService extends AbstractIndexComponent implements Iterable<Do
|
|||
public static final String DEFAULT_MAPPING = "_default_";
|
||||
|
||||
private final AnalysisService analysisService;
|
||||
private final PostingsFormatService postingsFormatService;
|
||||
|
||||
/**
|
||||
* Will create types automatically if they do not exists in the mapping definition yet
|
||||
|
@ -98,10 +99,11 @@ public class MapperService extends AbstractIndexComponent implements Iterable<Do
|
|||
private final SmartIndexNameSearchQuoteAnalyzer searchQuoteAnalyzer;
|
||||
|
||||
@Inject
|
||||
public MapperService(Index index, @IndexSettings Settings indexSettings, Environment environment, AnalysisService analysisService) {
|
||||
public MapperService(Index index, @IndexSettings Settings indexSettings, Environment environment, AnalysisService analysisService, PostingsFormatService postingsFormatService) {
|
||||
super(index, indexSettings);
|
||||
this.analysisService = analysisService;
|
||||
this.documentParser = new DocumentMapperParser(index, indexSettings, analysisService);
|
||||
this.postingsFormatService = postingsFormatService;
|
||||
this.documentParser = new DocumentMapperParser(index, indexSettings, analysisService, postingsFormatService);
|
||||
this.searchAnalyzer = new SmartIndexNameSearchAnalyzer(analysisService.defaultSearchAnalyzer());
|
||||
this.searchQuoteAnalyzer = new SmartIndexNameSearchQuoteAnalyzer(analysisService.defaultSearchQuoteAnalyzer());
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ import org.elasticsearch.common.lucene.Lucene;
|
|||
import org.elasticsearch.common.lucene.search.TermFilter;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.index.analysis.NamedAnalyzer;
|
||||
import org.elasticsearch.index.codec.postingsformat.PostingsFormatProvider;
|
||||
import org.elasticsearch.index.field.data.FieldDataType;
|
||||
import org.elasticsearch.index.mapper.*;
|
||||
import org.elasticsearch.index.query.QueryParseContext;
|
||||
|
@ -141,6 +142,7 @@ public abstract class AbstractFieldMapper<T> implements FieldMapper<T>, Mapper {
|
|||
protected NamedAnalyzer searchAnalyzer;
|
||||
protected Boolean includeInAll;
|
||||
protected boolean indexOptionsSet = false;
|
||||
protected PostingsFormatProvider provider;
|
||||
|
||||
protected Builder(String name, FieldType fieldType) {
|
||||
super(name);
|
||||
|
@ -222,6 +224,11 @@ public abstract class AbstractFieldMapper<T> implements FieldMapper<T>, Mapper {
|
|||
return builder;
|
||||
}
|
||||
|
||||
protected T postingsFormat(PostingsFormatProvider postingsFormat) {
|
||||
this.provider = postingsFormat;
|
||||
return builder;
|
||||
}
|
||||
|
||||
protected Names buildNames(BuilderContext context) {
|
||||
return new Names(name, buildIndexName(context), indexName == null ? name : indexName, buildFullName(context), context.path().sourcePath());
|
||||
}
|
||||
|
@ -237,16 +244,14 @@ public abstract class AbstractFieldMapper<T> implements FieldMapper<T>, Mapper {
|
|||
}
|
||||
|
||||
protected final Names names;
|
||||
|
||||
protected float boost;
|
||||
|
||||
protected final FieldType fieldType;
|
||||
|
||||
protected final NamedAnalyzer indexAnalyzer;
|
||||
|
||||
protected final NamedAnalyzer searchAnalyzer;
|
||||
protected PostingsFormatProvider postingsFormat;
|
||||
|
||||
protected AbstractFieldMapper(Names names, float boost, FieldType fieldType, NamedAnalyzer indexAnalyzer, NamedAnalyzer searchAnalyzer) {
|
||||
protected AbstractFieldMapper(Names names, float boost, FieldType fieldType, NamedAnalyzer indexAnalyzer,
|
||||
NamedAnalyzer searchAnalyzer, PostingsFormatProvider postingsFormat) {
|
||||
this.names = names;
|
||||
this.boost = boost;
|
||||
this.fieldType = fieldType;
|
||||
|
@ -264,6 +269,7 @@ public abstract class AbstractFieldMapper<T> implements FieldMapper<T>, Mapper {
|
|||
} else {
|
||||
this.searchAnalyzer = searchAnalyzer;
|
||||
}
|
||||
this.postingsFormat = postingsFormat;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -510,6 +516,9 @@ public abstract class AbstractFieldMapper<T> implements FieldMapper<T>, Mapper {
|
|||
if (!mergeContext.mergeFlags().simulate()) {
|
||||
// apply changeable values
|
||||
this.boost = fieldMergeWith.boost;
|
||||
if (fieldMergeWith.postingsFormat != null) {
|
||||
this.postingsFormat = fieldMergeWith.postingsFormat;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -518,6 +527,11 @@ public abstract class AbstractFieldMapper<T> implements FieldMapper<T>, Mapper {
|
|||
return FieldDataType.DefaultTypes.STRING;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PostingsFormatProvider postingFormatProvider() {
|
||||
return postingsFormat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||
builder.startObject(names.name());
|
||||
|
@ -568,6 +582,9 @@ public abstract class AbstractFieldMapper<T> implements FieldMapper<T>, Mapper {
|
|||
builder.field("search_analyzer", searchAnalyzer.name());
|
||||
}
|
||||
}
|
||||
if (postingsFormat != null) {
|
||||
builder.field("postings_format", postingsFormat.name());
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract String contentType();
|
||||
|
|
|
@ -32,6 +32,7 @@ import org.elasticsearch.common.io.stream.StreamOutput;
|
|||
import org.elasticsearch.common.unit.ByteSizeValue;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.index.codec.postingsformat.PostingsFormatProvider;
|
||||
import org.elasticsearch.index.mapper.*;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -86,7 +87,7 @@ public class BinaryFieldMapper extends AbstractFieldMapper<byte[]> {
|
|||
|
||||
@Override
|
||||
public BinaryFieldMapper build(BuilderContext context) {
|
||||
return new BinaryFieldMapper(buildNames(context), fieldType, compress, compressThreshold);
|
||||
return new BinaryFieldMapper(buildNames(context), fieldType, compress, compressThreshold, provider);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -118,8 +119,8 @@ public class BinaryFieldMapper extends AbstractFieldMapper<byte[]> {
|
|||
|
||||
private long compressThreshold;
|
||||
|
||||
protected BinaryFieldMapper(Names names, FieldType fieldType, Boolean compress, long compressThreshold) {
|
||||
super(names, 1.0f, fieldType, null, null);
|
||||
protected BinaryFieldMapper(Names names, FieldType fieldType, Boolean compress, long compressThreshold, PostingsFormatProvider provider) {
|
||||
super(names, 1.0f, fieldType, null, null, provider);
|
||||
this.compress = compress;
|
||||
this.compressThreshold = compressThreshold;
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.elasticsearch.common.lucene.Lucene;
|
|||
import org.elasticsearch.common.lucene.search.TermFilter;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.index.codec.postingsformat.PostingsFormatProvider;
|
||||
import org.elasticsearch.index.mapper.Mapper;
|
||||
import org.elasticsearch.index.mapper.MapperParsingException;
|
||||
import org.elasticsearch.index.mapper.ParseContext;
|
||||
|
@ -54,6 +55,7 @@ public class BooleanFieldMapper extends AbstractFieldMapper<Boolean> {
|
|||
BOOLEAN_FIELD_TYPE.setOmitNorms(true);
|
||||
BOOLEAN_FIELD_TYPE.freeze();
|
||||
}
|
||||
|
||||
public static final Boolean NULL_VALUE = null;
|
||||
}
|
||||
|
||||
|
@ -114,7 +116,7 @@ public class BooleanFieldMapper extends AbstractFieldMapper<Boolean> {
|
|||
|
||||
@Override
|
||||
public BooleanFieldMapper build(BuilderContext context) {
|
||||
return new BooleanFieldMapper(buildNames(context), boost, fieldType, nullValue);
|
||||
return new BooleanFieldMapper(buildNames(context), boost, fieldType, nullValue, provider);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -136,8 +138,8 @@ public class BooleanFieldMapper extends AbstractFieldMapper<Boolean> {
|
|||
|
||||
private Boolean nullValue;
|
||||
|
||||
protected BooleanFieldMapper(Names names, float boost, FieldType fieldType, Boolean nullValue) {
|
||||
super(names, boost, fieldType, Lucene.KEYWORD_ANALYZER, Lucene.KEYWORD_ANALYZER);
|
||||
protected BooleanFieldMapper(Names names, float boost, FieldType fieldType, Boolean nullValue, PostingsFormatProvider provider) {
|
||||
super(names, boost, fieldType, Lucene.KEYWORD_ANALYZER, Lucene.KEYWORD_ANALYZER, provider);
|
||||
this.nullValue = nullValue;
|
||||
}
|
||||
|
||||
|
|
|
@ -37,6 +37,7 @@ import org.elasticsearch.common.xcontent.XContentParser;
|
|||
import org.elasticsearch.index.analysis.NamedAnalyzer;
|
||||
import org.elasticsearch.index.analysis.NumericIntegerAnalyzer;
|
||||
import org.elasticsearch.index.cache.field.data.FieldDataCache;
|
||||
import org.elasticsearch.index.codec.postingsformat.PostingsFormatProvider;
|
||||
import org.elasticsearch.index.field.data.FieldDataType;
|
||||
import org.elasticsearch.index.mapper.*;
|
||||
import org.elasticsearch.index.query.QueryParseContext;
|
||||
|
@ -62,6 +63,7 @@ public class ByteFieldMapper extends NumberFieldMapper<Byte> {
|
|||
static {
|
||||
BYTE_FIELD_TYPE.freeze();
|
||||
}
|
||||
|
||||
public static final Byte NULL_VALUE = null;
|
||||
}
|
||||
|
||||
|
@ -83,7 +85,8 @@ public class ByteFieldMapper extends NumberFieldMapper<Byte> {
|
|||
public ByteFieldMapper build(BuilderContext context) {
|
||||
fieldType.setOmitNorms(fieldType.omitNorms() && boost == 1.0f);
|
||||
ByteFieldMapper fieldMapper = new ByteFieldMapper(buildNames(context),
|
||||
precisionStep, fuzzyFactor, boost, fieldType, nullValue, ignoreMalformed(context));
|
||||
precisionStep, fuzzyFactor, boost, fieldType, nullValue, ignoreMalformed(context),
|
||||
provider);
|
||||
fieldMapper.includeInAll(includeInAll);
|
||||
return fieldMapper;
|
||||
}
|
||||
|
@ -110,10 +113,10 @@ public class ByteFieldMapper extends NumberFieldMapper<Byte> {
|
|||
private String nullValueAsString;
|
||||
|
||||
protected ByteFieldMapper(Names names, int precisionStep, String fuzzyFactor, float boost, FieldType fieldType,
|
||||
Byte nullValue, Explicit<Boolean> ignoreMalformed) {
|
||||
Byte nullValue, Explicit<Boolean> ignoreMalformed, PostingsFormatProvider provider) {
|
||||
super(names, precisionStep, fuzzyFactor, boost, fieldType,
|
||||
ignoreMalformed, new NamedAnalyzer("_byte/" + precisionStep, new NumericIntegerAnalyzer(precisionStep)),
|
||||
new NamedAnalyzer("_byte/max", new NumericIntegerAnalyzer(Integer.MAX_VALUE)));
|
||||
new NamedAnalyzer("_byte/max", new NumericIntegerAnalyzer(Integer.MAX_VALUE)), provider);
|
||||
this.nullValue = nullValue;
|
||||
this.nullValueAsString = nullValue == null ? null : nullValue.toString();
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@ import org.elasticsearch.common.xcontent.XContentParser;
|
|||
import org.elasticsearch.index.analysis.NamedAnalyzer;
|
||||
import org.elasticsearch.index.analysis.NumericDateAnalyzer;
|
||||
import org.elasticsearch.index.cache.field.data.FieldDataCache;
|
||||
import org.elasticsearch.index.codec.postingsformat.PostingsFormatProvider;
|
||||
import org.elasticsearch.index.field.data.FieldDataType;
|
||||
import org.elasticsearch.index.mapper.*;
|
||||
import org.elasticsearch.index.query.QueryParseContext;
|
||||
|
@ -112,7 +113,7 @@ public class DateFieldMapper extends NumberFieldMapper<Long> {
|
|||
fieldType.setOmitNorms(fieldType.omitNorms() && boost == 1.0f);
|
||||
DateFieldMapper fieldMapper = new DateFieldMapper(buildNames(context), dateTimeFormatter,
|
||||
precisionStep, fuzzyFactor, boost, fieldType, nullValue,
|
||||
timeUnit, parseUpperInclusive, ignoreMalformed(context));
|
||||
timeUnit, parseUpperInclusive, ignoreMalformed(context), provider);
|
||||
fieldMapper.includeInAll(includeInAll);
|
||||
return fieldMapper;
|
||||
}
|
||||
|
@ -150,11 +151,13 @@ public class DateFieldMapper extends NumberFieldMapper<Long> {
|
|||
|
||||
protected DateFieldMapper(Names names, FormatDateTimeFormatter dateTimeFormatter, int precisionStep, String fuzzyFactor,
|
||||
float boost, FieldType fieldType,
|
||||
String nullValue, TimeUnit timeUnit, boolean parseUpperInclusive, Explicit<Boolean> ignoreMalformed) {
|
||||
String nullValue, TimeUnit timeUnit, boolean parseUpperInclusive, Explicit<Boolean> ignoreMalformed,
|
||||
PostingsFormatProvider provider) {
|
||||
super(names, precisionStep, fuzzyFactor, boost, fieldType,
|
||||
ignoreMalformed, new NamedAnalyzer("_date/" + precisionStep,
|
||||
new NumericDateAnalyzer(precisionStep, dateTimeFormatter.parser())),
|
||||
new NamedAnalyzer("_date/max", new NumericDateAnalyzer(Integer.MAX_VALUE, dateTimeFormatter.parser())));
|
||||
new NamedAnalyzer("_date/max", new NumericDateAnalyzer(Integer.MAX_VALUE, dateTimeFormatter.parser())),
|
||||
provider);
|
||||
this.dateTimeFormatter = dateTimeFormatter;
|
||||
this.nullValue = nullValue;
|
||||
this.timeUnit = timeUnit;
|
||||
|
|
|
@ -37,6 +37,7 @@ import org.elasticsearch.common.xcontent.XContentParser;
|
|||
import org.elasticsearch.index.analysis.NamedAnalyzer;
|
||||
import org.elasticsearch.index.analysis.NumericDoubleAnalyzer;
|
||||
import org.elasticsearch.index.cache.field.data.FieldDataCache;
|
||||
import org.elasticsearch.index.codec.postingsformat.PostingsFormatProvider;
|
||||
import org.elasticsearch.index.field.data.FieldDataType;
|
||||
import org.elasticsearch.index.mapper.*;
|
||||
import org.elasticsearch.index.query.QueryParseContext;
|
||||
|
@ -85,7 +86,7 @@ public class DoubleFieldMapper extends NumberFieldMapper<Double> {
|
|||
fieldType.setOmitNorms(fieldType.omitNorms() && boost == 1.0f);
|
||||
DoubleFieldMapper fieldMapper = new DoubleFieldMapper(buildNames(context),
|
||||
precisionStep, fuzzyFactor, boost, fieldType, nullValue,
|
||||
ignoreMalformed(context));
|
||||
ignoreMalformed(context), provider);
|
||||
fieldMapper.includeInAll(includeInAll);
|
||||
return fieldMapper;
|
||||
}
|
||||
|
@ -114,10 +115,11 @@ public class DoubleFieldMapper extends NumberFieldMapper<Double> {
|
|||
|
||||
protected DoubleFieldMapper(Names names, int precisionStep, String fuzzyFactor,
|
||||
float boost, FieldType fieldType,
|
||||
Double nullValue, Explicit<Boolean> ignoreMalformed) {
|
||||
Double nullValue, Explicit<Boolean> ignoreMalformed,
|
||||
PostingsFormatProvider provider) {
|
||||
super(names, precisionStep, fuzzyFactor, boost, fieldType,
|
||||
ignoreMalformed, new NamedAnalyzer("_double/" + precisionStep, new NumericDoubleAnalyzer(precisionStep)),
|
||||
new NamedAnalyzer("_double/max", new NumericDoubleAnalyzer(Integer.MAX_VALUE)));
|
||||
new NamedAnalyzer("_double/max", new NumericDoubleAnalyzer(Integer.MAX_VALUE)), provider);
|
||||
this.nullValue = nullValue;
|
||||
this.nullValueAsString = nullValue == null ? null : nullValue.toString();
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ import org.elasticsearch.common.xcontent.XContentParser;
|
|||
import org.elasticsearch.index.analysis.NamedAnalyzer;
|
||||
import org.elasticsearch.index.analysis.NumericFloatAnalyzer;
|
||||
import org.elasticsearch.index.cache.field.data.FieldDataCache;
|
||||
import org.elasticsearch.index.codec.postingsformat.PostingsFormatProvider;
|
||||
import org.elasticsearch.index.field.data.FieldDataType;
|
||||
import org.elasticsearch.index.mapper.*;
|
||||
import org.elasticsearch.index.query.QueryParseContext;
|
||||
|
@ -86,7 +87,7 @@ public class FloatFieldMapper extends NumberFieldMapper<Float> {
|
|||
fieldType.setOmitNorms(fieldType.omitNorms() && boost == 1.0f);
|
||||
FloatFieldMapper fieldMapper = new FloatFieldMapper(buildNames(context),
|
||||
precisionStep, fuzzyFactor, boost, fieldType, nullValue,
|
||||
ignoreMalformed(context));
|
||||
ignoreMalformed(context), provider);
|
||||
fieldMapper.includeInAll(includeInAll);
|
||||
return fieldMapper;
|
||||
}
|
||||
|
@ -113,10 +114,10 @@ public class FloatFieldMapper extends NumberFieldMapper<Float> {
|
|||
private String nullValueAsString;
|
||||
|
||||
protected FloatFieldMapper(Names names, int precisionStep, String fuzzyFactor, float boost, FieldType fieldType,
|
||||
Float nullValue, Explicit<Boolean> ignoreMalformed) {
|
||||
Float nullValue, Explicit<Boolean> ignoreMalformed, PostingsFormatProvider provider) {
|
||||
super(names, precisionStep, fuzzyFactor, boost, fieldType,
|
||||
ignoreMalformed, new NamedAnalyzer("_float/" + precisionStep, new NumericFloatAnalyzer(precisionStep)),
|
||||
new NamedAnalyzer("_float/max", new NumericFloatAnalyzer(Integer.MAX_VALUE)));
|
||||
new NamedAnalyzer("_float/max", new NumericFloatAnalyzer(Integer.MAX_VALUE)), provider);
|
||||
this.nullValue = nullValue;
|
||||
this.nullValueAsString = nullValue == null ? null : nullValue.toString();
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ import org.elasticsearch.common.xcontent.XContentParser;
|
|||
import org.elasticsearch.index.analysis.NamedAnalyzer;
|
||||
import org.elasticsearch.index.analysis.NumericIntegerAnalyzer;
|
||||
import org.elasticsearch.index.cache.field.data.FieldDataCache;
|
||||
import org.elasticsearch.index.codec.postingsformat.PostingsFormatProvider;
|
||||
import org.elasticsearch.index.field.data.FieldDataType;
|
||||
import org.elasticsearch.index.mapper.*;
|
||||
import org.elasticsearch.index.query.QueryParseContext;
|
||||
|
@ -86,7 +87,7 @@ public class IntegerFieldMapper extends NumberFieldMapper<Integer> {
|
|||
fieldType.setOmitNorms(fieldType.omitNorms() && boost == 1.0f);
|
||||
IntegerFieldMapper fieldMapper = new IntegerFieldMapper(buildNames(context),
|
||||
precisionStep, fuzzyFactor, boost, fieldType,
|
||||
nullValue, ignoreMalformed(context));
|
||||
nullValue, ignoreMalformed(context), provider);
|
||||
fieldMapper.includeInAll(includeInAll);
|
||||
return fieldMapper;
|
||||
}
|
||||
|
@ -114,10 +115,11 @@ public class IntegerFieldMapper extends NumberFieldMapper<Integer> {
|
|||
|
||||
protected IntegerFieldMapper(Names names, int precisionStep, String fuzzyFactor,
|
||||
float boost, FieldType fieldType,
|
||||
Integer nullValue, Explicit<Boolean> ignoreMalformed) {
|
||||
Integer nullValue, Explicit<Boolean> ignoreMalformed,
|
||||
PostingsFormatProvider provider) {
|
||||
super(names, precisionStep, fuzzyFactor, boost, fieldType,
|
||||
ignoreMalformed, new NamedAnalyzer("_int/" + precisionStep, new NumericIntegerAnalyzer(precisionStep)),
|
||||
new NamedAnalyzer("_int/max", new NumericIntegerAnalyzer(Integer.MAX_VALUE)));
|
||||
new NamedAnalyzer("_int/max", new NumericIntegerAnalyzer(Integer.MAX_VALUE)), provider);
|
||||
this.nullValue = nullValue;
|
||||
this.nullValueAsString = nullValue == null ? null : nullValue.toString();
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ import org.elasticsearch.common.xcontent.XContentParser;
|
|||
import org.elasticsearch.index.analysis.NamedAnalyzer;
|
||||
import org.elasticsearch.index.analysis.NumericLongAnalyzer;
|
||||
import org.elasticsearch.index.cache.field.data.FieldDataCache;
|
||||
import org.elasticsearch.index.codec.postingsformat.PostingsFormatProvider;
|
||||
import org.elasticsearch.index.field.data.FieldDataType;
|
||||
import org.elasticsearch.index.mapper.*;
|
||||
import org.elasticsearch.index.query.QueryParseContext;
|
||||
|
@ -86,7 +87,7 @@ public class LongFieldMapper extends NumberFieldMapper<Long> {
|
|||
fieldType.setOmitNorms(fieldType.omitNorms() && boost != 1.0f);
|
||||
LongFieldMapper fieldMapper = new LongFieldMapper(buildNames(context),
|
||||
precisionStep, fuzzyFactor, boost, fieldType, nullValue,
|
||||
ignoreMalformed(context));
|
||||
ignoreMalformed(context), provider);
|
||||
fieldMapper.includeInAll(includeInAll);
|
||||
return fieldMapper;
|
||||
}
|
||||
|
@ -114,10 +115,11 @@ public class LongFieldMapper extends NumberFieldMapper<Long> {
|
|||
|
||||
protected LongFieldMapper(Names names, int precisionStep, String fuzzyFactor,
|
||||
float boost, FieldType fieldType,
|
||||
Long nullValue, Explicit<Boolean> ignoreMalformed) {
|
||||
Long nullValue, Explicit<Boolean> ignoreMalformed,
|
||||
PostingsFormatProvider provider) {
|
||||
super(names, precisionStep, fuzzyFactor, boost, fieldType,
|
||||
ignoreMalformed, new NamedAnalyzer("_long/" + precisionStep, new NumericLongAnalyzer(precisionStep)),
|
||||
new NamedAnalyzer("_long/max", new NumericLongAnalyzer(Integer.MAX_VALUE)));
|
||||
new NamedAnalyzer("_long/max", new NumericLongAnalyzer(Integer.MAX_VALUE)), provider);
|
||||
this.nullValue = nullValue;
|
||||
this.nullValueAsString = nullValue == null ? null : nullValue.toString();
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ import org.elasticsearch.common.Nullable;
|
|||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.index.analysis.NamedAnalyzer;
|
||||
import org.elasticsearch.index.cache.field.data.FieldDataCache;
|
||||
import org.elasticsearch.index.codec.postingsformat.PostingsFormatProvider;
|
||||
import org.elasticsearch.index.field.data.FieldDataType;
|
||||
import org.elasticsearch.index.mapper.*;
|
||||
import org.elasticsearch.index.mapper.internal.AllFieldMapper;
|
||||
|
@ -139,9 +140,10 @@ public abstract class NumberFieldMapper<T extends Number> extends AbstractFieldM
|
|||
|
||||
protected NumberFieldMapper(Names names, int precisionStep, @Nullable String fuzzyFactor,
|
||||
float boost, FieldType fieldType,
|
||||
Explicit<Boolean> ignoreMalformed, NamedAnalyzer indexAnalyzer, NamedAnalyzer searchAnalyzer) {
|
||||
Explicit<Boolean> ignoreMalformed, NamedAnalyzer indexAnalyzer,
|
||||
NamedAnalyzer searchAnalyzer, PostingsFormatProvider provider) {
|
||||
// LUCENE 4 UPGRADE: Since we can't do anything before the super call, we have to push the boost check down to subclasses
|
||||
super(names, boost, fieldType, indexAnalyzer, searchAnalyzer);
|
||||
super(names, boost, fieldType, indexAnalyzer, searchAnalyzer, provider);
|
||||
if (precisionStep <= 0 || precisionStep >= maxPrecisionStep()) {
|
||||
this.precisionStep = Integer.MAX_VALUE;
|
||||
} else {
|
||||
|
|
|
@ -38,6 +38,7 @@ import org.elasticsearch.common.xcontent.XContentParser;
|
|||
import org.elasticsearch.index.analysis.NamedAnalyzer;
|
||||
import org.elasticsearch.index.analysis.NumericIntegerAnalyzer;
|
||||
import org.elasticsearch.index.cache.field.data.FieldDataCache;
|
||||
import org.elasticsearch.index.codec.postingsformat.PostingsFormatProvider;
|
||||
import org.elasticsearch.index.field.data.FieldDataType;
|
||||
import org.elasticsearch.index.mapper.*;
|
||||
import org.elasticsearch.index.query.QueryParseContext;
|
||||
|
@ -86,7 +87,7 @@ public class ShortFieldMapper extends NumberFieldMapper<Short> {
|
|||
fieldType.setOmitNorms(fieldType.omitNorms() && boost == 1.0f);
|
||||
ShortFieldMapper fieldMapper = new ShortFieldMapper(buildNames(context),
|
||||
precisionStep, fuzzyFactor, boost, fieldType, nullValue,
|
||||
ignoreMalformed(context));
|
||||
ignoreMalformed(context), provider);
|
||||
fieldMapper.includeInAll(includeInAll);
|
||||
return fieldMapper;
|
||||
}
|
||||
|
@ -114,10 +115,11 @@ public class ShortFieldMapper extends NumberFieldMapper<Short> {
|
|||
|
||||
protected ShortFieldMapper(Names names, int precisionStep, String fuzzyFactor,
|
||||
float boost, FieldType fieldType,
|
||||
Short nullValue, Explicit<Boolean> ignoreMalformed) {
|
||||
Short nullValue, Explicit<Boolean> ignoreMalformed,
|
||||
PostingsFormatProvider provider) {
|
||||
super(names, precisionStep, fuzzyFactor, boost, fieldType,
|
||||
ignoreMalformed, new NamedAnalyzer("_short/" + precisionStep, new NumericIntegerAnalyzer(precisionStep)),
|
||||
new NamedAnalyzer("_short/max", new NumericIntegerAnalyzer(Integer.MAX_VALUE)));
|
||||
new NamedAnalyzer("_short/max", new NumericIntegerAnalyzer(Integer.MAX_VALUE)), provider);
|
||||
this.nullValue = nullValue;
|
||||
this.nullValueAsString = nullValue == null ? null : nullValue.toString();
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ import org.elasticsearch.common.xcontent.XContentParser;
|
|||
import org.elasticsearch.common.xcontent.support.XContentMapValues;
|
||||
import org.elasticsearch.index.analysis.NamedAnalyzer;
|
||||
import org.elasticsearch.index.analysis.NamedCustomAnalyzer;
|
||||
import org.elasticsearch.index.codec.postingsformat.PostingsFormatProvider;
|
||||
import org.elasticsearch.index.mapper.*;
|
||||
import org.elasticsearch.index.mapper.internal.AllFieldMapper;
|
||||
|
||||
|
@ -128,8 +129,8 @@ public class StringFieldMapper extends AbstractFieldMapper<String> implements Al
|
|||
}
|
||||
}
|
||||
StringFieldMapper fieldMapper = new StringFieldMapper(buildNames(context),
|
||||
boost, fieldType, nullValue,
|
||||
indexAnalyzer, searchAnalyzer, searchQuotedAnalyzer, positionOffsetGap, ignoreAbove);
|
||||
boost, fieldType, nullValue, indexAnalyzer, searchAnalyzer, searchQuotedAnalyzer,
|
||||
positionOffsetGap, ignoreAbove, provider);
|
||||
fieldMapper.includeInAll(includeInAll);
|
||||
return fieldMapper;
|
||||
}
|
||||
|
@ -183,15 +184,17 @@ public class StringFieldMapper extends AbstractFieldMapper<String> implements Al
|
|||
private int ignoreAbove;
|
||||
|
||||
protected StringFieldMapper(Names names, float boost, FieldType fieldType,
|
||||
String nullValue, NamedAnalyzer indexAnalyzer, NamedAnalyzer searchAnalyzer) {
|
||||
this(names, boost, fieldType, nullValue, indexAnalyzer,
|
||||
searchAnalyzer, searchAnalyzer, Defaults.POSITION_OFFSET_GAP, Defaults.IGNORE_ABOVE);
|
||||
String nullValue, NamedAnalyzer indexAnalyzer, NamedAnalyzer searchAnalyzer,
|
||||
PostingsFormatProvider postingsFormat) {
|
||||
this(names, boost, fieldType, nullValue, indexAnalyzer, searchAnalyzer, searchAnalyzer,
|
||||
Defaults.POSITION_OFFSET_GAP, Defaults.IGNORE_ABOVE, postingsFormat);
|
||||
}
|
||||
|
||||
protected StringFieldMapper(Names names, float boost, FieldType fieldType,
|
||||
String nullValue, NamedAnalyzer indexAnalyzer, NamedAnalyzer searchAnalyzer,
|
||||
NamedAnalyzer searchQuotedAnalyzer, int positionOffsetGap, int ignoreAbove) {
|
||||
super(names, boost, fieldType, indexAnalyzer, searchAnalyzer);
|
||||
NamedAnalyzer searchQuotedAnalyzer, int positionOffsetGap, int ignoreAbove,
|
||||
PostingsFormatProvider postingsFormat) {
|
||||
super(names, boost, fieldType, indexAnalyzer, searchAnalyzer, postingsFormat);
|
||||
this.nullValue = nullValue;
|
||||
this.positionOffsetGap = positionOffsetGap;
|
||||
this.searchQuotedAnalyzer = searchQuotedAnalyzer != null ? searchQuotedAnalyzer : this.searchAnalyzer;
|
||||
|
|
|
@ -111,6 +111,9 @@ public class TypeParsers {
|
|||
builder.searchAnalyzer(analyzer);
|
||||
} else if (propName.equals("include_in_all")) {
|
||||
builder.includeInAll(nodeBooleanValue(propNode));
|
||||
} else if (propName.equals("postings_format")) {
|
||||
String postingFormatName = propNode.toString();
|
||||
builder.postingsFormat(parserContext.postingFormatService().get(postingFormatName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
|
|||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.support.XContentMapValues;
|
||||
import org.elasticsearch.index.analysis.NamedAnalyzer;
|
||||
import org.elasticsearch.index.codec.postingsformat.PostingsFormatProvider;
|
||||
import org.elasticsearch.index.field.data.FieldDataType;
|
||||
import org.elasticsearch.index.mapper.*;
|
||||
import org.elasticsearch.index.mapper.core.AbstractFieldMapper;
|
||||
|
@ -55,8 +56,6 @@ import static org.elasticsearch.index.mapper.core.TypeParsers.parseStore;
|
|||
* "lat" : 1.1,
|
||||
* "lon" : 2.1
|
||||
* }
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class GeoPointFieldMapper implements Mapper, ArrayValueMapperParser {
|
||||
|
||||
|
@ -384,7 +383,7 @@ public class GeoPointFieldMapper implements Mapper, ArrayValueMapperParser {
|
|||
}
|
||||
|
||||
private void parseLatLon(ParseContext context, double lat, double lon) throws IOException {
|
||||
if (normalizeLat || normalizeLon) {
|
||||
if (normalizeLat || normalizeLon) {
|
||||
Point point = new Point(lat, lon);
|
||||
GeoUtils.normalizePoint(point, normalizeLat, normalizeLon);
|
||||
lat = point.lat;
|
||||
|
@ -562,8 +561,7 @@ public class GeoPointFieldMapper implements Mapper, ArrayValueMapperParser {
|
|||
@Override
|
||||
public GeoStringFieldMapper build(BuilderContext context) {
|
||||
GeoStringFieldMapper fieldMapper = new GeoStringFieldMapper(buildNames(context),
|
||||
boost, fieldType, nullValue,
|
||||
indexAnalyzer, searchAnalyzer);
|
||||
boost, fieldType, nullValue, indexAnalyzer, searchAnalyzer, provider);
|
||||
fieldMapper.includeInAll(includeInAll);
|
||||
return fieldMapper;
|
||||
}
|
||||
|
@ -571,8 +569,10 @@ public class GeoPointFieldMapper implements Mapper, ArrayValueMapperParser {
|
|||
|
||||
GeoPointFieldMapper geoMapper;
|
||||
|
||||
public GeoStringFieldMapper(Names names, float boost, FieldType fieldType, String nullValue, NamedAnalyzer indexAnalyzer, NamedAnalyzer searchAnalyzer) {
|
||||
super(names, boost, fieldType, nullValue, indexAnalyzer, searchAnalyzer);
|
||||
public GeoStringFieldMapper(Names names, float boost, FieldType fieldType, String nullValue,
|
||||
NamedAnalyzer indexAnalyzer, NamedAnalyzer searchAnalyzer,
|
||||
PostingsFormatProvider provider) {
|
||||
super(names, boost, fieldType, nullValue, indexAnalyzer, searchAnalyzer, provider);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -13,6 +13,7 @@ import org.elasticsearch.common.lucene.spatial.prefix.tree.GeohashPrefixTree;
|
|||
import org.elasticsearch.common.lucene.spatial.prefix.tree.QuadPrefixTree;
|
||||
import org.elasticsearch.common.lucene.spatial.prefix.tree.SpatialPrefixTree;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.index.codec.postingsformat.PostingsFormatProvider;
|
||||
import org.elasticsearch.index.mapper.FieldMapper;
|
||||
import org.elasticsearch.index.mapper.Mapper;
|
||||
import org.elasticsearch.index.mapper.MapperParsingException;
|
||||
|
@ -108,7 +109,7 @@ public class GeoShapeFieldMapper extends AbstractFieldMapper<String> {
|
|||
throw new ElasticSearchIllegalArgumentException("Unknown prefix tree type [" + tree + "]");
|
||||
}
|
||||
|
||||
return new GeoShapeFieldMapper(buildNames(context), prefixTree, distanceErrorPct, fieldType);
|
||||
return new GeoShapeFieldMapper(buildNames(context), prefixTree, distanceErrorPct, fieldType, provider);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -135,8 +136,9 @@ public class GeoShapeFieldMapper extends AbstractFieldMapper<String> {
|
|||
|
||||
private final SpatialStrategy spatialStrategy;
|
||||
|
||||
public GeoShapeFieldMapper(FieldMapper.Names names, SpatialPrefixTree prefixTree, double distanceErrorPct, FieldType fieldType) {
|
||||
super(names, 1, fieldType, null, null);
|
||||
public GeoShapeFieldMapper(FieldMapper.Names names, SpatialPrefixTree prefixTree, double distanceErrorPct,
|
||||
FieldType fieldType, PostingsFormatProvider provider) {
|
||||
super(names, 1, fieldType, null, null, provider);
|
||||
this.spatialStrategy = new TermQueryPrefixTreeStrategy(names, prefixTree, distanceErrorPct);
|
||||
}
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ import org.elasticsearch.common.lucene.all.AllField;
|
|||
import org.elasticsearch.common.lucene.all.AllTermQuery;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.index.analysis.NamedAnalyzer;
|
||||
import org.elasticsearch.index.codec.postingsformat.PostingsFormatProvider;
|
||||
import org.elasticsearch.index.mapper.*;
|
||||
import org.elasticsearch.index.mapper.core.AbstractFieldMapper;
|
||||
import org.elasticsearch.index.query.QueryParseContext;
|
||||
|
@ -97,8 +98,7 @@ public class AllFieldMapper extends AbstractFieldMapper<Void> implements Interna
|
|||
fieldType.setIndexed(true);
|
||||
fieldType.setTokenized(true);
|
||||
|
||||
return new AllFieldMapper(name, fieldType,
|
||||
indexAnalyzer, searchAnalyzer, enabled, autoBoost);
|
||||
return new AllFieldMapper(name, fieldType, indexAnalyzer, searchAnalyzer, enabled, autoBoost, provider);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -130,12 +130,12 @@ public class AllFieldMapper extends AbstractFieldMapper<Void> implements Interna
|
|||
private volatile boolean autoBoost;
|
||||
|
||||
public AllFieldMapper() {
|
||||
this(Defaults.NAME, new FieldType(Defaults.ALL_FIELD_TYPE), null, null, Defaults.ENABLED, false);
|
||||
this(Defaults.NAME, new FieldType(Defaults.ALL_FIELD_TYPE), null, null, Defaults.ENABLED, false, null);
|
||||
}
|
||||
|
||||
protected AllFieldMapper(String name, FieldType fieldType,
|
||||
NamedAnalyzer indexAnalyzer, NamedAnalyzer searchAnalyzer, boolean enabled, boolean autoBoost) {
|
||||
super(new Names(name, name, name, name), 1.0f, fieldType, indexAnalyzer, searchAnalyzer);
|
||||
protected AllFieldMapper(String name, FieldType fieldType, NamedAnalyzer indexAnalyzer, NamedAnalyzer searchAnalyzer,
|
||||
boolean enabled, boolean autoBoost, PostingsFormatProvider provider) {
|
||||
super(new Names(name, name, name, name), 1.0f, fieldType, indexAnalyzer, searchAnalyzer, provider);
|
||||
this.enabled = enabled;
|
||||
this.autoBoost = autoBoost;
|
||||
|
||||
|
@ -248,8 +248,8 @@ public class AllFieldMapper extends AbstractFieldMapper<Void> implements Interna
|
|||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||
// if all are defaults, no need to write it at all
|
||||
if (enabled == Defaults.ENABLED && stored() == Defaults.ALL_FIELD_TYPE.stored() &&
|
||||
storeTermVectors() == Defaults.ALL_FIELD_TYPE.storeTermVectors() &&
|
||||
indexAnalyzer == null && searchAnalyzer == null) {
|
||||
storeTermVectors() == Defaults.ALL_FIELD_TYPE.storeTermVectors() &&
|
||||
indexAnalyzer == null && searchAnalyzer == null) {
|
||||
return builder;
|
||||
}
|
||||
builder.startObject(CONTENT_TYPE);
|
||||
|
|
|
@ -35,6 +35,7 @@ import org.elasticsearch.common.xcontent.XContentParser;
|
|||
import org.elasticsearch.index.analysis.NamedAnalyzer;
|
||||
import org.elasticsearch.index.analysis.NumericFloatAnalyzer;
|
||||
import org.elasticsearch.index.cache.field.data.FieldDataCache;
|
||||
import org.elasticsearch.index.codec.postingsformat.PostingsFormatProvider;
|
||||
import org.elasticsearch.index.field.data.FieldDataType;
|
||||
import org.elasticsearch.index.mapper.*;
|
||||
import org.elasticsearch.index.mapper.core.FloatFieldMapper;
|
||||
|
@ -85,7 +86,7 @@ public class BoostFieldMapper extends NumberFieldMapper<Float> implements Intern
|
|||
@Override
|
||||
public BoostFieldMapper build(BuilderContext context) {
|
||||
return new BoostFieldMapper(name, buildIndexName(context),
|
||||
precisionStep, boost, fieldType, nullValue);
|
||||
precisionStep, boost, fieldType, nullValue, provider);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -113,14 +114,15 @@ public class BoostFieldMapper extends NumberFieldMapper<Float> implements Intern
|
|||
}
|
||||
|
||||
protected BoostFieldMapper(String name, String indexName) {
|
||||
this(name, indexName, Defaults.PRECISION_STEP, Defaults.BOOST, new FieldType(Defaults.BOOST_FIELD_TYPE), Defaults.NULL_VALUE);
|
||||
this(name, indexName, Defaults.PRECISION_STEP, Defaults.BOOST, new FieldType(Defaults.BOOST_FIELD_TYPE),
|
||||
Defaults.NULL_VALUE, null);
|
||||
}
|
||||
|
||||
protected BoostFieldMapper(String name, String indexName, int precisionStep,
|
||||
float boost, FieldType fieldType, Float nullValue) {
|
||||
protected BoostFieldMapper(String name, String indexName, int precisionStep, float boost, FieldType fieldType,
|
||||
Float nullValue, PostingsFormatProvider provider) {
|
||||
super(new Names(name, indexName, indexName, name), precisionStep, null, boost, fieldType,
|
||||
Defaults.IGNORE_MALFORMED, new NamedAnalyzer("_float/" + precisionStep, new NumericFloatAnalyzer(precisionStep)),
|
||||
new NamedAnalyzer("_float/max", new NumericFloatAnalyzer(Integer.MAX_VALUE)));
|
||||
new NamedAnalyzer("_float/max", new NumericFloatAnalyzer(Integer.MAX_VALUE)), provider);
|
||||
this.nullValue = nullValue;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ import org.elasticsearch.common.lucene.Lucene;
|
|||
import org.elasticsearch.common.lucene.search.XBooleanFilter;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.index.codec.postingsformat.PostingsFormatProvider;
|
||||
import org.elasticsearch.index.mapper.*;
|
||||
import org.elasticsearch.index.mapper.core.AbstractFieldMapper;
|
||||
import org.elasticsearch.index.query.QueryParseContext;
|
||||
|
@ -87,7 +88,7 @@ public class IdFieldMapper extends AbstractFieldMapper<String> implements Intern
|
|||
|
||||
@Override
|
||||
public IdFieldMapper build(BuilderContext context) {
|
||||
return new IdFieldMapper(name, indexName, boost, fieldType, path);
|
||||
return new IdFieldMapper(name, indexName, boost, fieldType, path, provider);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -118,12 +119,13 @@ public class IdFieldMapper extends AbstractFieldMapper<String> implements Intern
|
|||
}
|
||||
|
||||
protected IdFieldMapper(String name, String indexName, FieldType fieldType) {
|
||||
this(name, indexName, Defaults.BOOST, fieldType, Defaults.PATH);
|
||||
this(name, indexName, Defaults.BOOST, fieldType, Defaults.PATH, null);
|
||||
}
|
||||
|
||||
protected IdFieldMapper(String name, String indexName, float boost, FieldType fieldType, String path) {
|
||||
protected IdFieldMapper(String name, String indexName, float boost, FieldType fieldType, String path,
|
||||
PostingsFormatProvider provider) {
|
||||
super(new Names(name, indexName, indexName, name), boost, fieldType, Lucene.KEYWORD_ANALYZER,
|
||||
Lucene.KEYWORD_ANALYZER);
|
||||
Lucene.KEYWORD_ANALYZER, provider);
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,11 +22,12 @@ package org.elasticsearch.index.mapper.internal;
|
|||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.document.FieldType;
|
||||
import org.apache.lucene.index.Term;
|
||||
import org.apache.lucene.index.FieldInfo.IndexOptions;
|
||||
import org.apache.lucene.index.Term;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.lucene.Lucene;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.index.codec.postingsformat.PostingsFormatProvider;
|
||||
import org.elasticsearch.index.mapper.*;
|
||||
import org.elasticsearch.index.mapper.core.AbstractFieldMapper;
|
||||
|
||||
|
@ -79,7 +80,7 @@ public class IndexFieldMapper extends AbstractFieldMapper<String> implements Int
|
|||
|
||||
@Override
|
||||
public IndexFieldMapper build(BuilderContext context) {
|
||||
return new IndexFieldMapper(name, indexName, boost, fieldType, enabled);
|
||||
return new IndexFieldMapper(name, indexName, boost, fieldType, enabled, provider);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -107,12 +108,13 @@ public class IndexFieldMapper extends AbstractFieldMapper<String> implements Int
|
|||
}
|
||||
|
||||
protected IndexFieldMapper(String name, String indexName) {
|
||||
this(name, indexName, Defaults.BOOST, new FieldType(Defaults.INDEX_FIELD_TYPE), Defaults.ENABLED);
|
||||
this(name, indexName, Defaults.BOOST, new FieldType(Defaults.INDEX_FIELD_TYPE), Defaults.ENABLED, null);
|
||||
}
|
||||
|
||||
public IndexFieldMapper(String name, String indexName, float boost, FieldType fieldType, boolean enabled) {
|
||||
public IndexFieldMapper(String name, String indexName, float boost, FieldType fieldType, boolean enabled,
|
||||
PostingsFormatProvider provider) {
|
||||
super(new Names(name, indexName, indexName, name), boost, fieldType, Lucene.KEYWORD_ANALYZER,
|
||||
Lucene.KEYWORD_ANALYZER);
|
||||
Lucene.KEYWORD_ANALYZER, provider);
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.elasticsearch.common.Nullable;
|
|||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.lucene.Lucene;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.index.codec.postingsformat.PostingsFormatProvider;
|
||||
import org.elasticsearch.index.mapper.*;
|
||||
import org.elasticsearch.index.mapper.core.AbstractFieldMapper;
|
||||
import org.elasticsearch.index.query.QueryParseContext;
|
||||
|
@ -67,6 +68,7 @@ public class ParentFieldMapper extends AbstractFieldMapper<Uid> implements Inter
|
|||
protected String indexName;
|
||||
|
||||
private String type;
|
||||
protected PostingsFormatProvider postingsFormat;
|
||||
|
||||
public Builder() {
|
||||
super(Defaults.NAME);
|
||||
|
@ -78,12 +80,17 @@ public class ParentFieldMapper extends AbstractFieldMapper<Uid> implements Inter
|
|||
return builder;
|
||||
}
|
||||
|
||||
protected Builder postingsFormat(PostingsFormatProvider postingsFormat) {
|
||||
this.postingsFormat = postingsFormat;
|
||||
return builder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ParentFieldMapper build(BuilderContext context) {
|
||||
if (type == null) {
|
||||
throw new MapperParsingException("Parent mapping must contain the parent type");
|
||||
}
|
||||
return new ParentFieldMapper(name, indexName, type);
|
||||
return new ParentFieldMapper(name, indexName, type, postingsFormat);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -96,6 +103,9 @@ public class ParentFieldMapper extends AbstractFieldMapper<Uid> implements Inter
|
|||
Object fieldNode = entry.getValue();
|
||||
if (fieldName.equals("type")) {
|
||||
builder.type(fieldNode.toString());
|
||||
} else if (fieldName.equals("postings_format")) {
|
||||
String postingFormatName = fieldNode.toString();
|
||||
builder.postingsFormat(parserContext.postingFormatService().get(postingFormatName));
|
||||
}
|
||||
}
|
||||
return builder;
|
||||
|
@ -104,9 +114,9 @@ public class ParentFieldMapper extends AbstractFieldMapper<Uid> implements Inter
|
|||
|
||||
private final String type;
|
||||
|
||||
protected ParentFieldMapper(String name, String indexName, String type) {
|
||||
protected ParentFieldMapper(String name, String indexName, String type, PostingsFormatProvider postingsFormat) {
|
||||
super(new Names(name, indexName, indexName, name), Defaults.BOOST, new FieldType(Defaults.PARENT_FIELD_TYPE),
|
||||
Lucene.KEYWORD_ANALYZER, Lucene.KEYWORD_ANALYZER);
|
||||
Lucene.KEYWORD_ANALYZER, Lucene.KEYWORD_ANALYZER, postingsFormat);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.apache.lucene.index.FieldInfo.IndexOptions;
|
|||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.lucene.Lucene;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.index.codec.postingsformat.PostingsFormatProvider;
|
||||
import org.elasticsearch.index.mapper.*;
|
||||
import org.elasticsearch.index.mapper.core.AbstractFieldMapper;
|
||||
import org.elasticsearch.index.mapper.core.NumberFieldMapper;
|
||||
|
@ -85,7 +86,7 @@ public class RoutingFieldMapper extends AbstractFieldMapper<String> implements I
|
|||
|
||||
@Override
|
||||
public RoutingFieldMapper build(BuilderContext context) {
|
||||
return new RoutingFieldMapper(fieldType, required, path);
|
||||
return new RoutingFieldMapper(fieldType, required, path, provider);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -113,12 +114,12 @@ public class RoutingFieldMapper extends AbstractFieldMapper<String> implements I
|
|||
private final String path;
|
||||
|
||||
public RoutingFieldMapper() {
|
||||
this(new FieldType(Defaults.ROUTING_FIELD_TYPE), Defaults.REQUIRED, Defaults.PATH);
|
||||
this(new FieldType(Defaults.ROUTING_FIELD_TYPE), Defaults.REQUIRED, Defaults.PATH, null);
|
||||
}
|
||||
|
||||
protected RoutingFieldMapper(FieldType fieldType, boolean required, String path) {
|
||||
protected RoutingFieldMapper(FieldType fieldType, boolean required, String path, PostingsFormatProvider provider) {
|
||||
super(new Names(Defaults.NAME, Defaults.NAME, Defaults.NAME, Defaults.NAME), 1.0f, fieldType, Lucene.KEYWORD_ANALYZER,
|
||||
Lucene.KEYWORD_ANALYZER);
|
||||
Lucene.KEYWORD_ANALYZER, provider);
|
||||
this.required = required;
|
||||
this.path = path;
|
||||
}
|
||||
|
@ -231,7 +232,7 @@ public class RoutingFieldMapper extends AbstractFieldMapper<String> implements I
|
|||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||
// if all are defaults, no sense to write it at all
|
||||
if (indexed() == Defaults.ROUTING_FIELD_TYPE.indexed() &&
|
||||
stored() == Defaults.ROUTING_FIELD_TYPE.stored() && required == Defaults.REQUIRED && path == Defaults.PATH) {
|
||||
stored() == Defaults.ROUTING_FIELD_TYPE.stored() && required == Defaults.REQUIRED && path == Defaults.PATH) {
|
||||
return builder;
|
||||
}
|
||||
builder.startObject(CONTENT_TYPE);
|
||||
|
|
|
@ -23,8 +23,10 @@ import org.apache.lucene.document.Field;
|
|||
import org.apache.lucene.document.FieldType;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.index.codec.postingsformat.PostingsFormatProvider;
|
||||
import org.elasticsearch.index.mapper.*;
|
||||
import org.elasticsearch.index.mapper.core.IntegerFieldMapper;
|
||||
import org.elasticsearch.index.mapper.core.NumberFieldMapper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
@ -48,15 +50,12 @@ public class SizeFieldMapper extends IntegerFieldMapper implements RootMapper {
|
|||
}
|
||||
}
|
||||
|
||||
public static class Builder extends Mapper.Builder<Builder, IntegerFieldMapper> {
|
||||
public static class Builder extends NumberFieldMapper.Builder<Builder, IntegerFieldMapper> {
|
||||
|
||||
protected boolean enabled = Defaults.ENABLED;
|
||||
|
||||
protected final FieldType fieldType;
|
||||
|
||||
public Builder() {
|
||||
super(Defaults.NAME);
|
||||
fieldType = new FieldType(Defaults.SIZE_FIELD_TYPE);
|
||||
super(Defaults.NAME, new FieldType(Defaults.SIZE_FIELD_TYPE));
|
||||
builder = this;
|
||||
}
|
||||
|
||||
|
@ -72,7 +71,7 @@ public class SizeFieldMapper extends IntegerFieldMapper implements RootMapper {
|
|||
|
||||
@Override
|
||||
public SizeFieldMapper build(BuilderContext context) {
|
||||
return new SizeFieldMapper(enabled, fieldType);
|
||||
return new SizeFieldMapper(enabled, fieldType, provider);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -96,13 +95,12 @@ public class SizeFieldMapper extends IntegerFieldMapper implements RootMapper {
|
|||
private final boolean enabled;
|
||||
|
||||
public SizeFieldMapper() {
|
||||
this(Defaults.ENABLED, new FieldType(Defaults.SIZE_FIELD_TYPE));
|
||||
this(Defaults.ENABLED, new FieldType(Defaults.SIZE_FIELD_TYPE), null);
|
||||
}
|
||||
|
||||
public SizeFieldMapper(boolean enabled, FieldType fieldType) {
|
||||
public SizeFieldMapper(boolean enabled, FieldType fieldType, PostingsFormatProvider provider) {
|
||||
super(new Names(Defaults.NAME), Defaults.PRECISION_STEP, Defaults.FUZZY_FACTOR,
|
||||
Defaults.BOOST, fieldType, Defaults.NULL_VALUE,
|
||||
Defaults.IGNORE_MALFORMED);
|
||||
Defaults.BOOST, fieldType, Defaults.NULL_VALUE, Defaults.IGNORE_MALFORMED, provider);
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
|
|
|
@ -197,8 +197,10 @@ public class SourceFieldMapper extends AbstractFieldMapper<byte[]> implements In
|
|||
this(Defaults.NAME, Defaults.ENABLED, Defaults.FORMAT, null, -1, Defaults.INCLUDES, Defaults.EXCLUDES);
|
||||
}
|
||||
|
||||
protected SourceFieldMapper(String name, boolean enabled, String format, Boolean compress, long compressThreshold, String[] includes, String[] excludes) {
|
||||
super(new Names(name, name, name, name), Defaults.BOOST, new FieldType(Defaults.SOURCE_FIELD_TYPE), Lucene.KEYWORD_ANALYZER, Lucene.KEYWORD_ANALYZER);
|
||||
protected SourceFieldMapper(String name, boolean enabled, String format, Boolean compress, long compressThreshold,
|
||||
String[] includes, String[] excludes) {
|
||||
super(new Names(name, name, name, name), Defaults.BOOST, new FieldType(Defaults.SOURCE_FIELD_TYPE),
|
||||
Lucene.KEYWORD_ANALYZER, Lucene.KEYWORD_ANALYZER, null); // Only stored.
|
||||
this.enabled = enabled;
|
||||
this.compress = compress;
|
||||
this.compressThreshold = compressThreshold;
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.elasticsearch.common.unit.TimeValue;
|
|||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.index.AlreadyExpiredException;
|
||||
import org.elasticsearch.index.codec.postingsformat.PostingsFormatProvider;
|
||||
import org.elasticsearch.index.mapper.*;
|
||||
import org.elasticsearch.index.mapper.core.LongFieldMapper;
|
||||
import org.elasticsearch.index.mapper.core.NumberFieldMapper;
|
||||
|
@ -82,7 +83,7 @@ public class TTLFieldMapper extends LongFieldMapper implements InternalMapper, R
|
|||
|
||||
@Override
|
||||
public TTLFieldMapper build(BuilderContext context) {
|
||||
return new TTLFieldMapper(fieldType, enabled, defaultTTL, ignoreMalformed(context));
|
||||
return new TTLFieldMapper(fieldType, enabled, defaultTTL, ignoreMalformed(context), provider);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -111,13 +112,14 @@ public class TTLFieldMapper extends LongFieldMapper implements InternalMapper, R
|
|||
private long defaultTTL;
|
||||
|
||||
public TTLFieldMapper() {
|
||||
this(new FieldType(Defaults.TTL_FIELD_TYPE), Defaults.ENABLED, Defaults.DEFAULT, Defaults.IGNORE_MALFORMED);
|
||||
this(new FieldType(Defaults.TTL_FIELD_TYPE), Defaults.ENABLED, Defaults.DEFAULT, Defaults.IGNORE_MALFORMED, null);
|
||||
}
|
||||
|
||||
protected TTLFieldMapper(FieldType fieldType, boolean enabled, long defaultTTL, Explicit<Boolean> ignoreMalformed) {
|
||||
protected TTLFieldMapper(FieldType fieldType, boolean enabled, long defaultTTL, Explicit<Boolean> ignoreMalformed,
|
||||
PostingsFormatProvider provider) {
|
||||
super(new Names(Defaults.NAME, Defaults.NAME, Defaults.NAME, Defaults.NAME), Defaults.PRECISION_STEP,
|
||||
Defaults.FUZZY_FACTOR, Defaults.BOOST, fieldType,
|
||||
Defaults.NULL_VALUE, ignoreMalformed);
|
||||
Defaults.FUZZY_FACTOR, Defaults.BOOST, fieldType, Defaults.NULL_VALUE, ignoreMalformed,
|
||||
provider);
|
||||
this.enabled = enabled;
|
||||
this.defaultTTL = defaultTTL;
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.elasticsearch.common.Strings;
|
|||
import org.elasticsearch.common.joda.FormatDateTimeFormatter;
|
||||
import org.elasticsearch.common.joda.Joda;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.index.codec.postingsformat.PostingsFormatProvider;
|
||||
import org.elasticsearch.index.mapper.*;
|
||||
import org.elasticsearch.index.mapper.core.DateFieldMapper;
|
||||
import org.elasticsearch.index.mapper.core.LongFieldMapper;
|
||||
|
@ -96,7 +97,8 @@ public class TimestampFieldMapper extends DateFieldMapper implements InternalMap
|
|||
if (context.indexSettings() != null) {
|
||||
parseUpperInclusive = context.indexSettings().getAsBoolean("index.mapping.date.parse_upper_inclusive", Defaults.PARSE_UPPER_INCLUSIVE);
|
||||
}
|
||||
return new TimestampFieldMapper(fieldType, enabled, path, dateTimeFormatter, parseUpperInclusive, ignoreMalformed(context));
|
||||
return new TimestampFieldMapper(fieldType, enabled, path, dateTimeFormatter, parseUpperInclusive,
|
||||
ignoreMalformed(context), provider);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -126,15 +128,17 @@ public class TimestampFieldMapper extends DateFieldMapper implements InternalMap
|
|||
private final String path;
|
||||
|
||||
public TimestampFieldMapper() {
|
||||
this(new FieldType(Defaults.TIMESTAMP_FIELD_TYPE), Defaults.ENABLED, Defaults.PATH, Defaults.DATE_TIME_FORMATTER, Defaults.PARSE_UPPER_INCLUSIVE, Defaults.IGNORE_MALFORMED);
|
||||
this(new FieldType(Defaults.TIMESTAMP_FIELD_TYPE), Defaults.ENABLED, Defaults.PATH, Defaults.DATE_TIME_FORMATTER,
|
||||
Defaults.PARSE_UPPER_INCLUSIVE, Defaults.IGNORE_MALFORMED, null);
|
||||
}
|
||||
|
||||
protected TimestampFieldMapper(FieldType fieldType, boolean enabled, String path,
|
||||
FormatDateTimeFormatter dateTimeFormatter, boolean parseUpperInclusive, Explicit<Boolean> ignoreMalformed) {
|
||||
FormatDateTimeFormatter dateTimeFormatter, boolean parseUpperInclusive,
|
||||
Explicit<Boolean> ignoreMalformed, PostingsFormatProvider provider) {
|
||||
super(new Names(Defaults.NAME, Defaults.NAME, Defaults.NAME, Defaults.NAME), dateTimeFormatter,
|
||||
Defaults.PRECISION_STEP, Defaults.FUZZY_FACTOR, Defaults.BOOST, fieldType,
|
||||
Defaults.NULL_VALUE, TimeUnit.MILLISECONDS /*always milliseconds*/,
|
||||
parseUpperInclusive, ignoreMalformed);
|
||||
parseUpperInclusive, ignoreMalformed, provider);
|
||||
this.enabled = enabled;
|
||||
this.path = path;
|
||||
}
|
||||
|
@ -213,7 +217,7 @@ public class TimestampFieldMapper extends DateFieldMapper implements InternalMap
|
|||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||
// if all are defaults, no sense to write it at all
|
||||
if (indexed() == Defaults.TIMESTAMP_FIELD_TYPE.indexed() &&
|
||||
stored() == Defaults.TIMESTAMP_FIELD_TYPE.stored() && enabled == Defaults.ENABLED && path == Defaults.PATH
|
||||
stored() == Defaults.TIMESTAMP_FIELD_TYPE.stored() && enabled == Defaults.ENABLED && path == Defaults.PATH
|
||||
&& dateTimeFormatter.format().equals(Defaults.DATE_TIME_FORMATTER.format())) {
|
||||
return builder;
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ import org.elasticsearch.common.Nullable;
|
|||
import org.elasticsearch.common.lucene.Lucene;
|
||||
import org.elasticsearch.common.lucene.search.TermFilter;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.index.codec.postingsformat.PostingsFormatProvider;
|
||||
import org.elasticsearch.index.mapper.*;
|
||||
import org.elasticsearch.index.mapper.core.AbstractFieldMapper;
|
||||
import org.elasticsearch.index.query.QueryParseContext;
|
||||
|
@ -78,7 +79,7 @@ public class TypeFieldMapper extends AbstractFieldMapper<String> implements Inte
|
|||
|
||||
@Override
|
||||
public TypeFieldMapper build(BuilderContext context) {
|
||||
return new TypeFieldMapper(name, indexName, boost, fieldType);
|
||||
return new TypeFieldMapper(name, indexName, boost, fieldType, provider);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -97,12 +98,12 @@ public class TypeFieldMapper extends AbstractFieldMapper<String> implements Inte
|
|||
}
|
||||
|
||||
protected TypeFieldMapper(String name, String indexName) {
|
||||
this(name, indexName, Defaults.BOOST, new FieldType(Defaults.TYPE_FIELD_TYPE));
|
||||
this(name, indexName, Defaults.BOOST, new FieldType(Defaults.TYPE_FIELD_TYPE), null);
|
||||
}
|
||||
|
||||
public TypeFieldMapper(String name, String indexName, float boost, FieldType fieldType) {
|
||||
public TypeFieldMapper(String name, String indexName, float boost, FieldType fieldType, PostingsFormatProvider provider) {
|
||||
super(new Names(name, indexName, indexName, name), boost, fieldType, Lucene.KEYWORD_ANALYZER,
|
||||
Lucene.KEYWORD_ANALYZER);
|
||||
Lucene.KEYWORD_ANALYZER, provider);
|
||||
}
|
||||
|
||||
public String value(Document document) {
|
||||
|
|
|
@ -97,7 +97,7 @@ public class UidFieldMapper extends AbstractFieldMapper<Uid> implements Internal
|
|||
|
||||
protected UidFieldMapper(String name, String indexName) {
|
||||
super(new Names(name, indexName, indexName, name), Defaults.BOOST, new FieldType(Defaults.UID_FIELD_TYPE),
|
||||
Lucene.KEYWORD_ANALYZER, Lucene.KEYWORD_ANALYZER);
|
||||
Lucene.KEYWORD_ANALYZER, Lucene.KEYWORD_ANALYZER, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -36,6 +36,7 @@ import org.elasticsearch.index.analysis.NamedAnalyzer;
|
|||
import org.elasticsearch.index.analysis.NumericAnalyzer;
|
||||
import org.elasticsearch.index.analysis.NumericTokenizer;
|
||||
import org.elasticsearch.index.cache.field.data.FieldDataCache;
|
||||
import org.elasticsearch.index.codec.postingsformat.PostingsFormatProvider;
|
||||
import org.elasticsearch.index.field.data.FieldDataType;
|
||||
import org.elasticsearch.index.mapper.*;
|
||||
import org.elasticsearch.index.mapper.core.LongFieldMapper;
|
||||
|
@ -112,7 +113,7 @@ public class IpFieldMapper extends NumberFieldMapper<Long> {
|
|||
public IpFieldMapper build(BuilderContext context) {
|
||||
fieldType.setOmitNorms(fieldType.omitNorms() && boost == 1.0f);
|
||||
IpFieldMapper fieldMapper = new IpFieldMapper(buildNames(context),
|
||||
precisionStep, boost, fieldType, nullValue, ignoreMalformed(context));
|
||||
precisionStep, boost, fieldType, nullValue, ignoreMalformed(context), provider);
|
||||
fieldMapper.includeInAll(includeInAll);
|
||||
return fieldMapper;
|
||||
}
|
||||
|
@ -138,10 +139,11 @@ public class IpFieldMapper extends NumberFieldMapper<Long> {
|
|||
|
||||
protected IpFieldMapper(Names names, int precisionStep,
|
||||
float boost, FieldType fieldType,
|
||||
String nullValue, Explicit<Boolean> ignoreMalformed) {
|
||||
String nullValue, Explicit<Boolean> ignoreMalformed,
|
||||
PostingsFormatProvider provider) {
|
||||
super(names, precisionStep, null, boost, fieldType,
|
||||
ignoreMalformed, new NamedAnalyzer("_ip/" + precisionStep, new NumericIpAnalyzer(precisionStep)),
|
||||
new NamedAnalyzer("_ip/max", new NumericIpAnalyzer(Integer.MAX_VALUE)));
|
||||
new NamedAnalyzer("_ip/max", new NumericIpAnalyzer(Integer.MAX_VALUE)), provider);
|
||||
this.nullValue = nullValue;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@ import org.elasticsearch.index.analysis.AnalysisService;
|
|||
import org.elasticsearch.index.cache.CacheStats;
|
||||
import org.elasticsearch.index.cache.IndexCache;
|
||||
import org.elasticsearch.index.cache.IndexCacheModule;
|
||||
import org.elasticsearch.index.codec.CodecModule;
|
||||
import org.elasticsearch.index.engine.IndexEngine;
|
||||
import org.elasticsearch.index.engine.IndexEngineModule;
|
||||
import org.elasticsearch.index.flush.FlushStats;
|
||||
|
@ -275,8 +276,9 @@ public class InternalIndicesService extends AbstractLifecycleComponent<IndicesSe
|
|||
modules.add(new AnalysisModule(indexSettings, indicesAnalysisService));
|
||||
modules.add(new SimilarityModule(indexSettings));
|
||||
modules.add(new IndexCacheModule(indexSettings));
|
||||
modules.add(new IndexQueryParserModule(indexSettings));
|
||||
modules.add(new CodecModule(indexSettings));
|
||||
modules.add(new MapperServiceModule());
|
||||
modules.add(new IndexQueryParserModule(indexSettings));
|
||||
modules.add(new IndexAliasesServiceModule());
|
||||
modules.add(new IndexGatewayModule(indexSettings, injector.getInstance(Gateway.class)));
|
||||
modules.add(new IndexModule(indexSettings));
|
||||
|
|
|
@ -0,0 +1,114 @@
|
|||
/*
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. ElasticSearch licenses this
|
||||
* file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.test.integration.codecs;
|
||||
|
||||
import org.elasticsearch.action.search.SearchPhaseExecutionException;
|
||||
import org.elasticsearch.action.search.SearchResponse;
|
||||
import org.elasticsearch.client.Client;
|
||||
import org.elasticsearch.common.settings.ImmutableSettings;
|
||||
import org.elasticsearch.test.integration.AbstractNodesTests;
|
||||
import org.testng.annotations.AfterClass;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class CodecTests extends AbstractNodesTests {
|
||||
|
||||
private Client client;
|
||||
|
||||
@BeforeClass
|
||||
public void createNodes() throws Exception {
|
||||
startNode("node1");
|
||||
client = getClient();
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public void closeNodes() {
|
||||
client.close();
|
||||
closeAllNodes();
|
||||
}
|
||||
|
||||
protected Client getClient() {
|
||||
return client("node1");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIndexOptionsWithConfiguredPostingsFormat() throws Exception {
|
||||
try {
|
||||
client.admin().indices().prepareDelete("test").execute().actionGet();
|
||||
} catch (Exception e) {
|
||||
// ignore
|
||||
}
|
||||
|
||||
client.admin().indices().prepareCreate("test")
|
||||
.addMapping("type1", jsonBuilder().startObject().startObject("type1").startObject("properties").startObject("field1")
|
||||
.field("postings_format", "test1").field("index_options", "docs").field("type", "string").endObject().endObject().endObject().endObject())
|
||||
.setSettings(ImmutableSettings.settingsBuilder()
|
||||
.put("number_of_shards", 1)
|
||||
.put("number_of_replicas", 0)
|
||||
.put("codec.postings_format.test1.type", "pulsing40")
|
||||
).execute().actionGet();
|
||||
|
||||
client.prepareIndex("test", "type1", "1").setSource("field1", "quick brown fox", "field2", "quick brown fox").execute().actionGet();
|
||||
client.prepareIndex("test", "type1", "2").setSource("field1", "quick lazy huge brown fox", "field2", "quick lazy huge brown fox").setRefresh(true).execute().actionGet();
|
||||
|
||||
SearchResponse searchResponse = client.prepareSearch().setQuery("{ \"text_phrase\" : { \"field2\" : \"quick brown\", \"slop\" : \"2\" }}").execute().actionGet();
|
||||
assertThat(searchResponse.hits().totalHits(), equalTo(1l));
|
||||
try {
|
||||
client.prepareSearch().setQuery("{ \"text_phrase\" : { \"field1\" : \"quick brown\", \"slop\" : \"2\" }}").execute().actionGet();
|
||||
} catch (SearchPhaseExecutionException e) {
|
||||
assertTrue(e.getMessage().endsWith("IllegalStateException[field \"field1\" was indexed without position data; cannot run PhraseQuery (term=quick)]; }"));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIndexOptionsWithSimpleTextCodec() throws Exception {
|
||||
try {
|
||||
client.admin().indices().prepareDelete("test").execute().actionGet();
|
||||
} catch (Exception e) {
|
||||
// ignore
|
||||
}
|
||||
|
||||
client.admin().indices().prepareCreate("test")
|
||||
.setSettings(ImmutableSettings.settingsBuilder()
|
||||
.put("number_of_shards", 1)
|
||||
.put("number_of_replicas", 0)
|
||||
.put("index.codec", "SimpleText")
|
||||
).execute().actionGet();
|
||||
|
||||
client.prepareIndex("test", "type1", "1").setSource("field1", "quick brown fox", "field2", "quick brown fox").execute().actionGet();
|
||||
client.prepareIndex("test", "type1", "2").setSource("field1", "quick lazy huge brown fox", "field2", "quick lazy huge brown fox").setRefresh(true).execute().actionGet();
|
||||
|
||||
SearchResponse searchResponse = client.prepareSearch().setQuery("{ \"text_phrase\" : { \"field2\" : \"quick brown\", \"slop\" : \"2\" }}").execute().actionGet();
|
||||
assertThat(searchResponse.hits().totalHits(), equalTo(1l));
|
||||
try {
|
||||
client.prepareSearch().setQuery("{ \"text_phrase\" : { \"field1\" : \"quick brown\", \"slop\" : \"2\" }}").execute().actionGet();
|
||||
} catch (SearchPhaseExecutionException e) {
|
||||
assertTrue(e.getMessage().endsWith("IllegalStateException[field \"field1\" was indexed without position data; cannot run PhraseQuery (term=quick)]; }"));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -35,6 +35,7 @@ import org.elasticsearch.index.IndexNameModule;
|
|||
import org.elasticsearch.index.aliases.IndexAliasesService;
|
||||
import org.elasticsearch.index.analysis.AnalysisModule;
|
||||
import org.elasticsearch.index.cache.IndexCacheModule;
|
||||
import org.elasticsearch.index.codec.CodecModule;
|
||||
import org.elasticsearch.index.engine.IndexEngineModule;
|
||||
import org.elasticsearch.index.query.FilterBuilder;
|
||||
import org.elasticsearch.index.query.IndexQueryParserModule;
|
||||
|
@ -64,6 +65,7 @@ public class IndexAliasesServiceTests {
|
|||
public static IndexQueryParserService newIndexQueryParserService() {
|
||||
Injector injector = new ModulesBuilder().add(
|
||||
new IndicesQueriesModule(),
|
||||
new CodecModule(ImmutableSettings.Builder.EMPTY_SETTINGS),
|
||||
new IndexSettingsModule(new Index("test"), ImmutableSettings.Builder.EMPTY_SETTINGS),
|
||||
new IndexNameModule(new Index("test")),
|
||||
new IndexQueryParserModule(ImmutableSettings.Builder.EMPTY_SETTINGS),
|
||||
|
|
|
@ -0,0 +1,255 @@
|
|||
/*
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. ElasticSearch licenses this
|
||||
* file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.test.unit.index.codec;
|
||||
|
||||
import org.apache.lucene.codecs.Codec;
|
||||
import org.apache.lucene.codecs.bloom.BloomFilteringPostingsFormat;
|
||||
import org.apache.lucene.codecs.lucene40.Lucene40Codec;
|
||||
import org.apache.lucene.codecs.lucene40.Lucene40PostingsFormat;
|
||||
import org.apache.lucene.codecs.memory.DirectPostingsFormat;
|
||||
import org.apache.lucene.codecs.memory.MemoryPostingsFormat;
|
||||
import org.apache.lucene.codecs.perfield.PerFieldPostingsFormat;
|
||||
import org.apache.lucene.codecs.pulsing.Pulsing40PostingsFormat;
|
||||
import org.apache.lucene.codecs.simpletext.SimpleTextCodec;
|
||||
import org.elasticsearch.common.inject.Injector;
|
||||
import org.elasticsearch.common.inject.ModulesBuilder;
|
||||
import org.elasticsearch.common.settings.ImmutableSettings;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.settings.SettingsModule;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.index.IndexNameModule;
|
||||
import org.elasticsearch.index.analysis.AnalysisModule;
|
||||
import org.elasticsearch.index.codec.CodecModule;
|
||||
import org.elasticsearch.index.codec.CodecService;
|
||||
import org.elasticsearch.index.codec.PerFieldMappingPostingFormatCodec;
|
||||
import org.elasticsearch.index.codec.postingsformat.*;
|
||||
import org.elasticsearch.index.mapper.DocumentMapper;
|
||||
import org.elasticsearch.index.mapper.MapperServiceModule;
|
||||
import org.elasticsearch.index.settings.IndexSettingsModule;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.instanceOf;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class CodecTests {
|
||||
|
||||
@Test
|
||||
public void testResolveDefaultCodecs() throws Exception {
|
||||
CodecService codecService = createCodecService();
|
||||
assertThat(codecService.codec("default"), instanceOf(PerFieldMappingPostingFormatCodec.class));
|
||||
assertThat(codecService.codec("Lucene40"), instanceOf(Lucene40Codec.class));
|
||||
assertThat(codecService.codec("SimpleText"), instanceOf(SimpleTextCodec.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testResolveDefaultPostingFormats() throws Exception {
|
||||
PostingsFormatService postingsFormatService = createCodecService().postingsFormatService();
|
||||
assertThat(postingsFormatService.get("default"), instanceOf(PreBuiltPostingsFormatProvider.class));
|
||||
// Should fail when upgrading Lucene with codec changes
|
||||
assertThat(postingsFormatService.get("default").get(), instanceOf(((PerFieldPostingsFormat) Codec.getDefault().postingsFormat()).getPostingsFormatForField(null).getClass()));
|
||||
assertThat(postingsFormatService.get("Lucene40"), instanceOf(PreBuiltPostingsFormatProvider.class));
|
||||
// Should fail when upgrading Lucene with codec changes
|
||||
assertThat(postingsFormatService.get("Lucene40").get(), instanceOf(((PerFieldPostingsFormat) Codec.getDefault().postingsFormat()).getPostingsFormatForField(null).getClass()));
|
||||
|
||||
assertThat(postingsFormatService.get("bloom_default"), instanceOf(PreBuiltPostingsFormatProvider.class));
|
||||
assertThat(postingsFormatService.get("bloom_default").get(), instanceOf(BloomFilteringPostingsFormat.class));
|
||||
assertThat(postingsFormatService.get("BloomFilter"), instanceOf(PreBuiltPostingsFormatProvider.class));
|
||||
assertThat(postingsFormatService.get("BloomFilter").get(), instanceOf(BloomFilteringPostingsFormat.class));
|
||||
|
||||
assertThat(postingsFormatService.get("bloom_pulsing"), instanceOf(PreBuiltPostingsFormatProvider.class));
|
||||
assertThat(postingsFormatService.get("bloom_pulsing").get(), instanceOf(BloomFilteringPostingsFormat.class));
|
||||
|
||||
assertThat(postingsFormatService.get("pulsing"), instanceOf(PreBuiltPostingsFormatProvider.class));
|
||||
assertThat(postingsFormatService.get("pulsing").get(), instanceOf(Pulsing40PostingsFormat.class));
|
||||
assertThat(postingsFormatService.get("Pulsing40"), instanceOf(PreBuiltPostingsFormatProvider.class));
|
||||
assertThat(postingsFormatService.get("Pulsing40").get(), instanceOf(Pulsing40PostingsFormat.class));
|
||||
|
||||
assertThat(postingsFormatService.get("memory"), instanceOf(PreBuiltPostingsFormatProvider.class));
|
||||
assertThat(postingsFormatService.get("memory").get(), instanceOf(MemoryPostingsFormat.class));
|
||||
assertThat(postingsFormatService.get("Memory"), instanceOf(PreBuiltPostingsFormatProvider.class));
|
||||
assertThat(postingsFormatService.get("Memory").get(), instanceOf(MemoryPostingsFormat.class));
|
||||
|
||||
assertThat(postingsFormatService.get("direct"), instanceOf(PreBuiltPostingsFormatProvider.class));
|
||||
assertThat(postingsFormatService.get("direct").get(), instanceOf(DirectPostingsFormat.class));
|
||||
assertThat(postingsFormatService.get("Direct"), instanceOf(PreBuiltPostingsFormatProvider.class));
|
||||
assertThat(postingsFormatService.get("Direct").get(), instanceOf(DirectPostingsFormat.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testResolvePostingFormatsFromMapping_default() throws Exception {
|
||||
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
|
||||
.startObject("properties")
|
||||
.startObject("field1").field("type", "string").field("postings_format", "default").endObject()
|
||||
.startObject("field2").field("type", "string").field("postings_format", "my_format1").endObject()
|
||||
.endObject()
|
||||
.endObject().endObject().string();
|
||||
|
||||
Settings indexSettings = ImmutableSettings.settingsBuilder()
|
||||
.put("index.codec.postings_format.my_format1.type", "lucene40")
|
||||
.put("index.codec.postings_format.my_format1.min_block_size", 16)
|
||||
.put("index.codec.postings_format.my_format1.max_block_size", 64)
|
||||
.build();
|
||||
CodecService codecService = createCodecService(indexSettings);
|
||||
DocumentMapper documentMapper = codecService.mapperService().documentMapperParser().parse(mapping);
|
||||
assertThat(documentMapper.mappers().name("field1").mapper().postingFormatProvider(), instanceOf(PreBuiltPostingsFormatProvider.class));
|
||||
assertThat(documentMapper.mappers().name("field1").mapper().postingFormatProvider().get(), instanceOf(Lucene40PostingsFormat.class));
|
||||
|
||||
assertThat(documentMapper.mappers().name("field2").mapper().postingFormatProvider(), instanceOf(Lucene40PostingsFormatProvider.class));
|
||||
Lucene40PostingsFormatProvider provider = (Lucene40PostingsFormatProvider) documentMapper.mappers().name("field2").mapper().postingFormatProvider();
|
||||
assertThat(provider.minBlockSize(), equalTo(16));
|
||||
assertThat(provider.maxBlockSize(), equalTo(64));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testResolvePostingFormatsFromMapping_memory() throws Exception {
|
||||
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
|
||||
.startObject("properties")
|
||||
.startObject("field1").field("type", "string").field("postings_format", "memory").endObject()
|
||||
.startObject("field2").field("type", "string").field("postings_format", "my_format1").endObject()
|
||||
.endObject()
|
||||
.endObject().endObject().string();
|
||||
|
||||
Settings indexSettings = ImmutableSettings.settingsBuilder()
|
||||
.put("index.codec.postings_format.my_format1.type", "memory")
|
||||
.put("index.codec.postings_format.my_format1.pack_fst", true)
|
||||
.put("index.codec.postings_format.my_format1.acceptable_overhead_ratio", 0.3f)
|
||||
.build();
|
||||
CodecService codecService = createCodecService(indexSettings);
|
||||
DocumentMapper documentMapper = codecService.mapperService().documentMapperParser().parse(mapping);
|
||||
assertThat(documentMapper.mappers().name("field1").mapper().postingFormatProvider(), instanceOf(PreBuiltPostingsFormatProvider.class));
|
||||
assertThat(documentMapper.mappers().name("field1").mapper().postingFormatProvider().get(), instanceOf(MemoryPostingsFormat.class));
|
||||
|
||||
assertThat(documentMapper.mappers().name("field2").mapper().postingFormatProvider(), instanceOf(MemoryPostingsFormatProvider.class));
|
||||
MemoryPostingsFormatProvider provider = (MemoryPostingsFormatProvider) documentMapper.mappers().name("field2").mapper().postingFormatProvider();
|
||||
assertThat(provider.packFst(), equalTo(true));
|
||||
assertThat(provider.acceptableOverheadRatio(), equalTo(0.3f));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testResolvePostingFormatsFromMapping_direct() throws Exception {
|
||||
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
|
||||
.startObject("properties")
|
||||
.startObject("field1").field("type", "string").field("postings_format", "direct").endObject()
|
||||
.startObject("field2").field("type", "string").field("postings_format", "my_format1").endObject()
|
||||
.endObject()
|
||||
.endObject().endObject().string();
|
||||
|
||||
Settings indexSettings = ImmutableSettings.settingsBuilder()
|
||||
.put("index.codec.postings_format.my_format1.type", "direct")
|
||||
.put("index.codec.postings_format.my_format1.min_skip_count", 16)
|
||||
.put("index.codec.postings_format.my_format1.low_freq_cutoff", 64)
|
||||
.build();
|
||||
CodecService codecService = createCodecService(indexSettings);
|
||||
DocumentMapper documentMapper = codecService.mapperService().documentMapperParser().parse(mapping);
|
||||
assertThat(documentMapper.mappers().name("field1").mapper().postingFormatProvider(), instanceOf(PreBuiltPostingsFormatProvider.class));
|
||||
assertThat(documentMapper.mappers().name("field1").mapper().postingFormatProvider().get(), instanceOf(DirectPostingsFormat.class));
|
||||
|
||||
assertThat(documentMapper.mappers().name("field2").mapper().postingFormatProvider(), instanceOf(DirectPostingsFormatProvider.class));
|
||||
DirectPostingsFormatProvider provider = (DirectPostingsFormatProvider) documentMapper.mappers().name("field2").mapper().postingFormatProvider();
|
||||
assertThat(provider.minSkipCount(), equalTo(16));
|
||||
assertThat(provider.lowFreqCutoff(), equalTo(64));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testResolvePostingFormatsFromMapping_pulsing() throws Exception {
|
||||
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
|
||||
.startObject("properties")
|
||||
.startObject("field1").field("type", "string").field("postings_format", "pulsing").endObject()
|
||||
.startObject("field2").field("type", "string").field("postings_format", "my_format1").endObject()
|
||||
.endObject()
|
||||
.endObject().endObject().string();
|
||||
|
||||
Settings indexSettings = ImmutableSettings.settingsBuilder()
|
||||
.put("index.codec.postings_format.my_format1.type", "pulsing40")
|
||||
.put("index.codec.postings_format.my_format1.freq_cut_off", 2)
|
||||
.put("index.codec.postings_format.my_format1.min_block_size", 32)
|
||||
.put("index.codec.postings_format.my_format1.max_block_size", 64)
|
||||
.build();
|
||||
CodecService codecService = createCodecService(indexSettings);
|
||||
DocumentMapper documentMapper = codecService.mapperService().documentMapperParser().parse(mapping);
|
||||
assertThat(documentMapper.mappers().name("field1").mapper().postingFormatProvider(), instanceOf(PreBuiltPostingsFormatProvider.class));
|
||||
assertThat(documentMapper.mappers().name("field1").mapper().postingFormatProvider().get(), instanceOf(Pulsing40PostingsFormat.class));
|
||||
|
||||
assertThat(documentMapper.mappers().name("field2").mapper().postingFormatProvider(), instanceOf(Pulsing40PostingsFormatProvider.class));
|
||||
Pulsing40PostingsFormatProvider provider = (Pulsing40PostingsFormatProvider) documentMapper.mappers().name("field2").mapper().postingFormatProvider();
|
||||
assertThat(provider.freqCutOff(), equalTo(2));
|
||||
assertThat(provider.minBlockSize(), equalTo(32));
|
||||
assertThat(provider.maxBlockSize(), equalTo(64));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testResolvePostingFormatsFromMapping_bloom() throws Exception {
|
||||
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
|
||||
.startObject("properties")
|
||||
.startObject("field1").field("type", "string").field("postings_format", "bloom_default").endObject()
|
||||
.startObject("field2").field("type", "string").field("postings_format", "bloom_pulsing").endObject()
|
||||
.startObject("field3").field("type", "string").field("postings_format", "my_format1").endObject()
|
||||
.endObject()
|
||||
.endObject().endObject().string();
|
||||
|
||||
Settings indexSettings = ImmutableSettings.settingsBuilder()
|
||||
.put("index.codec.postings_format.my_format1.type", "bloom_filter")
|
||||
.put("index.codec.postings_format.my_format1.desired_max_saturation", 0.2f)
|
||||
.put("index.codec.postings_format.my_format1.saturation_limit", 0.8f)
|
||||
.put("index.codec.postings_format.my_format1.delegate", "delegate1")
|
||||
.put("index.codec.postings_format.delegate1.type", "direct")
|
||||
.put("index.codec.postings_format.delegate1.min_skip_count", 16)
|
||||
.put("index.codec.postings_format.delegate1.low_freq_cutoff", 64)
|
||||
.build();
|
||||
CodecService codecService = createCodecService(indexSettings);
|
||||
DocumentMapper documentMapper = codecService.mapperService().documentMapperParser().parse(mapping);
|
||||
assertThat(documentMapper.mappers().name("field1").mapper().postingFormatProvider(), instanceOf(PreBuiltPostingsFormatProvider.class));
|
||||
assertThat(documentMapper.mappers().name("field1").mapper().postingFormatProvider().get(), instanceOf(BloomFilteringPostingsFormat.class));
|
||||
|
||||
assertThat(documentMapper.mappers().name("field2").mapper().postingFormatProvider(), instanceOf(PreBuiltPostingsFormatProvider.class));
|
||||
assertThat(documentMapper.mappers().name("field2").mapper().postingFormatProvider().get(), instanceOf(BloomFilteringPostingsFormat.class));
|
||||
|
||||
assertThat(documentMapper.mappers().name("field3").mapper().postingFormatProvider(), instanceOf(BloomFilterPostingsFormatProvider.class));
|
||||
BloomFilterPostingsFormatProvider provider = (BloomFilterPostingsFormatProvider) documentMapper.mappers().name("field3").mapper().postingFormatProvider();
|
||||
assertThat(provider.desiredMaxSaturation(), equalTo(0.2f));
|
||||
assertThat(provider.saturationLimit(), equalTo(0.8f));
|
||||
assertThat(provider.delegate(), instanceOf(DirectPostingsFormatProvider.class));
|
||||
DirectPostingsFormatProvider delegate = (DirectPostingsFormatProvider) provider.delegate();
|
||||
assertThat(delegate.minSkipCount(), equalTo(16));
|
||||
assertThat(delegate.lowFreqCutoff(), equalTo(64));
|
||||
}
|
||||
|
||||
private static CodecService createCodecService() {
|
||||
return createCodecService(ImmutableSettings.Builder.EMPTY_SETTINGS);
|
||||
}
|
||||
|
||||
private static CodecService createCodecService(Settings settings) {
|
||||
Index index = new Index("test");
|
||||
Injector injector = new ModulesBuilder()
|
||||
.add(new SettingsModule(settings))
|
||||
.add(new IndexNameModule(index))
|
||||
.add(new IndexSettingsModule(index, settings))
|
||||
.add(new CodecModule(settings))
|
||||
.add(new MapperServiceModule())
|
||||
.add(new AnalysisModule(settings))
|
||||
.createInjector();
|
||||
return injector.getInstance(CodecService.class);
|
||||
}
|
||||
|
||||
}
|
|
@ -20,6 +20,7 @@
|
|||
package org.elasticsearch.test.unit.index.engine.robin;
|
||||
|
||||
import org.elasticsearch.index.analysis.AnalysisService;
|
||||
import org.elasticsearch.index.codec.CodecService;
|
||||
import org.elasticsearch.index.engine.Engine;
|
||||
import org.elasticsearch.index.engine.robin.RobinEngine;
|
||||
import org.elasticsearch.index.indexing.ShardIndexingService;
|
||||
|
@ -38,6 +39,6 @@ public class SimpleRobinEngineTests extends AbstractSimpleEngineTests {
|
|||
|
||||
protected Engine createEngine(Store store, Translog translog) {
|
||||
return new RobinEngine(shardId, EMPTY_SETTINGS, threadPool, new IndexSettingsService(shardId.index(), EMPTY_SETTINGS), new ShardIndexingService(shardId, EMPTY_SETTINGS), null, store, createSnapshotDeletionPolicy(), translog, createMergePolicy(), createMergeScheduler(),
|
||||
new AnalysisService(shardId.index()), new SimilarityService(shardId.index()));
|
||||
new AnalysisService(shardId.index()), new SimilarityService(shardId.index()), new CodecService(shardId.index()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ import org.elasticsearch.index.Index;
|
|||
import org.elasticsearch.index.IndexNameModule;
|
||||
import org.elasticsearch.index.analysis.AnalysisModule;
|
||||
import org.elasticsearch.index.analysis.AnalysisService;
|
||||
import org.elasticsearch.index.codec.postingsformat.PostingsFormatService;
|
||||
import org.elasticsearch.index.mapper.DocumentMapperParser;
|
||||
import org.elasticsearch.index.mapper.MapperService;
|
||||
import org.elasticsearch.index.settings.IndexSettingsModule;
|
||||
|
@ -42,15 +43,16 @@ import org.elasticsearch.indices.analysis.IndicesAnalysisService;
|
|||
public class MapperTests {
|
||||
|
||||
public static DocumentMapperParser newParser() {
|
||||
return new DocumentMapperParser(new Index("test"), newAnalysisService());
|
||||
return new DocumentMapperParser(new Index("test"), newAnalysisService(), new PostingsFormatService(new Index("test")));
|
||||
}
|
||||
|
||||
public static DocumentMapperParser newParser(Settings indexSettings) {
|
||||
return new DocumentMapperParser(new Index("test"), indexSettings, newAnalysisService());
|
||||
return new DocumentMapperParser(new Index("test"), indexSettings, newAnalysisService(), new PostingsFormatService(new Index("test")));
|
||||
}
|
||||
|
||||
public static MapperService newMapperService() {
|
||||
return new MapperService(new Index("test"), ImmutableSettings.Builder.EMPTY_SETTINGS, new Environment(), newAnalysisService());
|
||||
return new MapperService(new Index("test"), ImmutableSettings.Builder.EMPTY_SETTINGS, new Environment(), newAnalysisService(),
|
||||
new PostingsFormatService(new Index("test")));
|
||||
}
|
||||
|
||||
public static AnalysisService newAnalysisService() {
|
||||
|
|
|
@ -34,6 +34,7 @@ import org.elasticsearch.index.Index;
|
|||
import org.elasticsearch.index.IndexNameModule;
|
||||
import org.elasticsearch.index.analysis.AnalysisModule;
|
||||
import org.elasticsearch.index.cache.IndexCacheModule;
|
||||
import org.elasticsearch.index.codec.CodecModule;
|
||||
import org.elasticsearch.index.engine.IndexEngineModule;
|
||||
import org.elasticsearch.index.mapper.MapperServiceModule;
|
||||
import org.elasticsearch.index.percolator.PercolatorExecutor;
|
||||
|
@ -71,6 +72,7 @@ public class PercolatorExecutorTests {
|
|||
.build();
|
||||
Index index = new Index("test");
|
||||
injector = new ModulesBuilder().add(
|
||||
new CodecModule(settings),
|
||||
new SettingsModule(settings),
|
||||
new ThreadPoolModule(settings),
|
||||
new ScriptModule(settings),
|
||||
|
|
|
@ -42,6 +42,7 @@ import org.elasticsearch.index.Index;
|
|||
import org.elasticsearch.index.IndexNameModule;
|
||||
import org.elasticsearch.index.analysis.AnalysisModule;
|
||||
import org.elasticsearch.index.cache.IndexCacheModule;
|
||||
import org.elasticsearch.index.codec.CodecModule;
|
||||
import org.elasticsearch.index.engine.IndexEngineModule;
|
||||
import org.elasticsearch.index.mapper.MapperService;
|
||||
import org.elasticsearch.index.mapper.MapperServiceModule;
|
||||
|
@ -90,6 +91,7 @@ public class SimpleIndexQueryParserTests {
|
|||
.build();
|
||||
Index index = new Index("test");
|
||||
injector = new ModulesBuilder().add(
|
||||
new CodecModule(settings),
|
||||
new SettingsModule(settings),
|
||||
new ThreadPoolModule(settings),
|
||||
new IndicesQueriesModule(),
|
||||
|
|
|
@ -30,6 +30,7 @@ import org.elasticsearch.index.Index;
|
|||
import org.elasticsearch.index.IndexNameModule;
|
||||
import org.elasticsearch.index.analysis.AnalysisModule;
|
||||
import org.elasticsearch.index.cache.IndexCacheModule;
|
||||
import org.elasticsearch.index.codec.CodecModule;
|
||||
import org.elasticsearch.index.engine.IndexEngineModule;
|
||||
import org.elasticsearch.index.query.IndexQueryParserModule;
|
||||
import org.elasticsearch.index.query.IndexQueryParserService;
|
||||
|
@ -63,6 +64,7 @@ public class IndexQueryParserModuleTests {
|
|||
Index index = new Index("test");
|
||||
Injector injector = new ModulesBuilder().add(
|
||||
new SettingsModule(settings),
|
||||
new CodecModule(settings),
|
||||
new ThreadPoolModule(settings),
|
||||
new IndicesQueriesModule(),
|
||||
new ScriptModule(settings),
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.elasticsearch.index.Index;
|
|||
import org.elasticsearch.index.IndexNameModule;
|
||||
import org.elasticsearch.index.analysis.AnalysisModule;
|
||||
import org.elasticsearch.index.cache.IndexCacheModule;
|
||||
import org.elasticsearch.index.codec.CodecModule;
|
||||
import org.elasticsearch.index.engine.IndexEngineModule;
|
||||
import org.elasticsearch.index.query.IndexQueryParserModule;
|
||||
import org.elasticsearch.index.query.IndexQueryParserService;
|
||||
|
@ -60,6 +61,7 @@ public class IndexQueryParserPlugin2Tests {
|
|||
|
||||
Index index = new Index("test");
|
||||
Injector injector = new ModulesBuilder().add(
|
||||
new CodecModule(settings),
|
||||
new SettingsModule(settings),
|
||||
new ThreadPoolModule(settings),
|
||||
new IndicesQueriesModule(),
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.elasticsearch.index.Index;
|
|||
import org.elasticsearch.index.IndexNameModule;
|
||||
import org.elasticsearch.index.analysis.AnalysisModule;
|
||||
import org.elasticsearch.index.cache.IndexCacheModule;
|
||||
import org.elasticsearch.index.codec.CodecModule;
|
||||
import org.elasticsearch.index.engine.IndexEngineModule;
|
||||
import org.elasticsearch.index.query.IndexQueryParserModule;
|
||||
import org.elasticsearch.index.query.IndexQueryParserService;
|
||||
|
@ -80,6 +81,7 @@ public class IndexQueryParserPluginTests {
|
|||
new SimilarityModule(settings),
|
||||
queryParserModule,
|
||||
new IndexNameModule(index),
|
||||
new CodecModule(settings),
|
||||
new AbstractModule() {
|
||||
@Override
|
||||
protected void configure() {
|
||||
|
|
Loading…
Reference in New Issue