当前位置: 首页>>代码示例>>Java>>正文


Java IndexSettings类代码示例

本文整理汇总了Java中org.elasticsearch.index.IndexSettings的典型用法代码示例。如果您正苦于以下问题:Java IndexSettings类的具体用法?Java IndexSettings怎么用?Java IndexSettings使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IndexSettings类属于org.elasticsearch.index包,在下文中一共展示了IndexSettings类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: PatternAnalyzerProvider

import org.elasticsearch.index.IndexSettings; //导入依赖的package包/类
public PatternAnalyzerProvider(IndexSettings indexSettings, Environment env, String name, Settings settings) {
    super(indexSettings, name, settings);

    final CharArraySet defaultStopwords = CharArraySet.EMPTY_SET;
    boolean lowercase =
        settings.getAsBooleanLenientForPreEs6Indices(indexSettings.getIndexVersionCreated(), "lowercase", true, deprecationLogger);
    CharArraySet stopWords = Analysis.parseStopWords(env, indexSettings.getIndexVersionCreated(), settings, defaultStopwords);

    String sPattern = settings.get("pattern", "\\W+" /*PatternAnalyzer.NON_WORD_PATTERN*/);
    if (sPattern == null) {
        throw new IllegalArgumentException("Analyzer [" + name + "] of type pattern must have a `pattern` set");
    }
    Pattern pattern = Regex.compile(sPattern, settings.get("flags"));

    analyzer = new PatternAnalyzer(pattern, lowercase, stopWords);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:PatternAnalyzerProvider.java

示例2: VoikkoTokenFilterFactory

import org.elasticsearch.index.IndexSettings; //导入依赖的package包/类
public VoikkoTokenFilterFactory(IndexSettings indexSettings,
                                @SuppressWarnings("unused") Environment environment,
                                String name,
                                Settings settings) {
    super(indexSettings,  name, settings);

    cfg.analyzeAll = settings.getAsBoolean("analyzeAll", cfg.analyzeAll);
    cfg.minimumWordSize = settings.getAsInt("minimumWordSize", cfg.minimumWordSize);
    cfg.maximumWordSize = settings.getAsInt("maximumWordSize", cfg.maximumWordSize);

    analysisCache = new AnalysisCache(settings.getAsInt("analysisCacheSize", 1024));

    String language = settings.get("language", "fi_FI");
    String dictionaryPath = settings.get("dictionaryPath");

    for (String dir : settings.getAsArray("libraryPath"))
        Voikko.addLibraryPath(dir);

    voikkoPool = new VoikkoPool(language, dictionaryPath);
    voikkoPool.setMaxSize(settings.getAsInt("poolMaxSize", 10));
}
 
开发者ID:EvidentSolutions,项目名称:elasticsearch-analysis-voikko,代码行数:22,代码来源:VoikkoTokenFilterFactory.java

示例3: testNoParentNullFieldCreatedIfNoParentSpecified

import org.elasticsearch.index.IndexSettings; //导入依赖的package包/类
public void testNoParentNullFieldCreatedIfNoParentSpecified() throws Exception {
    Index index = new Index("_index", "testUUID");
    IndexSettings indexSettings = IndexSettingsModule.newIndexSettings(index, Settings.EMPTY);
    NamedAnalyzer namedAnalyzer = new NamedAnalyzer("default", AnalyzerScope.INDEX, new StandardAnalyzer());
    IndexAnalyzers indexAnalyzers = new IndexAnalyzers(indexSettings, namedAnalyzer, namedAnalyzer, namedAnalyzer,
        Collections.emptyMap(), Collections.emptyMap());
    SimilarityService similarityService = new SimilarityService(indexSettings, Collections.emptyMap());
    MapperService mapperService = new MapperService(indexSettings, indexAnalyzers, xContentRegistry(), similarityService,
        new IndicesModule(emptyList()).getMapperRegistry(), () -> null);
    XContentBuilder mappingSource = jsonBuilder().startObject().startObject("some_type")
        .startObject("properties")
        .endObject()
        .endObject().endObject();
    mapperService.merge("some_type", new CompressedXContent(mappingSource.string()), MergeReason.MAPPING_UPDATE, false);
    Set<String> allFields = new HashSet<>(mapperService.simpleMatchToIndexNames("*"));
    assertTrue(allFields.contains("_parent"));
    assertFalse(allFields.contains("_parent#null"));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:19,代码来源:ParentFieldMapperTests.java

示例4: setRandomIndexTranslogSettings

import org.elasticsearch.index.IndexSettings; //导入依赖的package包/类
private static Settings.Builder setRandomIndexTranslogSettings(Random random, Settings.Builder builder) {
    if (random.nextBoolean()) {
        builder.put(IndexSettings.INDEX_TRANSLOG_FLUSH_THRESHOLD_SIZE_SETTING.getKey(), new ByteSizeValue(RandomNumbers.randomIntBetween(random, 1, 300), ByteSizeUnit.MB));
    }
    if (random.nextBoolean()) {
        builder.put(IndexSettings.INDEX_TRANSLOG_FLUSH_THRESHOLD_SIZE_SETTING.getKey(), new ByteSizeValue(1, ByteSizeUnit.PB)); // just don't flush
    }
    if (random.nextBoolean()) {
        builder.put(IndexSettings.INDEX_TRANSLOG_DURABILITY_SETTING.getKey(), RandomPicks.randomFrom(random, Translog.Durability.values()));
    }

    if (random.nextBoolean()) {
        builder.put(IndexSettings.INDEX_TRANSLOG_SYNC_INTERVAL_SETTING.getKey(), RandomNumbers.randomIntBetween(random, 100, 5000), TimeUnit.MILLISECONDS);
    }

    return builder;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:18,代码来源:ESIntegTestCase.java

示例5: testBuiltInAnalyzersAreCached

import org.elasticsearch.index.IndexSettings; //导入依赖的package包/类
public void testBuiltInAnalyzersAreCached() throws IOException {
    Settings settings = Settings.builder().put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString()).build();
    Settings indexSettings = Settings.builder()
            .put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT).build();
    IndexSettings idxSettings = IndexSettingsModule.newIndexSettings("index", indexSettings);
    IndexAnalyzers indexAnalyzers = new AnalysisRegistry(new Environment(settings),
            emptyMap(), emptyMap(), emptyMap(), emptyMap(), emptyMap())
            .build(idxSettings);
    IndexAnalyzers otherIndexAnalyzers = new AnalysisRegistry(new Environment(settings), emptyMap(), emptyMap(), emptyMap(),
            emptyMap(), emptyMap()).build(idxSettings);
    final int numIters = randomIntBetween(5, 20);
    for (int i = 0; i < numIters; i++) {
        PreBuiltAnalyzers preBuiltAnalyzers = RandomPicks.randomFrom(random(), PreBuiltAnalyzers.values());
        assertSame(indexAnalyzers.get(preBuiltAnalyzers.name()), otherIndexAnalyzers.get(preBuiltAnalyzers.name()));
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:AnalysisRegistryTests.java

示例6: testRangeQuery

import org.elasticsearch.index.IndexSettings; //导入依赖的package包/类
public void testRangeQuery() throws IOException {
    Settings indexSettings = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT)
            .put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1).put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 1).build();
    QueryShardContext context = new QueryShardContext(0,
            new IndexSettings(IndexMetaData.builder("foo").settings(indexSettings).build(), indexSettings),
            null, null, null, null, null, xContentRegistry(), null, null, () -> nowInMillis);
    MappedFieldType ft = createDefaultFieldType();
    ft.setName("field");
    String date1 = "2015-10-12T14:10:55";
    String date2 = "2016-04-28T11:33:52";
    long instant1 = DateFieldMapper.DEFAULT_DATE_TIME_FORMATTER.parser().parseDateTime(date1).getMillis();
    long instant2 = DateFieldMapper.DEFAULT_DATE_TIME_FORMATTER.parser().parseDateTime(date2).getMillis() + 999;
    ft.setIndexOptions(IndexOptions.DOCS);
    Query expected = new IndexOrDocValuesQuery(
            LongPoint.newRangeQuery("field", instant1, instant2),
            SortedNumericDocValuesField.newRangeQuery("field", instant1, instant2));
    assertEquals(expected,
            ft.rangeQuery(date1, date2, true, true, context).rewrite(new MultiReader()));

    ft.setIndexOptions(IndexOptions.NONE);
    IllegalArgumentException e = expectThrows(IllegalArgumentException.class,
            () -> ft.rangeQuery(date1, date2, true, true, context));
    assertEquals("Cannot search on field [field] since it is not indexed.", e.getMessage());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:25,代码来源:DateFieldTypeTests.java

示例7: testTermQuery

import org.elasticsearch.index.IndexSettings; //导入依赖的package包/类
public void testTermQuery() {
    Settings indexSettings = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT)
            .put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1).put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 1).build();
    QueryShardContext context = new QueryShardContext(0,
            new IndexSettings(IndexMetaData.builder("foo").settings(indexSettings).build(),
                    indexSettings),
            null, null, null, null, null, xContentRegistry(), null, null, () -> nowInMillis);
    MappedFieldType ft = createDefaultFieldType();
    ft.setName("field");
    String date = "2015-10-12T14:10:55";
    long instant = DateFieldMapper.DEFAULT_DATE_TIME_FORMATTER.parser().parseDateTime(date).getMillis();
    ft.setIndexOptions(IndexOptions.DOCS);
    Query expected = new IndexOrDocValuesQuery(
            LongPoint.newRangeQuery("field", instant, instant + 999),
            SortedNumericDocValuesField.newRangeQuery("field", instant, instant + 999));
    assertEquals(expected, ft.termQuery(date, context));

    ft.setIndexOptions(IndexOptions.NONE);
    IllegalArgumentException e = expectThrows(IllegalArgumentException.class,
            () -> ft.termQuery(date, context));
    assertEquals("Cannot search on field [field] since it is not indexed.", e.getMessage());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:23,代码来源:DateFieldTypeTests.java

