本文整理汇总了Java中org.elasticsearch.search.SearchModule类的典型用法代码示例。如果您正苦于以下问题:Java SearchModule类的具体用法?Java SearchModule怎么用?Java SearchModule使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SearchModule类属于org.elasticsearch.search包,在下文中一共展示了SearchModule类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: setUp
import org.elasticsearch.search.SearchModule; //导入依赖的package包/类
/**
* Setup for the whole base test class.
*/
@Override
public void setUp() throws Exception {
super.setUp();
Settings settings = Settings.builder()
.put("node.name", AbstractQueryTestCase.class.toString())
.put(Environment.PATH_HOME_SETTING.getKey(), createTempDir())
.build();
IndicesModule indicesModule = new IndicesModule(Collections.emptyList());
SearchModule searchModule = new SearchModule(settings, false, emptyList());
List<NamedWriteableRegistry.Entry> entries = new ArrayList<>();
entries.addAll(indicesModule.getNamedWriteables());
entries.addAll(searchModule.getNamedWriteables());
namedWriteableRegistry = new NamedWriteableRegistry(entries);
xContentRegistry = new NamedXContentRegistry(searchModule.getNamedXContents());
//create some random type with some default field, those types will stick around for all of the subclasses
currentTypes = new String[randomIntBetween(0, 5)];
for (int i = 0; i < currentTypes.length; i++) {
String type = randomAsciiOfLengthBetween(1, 10);
currentTypes[i] = type;
}
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:25,代码来源:BasePipelineAggregationTestCase.java
示例2: setUp
import org.elasticsearch.search.SearchModule; //导入依赖的package包/类
@Override
public void setUp() throws Exception {
super.setUp();
// we have to prefer CURRENT since with the range of versions we support
// it's rather unlikely to get the current actually.
Settings settings = Settings.builder().put("node.name", AbstractQueryTestCase.class.toString())
.put(Environment.PATH_HOME_SETTING.getKey(), createTempDir())
.put(ScriptService.SCRIPT_AUTO_RELOAD_ENABLED_SETTING.getKey(), false).build();
// create some random type with some default field, those types will
// stick around for all of the subclasses
currentTypes = new String[randomIntBetween(0, 5)];
for (int i = 0; i < currentTypes.length; i++) {
String type = randomAsciiOfLengthBetween(1, 10);
currentTypes[i] = type;
}
xContentRegistry = new NamedXContentRegistry(new SearchModule(settings, false, emptyList()).getNamedXContents());
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:18,代码来源:AggregatorFactoriesTests.java
示例3: init
import org.elasticsearch.search.SearchModule; //导入依赖的package包/类
@BeforeClass
public static void init() throws IOException {
Path genericConfigFolder = createTempDir();
Settings baseSettings = Settings.builder()
.put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString())
.put(Environment.PATH_CONF_SETTING.getKey(), genericConfigFolder)
.build();
Environment environment = new Environment(baseSettings);
ScriptContextRegistry scriptContextRegistry = new ScriptContextRegistry(Collections.emptyList());
ScriptEngineRegistry scriptEngineRegistry = new ScriptEngineRegistry(Collections.singletonList(new TestEngineService()));
ScriptSettings scriptSettings = new ScriptSettings(scriptEngineRegistry, scriptContextRegistry);
scriptService = new ScriptService(baseSettings, environment,
new ResourceWatcherService(baseSettings, null), scriptEngineRegistry, scriptContextRegistry, scriptSettings) {
@Override
public CompiledScript compile(Script script, ScriptContext scriptContext) {
return new CompiledScript(ScriptType.INLINE, "mockName", "test", script);
}
};
SearchModule searchModule = new SearchModule(Settings.EMPTY, false, emptyList());
namedWriteableRegistry = new NamedWriteableRegistry(searchModule.getNamedWriteables());
xContentRegistry = new NamedXContentRegistry(searchModule.getNamedXContents());
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:24,代码来源:AbstractSortTestCase.java
示例4: init
import org.elasticsearch.search.SearchModule; //导入依赖的package包/类
/**
* setup for the whole base test class
*/
@BeforeClass
public static void init() throws IOException {
SearchModule searchModule = new SearchModule(Settings.EMPTY, false, emptyList());
namedWriteableRegistry = new NamedWriteableRegistry(searchModule.getNamedWriteables());
xContentRegistry = new NamedXContentRegistry(searchModule.getNamedXContents());
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:AbstractSuggestionBuilderTestCase.java
示例5: init
import org.elasticsearch.search.SearchModule; //导入依赖的package包/类
/**
* Setup for the whole base test class.
*/
@BeforeClass
public static void init() {
SearchModule searchModule = new SearchModule(Settings.EMPTY, false, emptyList());
namedWriteableRegistry = new NamedWriteableRegistry(searchModule.getNamedWriteables());
xContentRegistry = new NamedXContentRegistry(searchModule.getNamedXContents());
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:SuggestBuilderTests.java
示例6: init
import org.elasticsearch.search.SearchModule; //导入依赖的package包/类
/**
* setup for the whole base test class
*/
@BeforeClass
public static void init() {
SearchModule searchModule = new SearchModule(Settings.EMPTY, false, emptyList());
namedWriteableRegistry = new NamedWriteableRegistry(searchModule.getNamedWriteables());
xContentRegistry = new NamedXContentRegistry(searchModule.getNamedXContents());
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:HighlightBuilderTests.java
示例7: setUp
import org.elasticsearch.search.SearchModule; //导入依赖的package包/类
public void setUp() throws Exception {
super.setUp();
IndicesModule indicesModule = new IndicesModule(Collections.emptyList());
SearchModule searchModule = new SearchModule(Settings.EMPTY, false, Collections.emptyList());
List<NamedWriteableRegistry.Entry> entries = new ArrayList<>();
entries.addAll(indicesModule.getNamedWriteables());
entries.addAll(searchModule.getNamedWriteables());
namedWriteableRegistry = new NamedWriteableRegistry(entries);
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:ExplainRequestTests.java
示例8: testBuilderAndParser
import org.elasticsearch.search.SearchModule; //导入依赖的package包/类
public void testBuilderAndParser() throws Exception {
SearchModule searchModule = new SearchModule(Settings.EMPTY, false, emptyList());
ParseFieldRegistry<SignificanceHeuristicParser> heuristicParserMapper = searchModule.getSignificanceHeuristicParserRegistry();
// test jlh with string
assertTrue(parseFromString(heuristicParserMapper, "\"jlh\":{}") instanceof JLHScore);
// test gnd with string
assertTrue(parseFromString(heuristicParserMapper, "\"gnd\":{}") instanceof GND);
// test mutual information with string
boolean includeNegatives = randomBoolean();
boolean backgroundIsSuperset = randomBoolean();
String mutual = "\"mutual_information\":{\"include_negatives\": " + includeNegatives + ", \"background_is_superset\":"
+ backgroundIsSuperset + "}";
assertEquals(new MutualInformation(includeNegatives, backgroundIsSuperset),
parseFromString(heuristicParserMapper, mutual));
String chiSquare = "\"chi_square\":{\"include_negatives\": " + includeNegatives + ", \"background_is_superset\":"
+ backgroundIsSuperset + "}";
assertEquals(new ChiSquare(includeNegatives, backgroundIsSuperset),
parseFromString(heuristicParserMapper, chiSquare));
// test with builders
assertThat(parseFromBuilder(heuristicParserMapper, new JLHScore()), instanceOf(JLHScore.class));
assertThat(parseFromBuilder(heuristicParserMapper, new GND(backgroundIsSuperset)), instanceOf(GND.class));
assertEquals(new MutualInformation(includeNegatives, backgroundIsSuperset),
parseFromBuilder(heuristicParserMapper, new MutualInformation(includeNegatives, backgroundIsSuperset)));
assertEquals(new ChiSquare(includeNegatives, backgroundIsSuperset),
parseFromBuilder(heuristicParserMapper, new ChiSquare(includeNegatives, backgroundIsSuperset)));
// test exceptions
String faultyHeuristicdefinition = "\"mutual_information\":{\"include_negatives\": false, \"some_unknown_field\": false}";
String expectedError = "unknown field [some_unknown_field]";
checkParseException(heuristicParserMapper, faultyHeuristicdefinition, expectedError);
faultyHeuristicdefinition = "\"chi_square\":{\"unknown_field\": true}";
expectedError = "unknown field [unknown_field]";
checkParseException(heuristicParserMapper, faultyHeuristicdefinition, expectedError);
faultyHeuristicdefinition = "\"jlh\":{\"unknown_field\": true}";
expectedError = "expected an empty object, but found ";
checkParseException(heuristicParserMapper, faultyHeuristicdefinition, expectedError);
faultyHeuristicdefinition = "\"gnd\":{\"unknown_field\": true}";
expectedError = "unknown field [unknown_field]";
checkParseException(heuristicParserMapper, faultyHeuristicdefinition, expectedError);
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:46,代码来源:SignificanceHeuristicTests.java
示例9: init
import org.elasticsearch.search.SearchModule; //导入依赖的package包/类
@BeforeClass
public static void init() {
SearchModule searchModule = new SearchModule(Settings.EMPTY, false, emptyList());
xContentRegistry = new NamedXContentRegistry(searchModule.getNamedXContents());
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:6,代码来源:SortBuilderTests.java
示例10: init
import org.elasticsearch.search.SearchModule; //导入依赖的package包/类
@BeforeClass
public static void init() {
SearchModule searchModule = new SearchModule(Settings.EMPTY, false, emptyList());
namedWriteableRegistry = new NamedWriteableRegistry(searchModule.getNamedWriteables());
xContentRegistry = new NamedXContentRegistry(searchModule.getNamedXContents());
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:7,代码来源:CollapseBuilderTests.java
示例11: init
import org.elasticsearch.search.SearchModule; //导入依赖的package包/类
@BeforeClass
public static void init() {
xContentRegistry = new NamedXContentRegistry(new SearchModule(Settings.EMPTY, false, emptyList()).getNamedXContents());
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:QueryParseContextTests.java
示例12: testSerialization
import org.elasticsearch.search.SearchModule; //导入依赖的package包/类
public void testSerialization() throws Exception {
Map<String, AliasFilter> indicesAndFilters = new HashMap<>();
Set<DiscoveryNode> nodes = new HashSet<>();
int numShards = randomIntBetween(1, 10);
ClusterSearchShardsGroup[] clusterSearchShardsGroups = new ClusterSearchShardsGroup[numShards];
for (int i = 0; i < numShards; i++) {
String index = randomAsciiOfLengthBetween(3, 10);
ShardId shardId = new ShardId(index, randomAsciiOfLength(12), i);
String nodeId = randomAsciiOfLength(10);
ShardRouting shardRouting = TestShardRouting.newShardRouting(shardId, nodeId, randomBoolean(), ShardRoutingState.STARTED);
clusterSearchShardsGroups[i] = new ClusterSearchShardsGroup(shardId, new ShardRouting[]{shardRouting});
DiscoveryNode node = new DiscoveryNode(shardRouting.currentNodeId(),
new TransportAddress(TransportAddress.META_ADDRESS, randomInt(0xFFFF)), VersionUtils.randomVersion(random()));
nodes.add(node);
AliasFilter aliasFilter;
if (randomBoolean()) {
aliasFilter = new AliasFilter(RandomQueryBuilder.createQuery(random()), "alias-" + index);
} else {
aliasFilter = new AliasFilter(null, Strings.EMPTY_ARRAY);
}
indicesAndFilters.put(index, aliasFilter);
}
ClusterSearchShardsResponse clusterSearchShardsResponse = new ClusterSearchShardsResponse(clusterSearchShardsGroups,
nodes.toArray(new DiscoveryNode[nodes.size()]), indicesAndFilters);
SearchModule searchModule = new SearchModule(Settings.EMPTY, false, Collections.emptyList());
List<NamedWriteableRegistry.Entry> entries = new ArrayList<>();
entries.addAll(searchModule.getNamedWriteables());
NamedWriteableRegistry namedWriteableRegistry = new NamedWriteableRegistry(entries);
Version version = VersionUtils.randomVersionBetween(random(), Version.V_5_0_0, Version.CURRENT);
try(BytesStreamOutput out = new BytesStreamOutput()) {
out.setVersion(version);
clusterSearchShardsResponse.writeTo(out);
try(StreamInput in = new NamedWriteableAwareStreamInput(out.bytes().streamInput(), namedWriteableRegistry)) {
in.setVersion(version);
ClusterSearchShardsResponse deserialized = new ClusterSearchShardsResponse();
deserialized.readFrom(in);
assertArrayEquals(clusterSearchShardsResponse.getNodes(), deserialized.getNodes());
assertEquals(clusterSearchShardsResponse.getGroups().length, deserialized.getGroups().length);
for (int i = 0; i < clusterSearchShardsResponse.getGroups().length; i++) {
ClusterSearchShardsGroup clusterSearchShardsGroup = clusterSearchShardsResponse.getGroups()[i];
ClusterSearchShardsGroup deserializedGroup = deserialized.getGroups()[i];
assertEquals(clusterSearchShardsGroup.getShardId(), deserializedGroup.getShardId());
assertArrayEquals(clusterSearchShardsGroup.getShards(), deserializedGroup.getShards());
}
if (version.onOrAfter(Version.V_5_1_1_UNRELEASED)) {
assertEquals(clusterSearchShardsResponse.getIndicesAndFilters(), deserialized.getIndicesAndFilters());
} else {
assertNull(deserialized.getIndicesAndFilters());
}
}
}
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:54,代码来源:ClusterSearchShardsResponseTests.java
示例13: build
import org.elasticsearch.search.SearchModule; //导入依赖的package包/类
/**
* Builds a new instance of the transport client.
*/
public TransportClient build() {
Settings settings = InternalSettingsPreparer.prepareSettings(this.settings);
settings = settingsBuilder()
.put(NettyTransport.PING_SCHEDULE, "5s") // enable by default the transport schedule ping interval
.put(settings)
.put("network.server", false)
.put("node.client", true)
.put(CLIENT_TYPE_SETTING, CLIENT_TYPE)
.build();
PluginsService pluginsService = new PluginsService(settings, null, null, pluginClasses);
this.settings = pluginsService.updatedSettings();
Version version = Version.CURRENT;
final ThreadPool threadPool = new ThreadPool(settings);
NamedWriteableRegistry namedWriteableRegistry = new NamedWriteableRegistry();
boolean success = false;
try {
ModulesBuilder modules = new ModulesBuilder();
modules.add(new Version.Module(version));
// plugin modules must be added here, before others or we can get crazy injection errors...
for (Module pluginModule : pluginsService.nodeModules()) {
modules.add(pluginModule);
}
modules.add(new PluginsModule(pluginsService));
modules.add(new SettingsModule(this.settings));
modules.add(new NetworkModule(namedWriteableRegistry));
modules.add(new ClusterNameModule(this.settings));
modules.add(new ThreadPoolModule(threadPool));
modules.add(new TransportModule(this.settings, namedWriteableRegistry));
modules.add(new SearchModule() {
@Override
protected void configure() {
// noop
}
});
modules.add(new ActionModule(true));
modules.add(new ClientTransportModule());
modules.add(new CircuitBreakerModule(this.settings));
pluginsService.processModules(modules);
Injector injector = modules.createInjector();
final TransportService transportService = injector.getInstance(TransportService.class);
transportService.start();
transportService.acceptIncomingRequests();
TransportClient transportClient = new TransportClient(injector);
success = true;
return transportClient;
} finally {
if (!success) {
ThreadPool.terminate(threadPool, 10, TimeUnit.SECONDS);
}
}
}
开发者ID:baidu,项目名称:Elasticsearch,代码行数:62,代码来源:TransportClient.java
示例14: onModule
import org.elasticsearch.search.SearchModule; //导入依赖的package包/类
public void onModule(SearchModule module) {
module.registerAggregatorParser(MultipleMetricParser.class);
InternalMultipleMetric.registerStreams();
}
开发者ID:eliep,项目名称:elasticsearch-multiple-metric-aggregation,代码行数:5,代码来源:MultipleMetricPlugin.java
示例15: onModule
import org.elasticsearch.search.SearchModule; //导入依赖的package包/类
public void onModule(SearchModule module) {
module.registerAggregatorParser(PathParser.class);
InternalPath.registerStreams();
}
开发者ID:jprante,项目名称:elasticsearch-aggregations,代码行数:5,代码来源:AggregationPlugin.java
示例16: onModule
import org.elasticsearch.search.SearchModule; //导入依赖的package包/类
public void onModule(SearchModule searchModule) {
searchModule.registerFetchSubPhase(VectorizeFetchSubPhase.class);
}
开发者ID:alexksikes,项目名称:elasticsearch-vectorize,代码行数:4,代码来源:FetchVectorizePlugin.java
示例17: onModule
import org.elasticsearch.search.SearchModule; //导入依赖的package包/类
public void onModule(SearchModule searchModule) {
searchModule.registerFunctionScoreParser(CondBoostFactorFunctionParser.class);
}
开发者ID:jprante,项目名称:elasticsearch-functionscore-conditionalboost,代码行数:4,代码来源:CondBoostPlugin.java
示例18: build
import org.elasticsearch.search.SearchModule; //导入依赖的package包/类
public TransportClient build() {
Settings settings = InternalSettingsPreparer.prepareSettings(this.settings);
settings = settingsBuilder()
.put("transport.ping.schedule", this.settings.get("ping.interval", "30s"))
.put(settings)
.put("network.server", false)
.put("node.client", true)
.put(CLIENT_TYPE_SETTING, CLIENT_TYPE)
.build();
PluginsService pluginsService = new PluginsService(settings, null, null, pluginClasses);
this.settings = pluginsService.updatedSettings();
Version version = Version.CURRENT;
final ThreadPool threadPool = new ThreadPool(settings);
final NamedWriteableRegistry namedWriteableRegistry = new NamedWriteableRegistry();
boolean success = false;
try {
ModulesBuilder modules = new ModulesBuilder();
modules.add(new Version.Module(version));
// plugin modules must be added here, before others or we can get crazy injection errors...
for (Module pluginModule : pluginsService.nodeModules()) {
modules.add(pluginModule);
}
modules.add(new PluginsModule(pluginsService));
modules.add(new SettingsModule(this.settings));
modules.add(new NetworkModule(namedWriteableRegistry));
modules.add(new ClusterNameModule(this.settings));
modules.add(new ThreadPoolModule(threadPool));
modules.add(new TransportModule(this.settings, namedWriteableRegistry));
modules.add(new SearchModule() {
@Override
protected void configure() {
// noop
}
});
modules.add(new ActionModule(true));
modules.add(new ClientTransportModule(hostFailedListener));
modules.add(new CircuitBreakerModule(this.settings));
pluginsService.processModules(modules);
Injector injector = modules.createInjector();
injector.getInstance(TransportService.class).start();
TransportClient transportClient = new TransportClient(injector);
success = true;
return transportClient;
} finally {
if (!success) {
ThreadPool.terminate(threadPool, 10, TimeUnit.SECONDS);
}
}
}
开发者ID:jprante,项目名称:elasticsearch-helper,代码行数:51,代码来源:TransportClient.java
示例19: onModule
import org.elasticsearch.search.SearchModule; //导入依赖的package包/类
/**
* Old-style search extension point. {@code @Deprecated} and {@code final} to act as a signpost for plugin authors upgrading
* from 2.x.
*
* @deprecated implement {@link SearchPlugin} instead
*/
@Deprecated
public final void onModule(SearchModule module) {}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:9,代码来源:Plugin.java
注:本文中的org.elasticsearch.search.SearchModule类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论