示例8: getTokenFilterProvider

import org.elasticsearch.index.IndexSettings; //导入依赖的package包/类
/**
 * Returns a registered {@link TokenFilterFactory} provider by {@link IndexSettings}
 *  or a registered {@link TokenFilterFactory} provider by predefined name
 *  or <code>null</code> if the tokenFilter was not registered
 * @param tokenFilter global or defined tokenFilter name
 * @param indexSettings an index settings
 * @return {@link TokenFilterFactory} provider or <code>null</code>
 */
public AnalysisProvider<TokenFilterFactory> getTokenFilterProvider(String tokenFilter, IndexSettings indexSettings) {
    final Map<String, Settings> tokenFilterSettings = indexSettings.getSettings().getGroups("index.analysis.filter");
    if (tokenFilterSettings.containsKey(tokenFilter)) {
        Settings currentSettings = tokenFilterSettings.get(tokenFilter);
        String typeName = currentSettings.get("type");
        /*
         * synonym and synonym_graph are different than everything else since they need access to the tokenizer factories for the index.
         * instead of building the infrastructure for plugins we rather make it a real exception to not pollute the general interface and
         * hide internal data-structures as much as possible.
         */
        if ("synonym".equals(typeName)) {
            return requiresAnalysisSettings((is, env, name, settings) -> new SynonymTokenFilterFactory(is, env, this, name, settings));
        } else if ("synonym_graph".equals(typeName)) {
            return requiresAnalysisSettings((is, env, name, settings) -> new SynonymGraphTokenFilterFactory(is, env, this, name, settings));
        } else {
            return getAnalysisProvider(Component.FILTER, tokenFilters, tokenFilter, typeName);
        }
    } else {
        return getTokenFilterProvider(tokenFilter);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:30,代码来源:AnalysisRegistry.java

示例9: acquireFSLockForPaths

import org.elasticsearch.index.IndexSettings; //导入依赖的package包/类
/**
 * Acquires, then releases, all {@code write.lock} files in the given
 * shard paths. The "write.lock" file is assumed to be under the shard
 * path's "index" directory as used by Elasticsearch.
 *
 * @throws LockObtainFailedException if any of the locks could not be acquired
 */
public static void acquireFSLockForPaths(IndexSettings indexSettings, Path... shardPaths) throws IOException {
    Lock[] locks = new Lock[shardPaths.length];
    Directory[] dirs = new Directory[shardPaths.length];
    try {
        for (int i = 0; i < shardPaths.length; i++) {
            // resolve the directory the shard actually lives in
            Path p = shardPaths[i].resolve("index");
            // open a directory (will be immediately closed) on the shard's location
            dirs[i] = new SimpleFSDirectory(p, indexSettings.getValue(FsDirectoryService.INDEX_LOCK_FACTOR_SETTING));
            // create a lock for the "write.lock" file
            try {
                locks[i] = dirs[i].obtainLock(IndexWriter.WRITE_LOCK_NAME);
            } catch (IOException ex) {
                throw new LockObtainFailedException("unable to acquire " +
                                IndexWriter.WRITE_LOCK_NAME + " for " + p, ex);
            }
        }
    } finally {
        IOUtils.closeWhileHandlingException(locks);
        IOUtils.closeWhileHandlingException(dirs);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:30,代码来源:NodeEnvironment.java

示例10: deleteShardDirectoryUnderLock

import org.elasticsearch.index.IndexSettings; //导入依赖的package包/类
/**
 * Deletes a shard data directory. Note: this method assumes that the shard
 * lock is acquired. This method will also attempt to acquire the write
 * locks for the shard's paths before deleting the data, but this is best
 * effort, as the lock is released before the deletion happens in order to
 * allow the folder to be deleted
 *
 * @param lock the shards lock
 * @throws IOException if an IOException occurs
 * @throws ElasticsearchException if the write.lock is not acquirable
 */
public void deleteShardDirectoryUnderLock(ShardLock lock, IndexSettings indexSettings) throws IOException {
    final ShardId shardId = lock.getShardId();
    assert isShardLocked(shardId) : "shard " + shardId + " is not locked";
    final Path[] paths = availableShardPaths(shardId);
    logger.trace("acquiring locks for {}, paths: [{}]", shardId, paths);
    acquireFSLockForPaths(indexSettings, paths);
    IOUtils.rm(paths);
    if (indexSettings.hasCustomDataPath()) {
        Path customLocation = resolveCustomLocation(indexSettings, shardId);
        logger.trace("acquiring lock for {}, custom path: [{}]", shardId, customLocation);
        acquireFSLockForPaths(indexSettings, customLocation);
        logger.trace("deleting custom shard {} directory [{}]", shardId, customLocation);
        IOUtils.rm(customLocation);
    }
    logger.trace("deleted shard {} directory, paths: [{}]", shardId, paths);
    assert FileSystemUtils.exists(paths) == false;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:29,代码来源:NodeEnvironment.java

示例11: assertRealtimeGetWorks

import org.elasticsearch.index.IndexSettings; //导入依赖的package包/类
void assertRealtimeGetWorks(String indexName) {
    assertAcked(client().admin().indices().prepareUpdateSettings(indexName).setSettings(Settings.builder()
            .put("refresh_interval", -1)
            .build()));
    SearchRequestBuilder searchReq = client().prepareSearch(indexName).setQuery(QueryBuilders.matchAllQuery());
    SearchHit hit = searchReq.get().getHits().getAt(0);
    String docId = hit.getId();
    // foo is new, it is not a field in the generated index
    client().prepareUpdate(indexName, "doc", docId).setDoc(Requests.INDEX_CONTENT_TYPE, "foo", "bar").get();
    GetResponse getRsp = client().prepareGet(indexName, "doc", docId).get();
    Map<String, Object> source = getRsp.getSourceAsMap();
    assertThat(source, Matchers.hasKey("foo"));

    assertAcked(client().admin().indices().prepareUpdateSettings(indexName).setSettings(Settings.builder()
            .put("refresh_interval", IndexSettings.DEFAULT_REFRESH_INTERVAL)
            .build()));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:18,代码来源:OldIndexBackwardsCompatibilityIT.java

示例12: BitsetFilterCache

import org.elasticsearch.index.IndexSettings; //导入依赖的package包/类
public BitsetFilterCache(IndexSettings indexSettings, Listener listener) {
    super(indexSettings);
    if (listener == null) {
        throw new IllegalArgumentException("listener must not be null");
    }
    this.loadRandomAccessFiltersEagerly = this.indexSettings.getValue(INDEX_LOAD_RANDOM_ACCESS_FILTERS_EAGERLY_SETTING);
    this.loadedFilters = CacheBuilder.<Object, Cache<Query, Value>>builder().removalListener(this).build();
    this.listener = listener;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:BitsetFilterCache.java

示例13: testTooLargeFromAndSizeOkByDynamicSetting

import org.elasticsearch.index.IndexSettings; //导入依赖的package包/类
public void testTooLargeFromAndSizeOkByDynamicSetting() throws Exception {
    createIndex("idx");
    assertAcked(client().admin().indices().prepareUpdateSettings("idx")
            .setSettings(
                    Settings.builder().put(IndexSettings.MAX_RESULT_WINDOW_SETTING.getKey(),
                            IndexSettings.MAX_RESULT_WINDOW_SETTING.get(Settings.EMPTY) * 2))
            .get());
    indexRandom(true, client().prepareIndex("idx", "type").setSource("{}", XContentType.JSON));

    assertHitCount(client().prepareSearch("idx").setFrom(IndexSettings.MAX_RESULT_WINDOW_SETTING.get(Settings.EMPTY)).get(), 1);
    assertHitCount(client().prepareSearch("idx").setSize(IndexSettings.MAX_RESULT_WINDOW_SETTING.get(Settings.EMPTY) + 1).get(), 1);
    assertHitCount(client().prepareSearch("idx").setSize(IndexSettings.MAX_RESULT_WINDOW_SETTING.get(Settings.EMPTY))
            .setFrom(IndexSettings.MAX_RESULT_WINDOW_SETTING.get(Settings.EMPTY)).get(), 1);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:15,代码来源:SimpleSearchIT.java

示例14: SoraniAnalyzerProvider

import org.elasticsearch.index.IndexSettings; //导入依赖的package包/类
public SoraniAnalyzerProvider(IndexSettings indexSettings, Environment env, String name, Settings settings) {
    super(indexSettings, name, settings);
    analyzer = new SoraniAnalyzer(
        Analysis.parseStopWords(env, indexSettings.getIndexVersionCreated(), settings, SoraniAnalyzer.getDefaultStopSet()),
        Analysis.parseStemExclusion(settings, CharArraySet.EMPTY_SET)
    );
    analyzer.setVersion(version);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:9,代码来源:SoraniAnalyzerProvider.java

示例15: createStore

import org.elasticsearch.index.IndexSettings; //导入依赖的package包/类
private Store createStore(IndexSettings indexSettings, ShardPath shardPath) throws IOException {
    final ShardId shardId = shardPath.getShardId();
    final DirectoryService directoryService = new DirectoryService(shardId, indexSettings) {
        @Override
        public Directory newDirectory() throws IOException {
            return newFSDirectory(shardPath.resolveIndex());
        }
    };
    return new Store(shardId, indexSettings, directoryService, new DummyShardLock(shardId));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:11,代码来源:IndexShardTestCase.java


注:本文中的org.elasticsearch.index.IndexSettings类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。