Our application will often face all kinds of demand. Among the them , the most taboo is to the restart the server. In the application of some large, restart the service may bring some serious impact.
So, in most of the time. we should try to avoid to restart .
Then , In Solr ,how should we dynamic load some data ? such as : The dynamic load our index or Dynamic update our modified schemal and solrconfig.xml.
if you need, the CoreAdminRequest class is a good choice.
Example Code is given blow :
/**
* dynamic adding indexes
*
* Search technology group : 324714439
*
*
* */
public static void reloadIndex()throws Exception{
CoreAdminRequest admin=new CoreAdminRequest();
//some index need to be added
String []indexDirs={"D:\\mysolr\\webapps\\solr\\solr_home\\collections\\collection1\\data\\index"};
// String []srcCores={"collection2","collection1"};
String []srcCores={};
server.setBaseURL("http://localhost:9001/solr/collection2");
server.deleteByQuery("*:*");//clear old index
server.setBaseURL("http://localhost:9001/solr/");
admin.mergeIndexes("collection2", indexDirs, srcCores, server);//copy new index into target
admin.reloadCore("collection2", server);
server.setBaseURL("http://localhost:9001/solr/collection2");
server.commit();
System.out.println("execute successful !");
}
/*
* Dynamic update SolrCore
*
* avoid to the restart service
*
* **/
public static void reloadCore()throws Exception{
HttpSolrServer s=new HttpSolrServer("http://localhost:9003/solr");
CoreAdminRequest core=new CoreAdminRequest();
core.reloadCore("collection1", s);
System.out.println("reload success!");
s.commit();
}
Some is marked on the images below part, can be easy dynamically loaded .
/**
* Method 2
*
* some new method
* you don't reload core again .
*
* **/
public static void reloadIndex3()throws Exception{
HttpSolrServer server=new HttpSolrServer("http://localhost:9004/solr/collection2");
CoreAdminRequest admin=new CoreAdminRequest();
//some index need to be added
String []indexDirs={"C:\\Users\\qindongliang\\Desktop\\test\\mysolr\\webapps\\solr\\solr_home\\collections\\collection1\\data\\index"};
String []srcCores={};
server.deleteByQuery("*:*");//clear old index
admin.mergeIndexes("collection2", indexDirs, srcCores, new HttpSolrServer("http://localhost:9004/solr"));//copy new index into target
server.commit();
System.out.println("execute successful !");
}
Restart the service is bad , You need dynamic loading !

- 大小: 67.1 KB
分享到:
相关推荐
标题中的"A class to dynamically read data from any ODBC data source"是指一个可以动态地从任何ODBC数据源读取数据的类。ODBC(Open Database Connectivity)是微软开发的一种数据库访问接口,它允许应用程序通过...
" Set visibility to true to show the input field DATA(lo_node) = wd_context->get_child( 'INPUT_FIELD_NAME' ). lo_node->set_visible( lv_visible ). ENDMETHOD. ``` 在这个例子中,`zinterface~display_...
这篇教程主要介绍的是如何在运行时动态替换工具栏,这对于软件开发者来说是一个非常实用的技术,尤其是在需要根据用户需求或特定场景灵活调整界面元素的应用中。动态更换工具栏可以使应用程序更加灵活,提供更好的...
CODBCDynamic是一个面向ODBC(Open Database Connectivity)数据源的类,它允许程序员以动态的方式从各种数据库中读取数据。ODBC是微软提供的一种标准接口,使得应用程序能够与多种数据库管理系统(DBMS)进行交互,...
By the end of this book, you will be fully equipped to construct a series of Flume agents to dynamically transport your stream data and logs from your systems into Hadoop. A step-by-step book that ...
This HOWTO for programmers discusses how to create and use program libraries on Linux. This includes static libraries, shared libraries, and dynamically loaded libraries.
GTypePlugin - An interface for dynamically loadable types GTypeModule - Type loading modules GObject - The base object type Enums and Flags - Enumeration and flags types GBoxed - A mechanism to ...
动态加载DLL(Dynamic Link Library)中的类是一种在运行时按需加载代码的机制,它可以提高程序的灵活性,减少应用程序的启动时间和内存占用。这个压缩包包含的文件是关于如何实现这一功能的源代码示例。...
### Dynamically Programmable DRU for V5:关键技术点解析 #### 概述 在现代多服务光学网络中,为了能够支持各种数据传输速率,需要具备能够灵活调整工作频率的收发器。通常情况下,高速串行输入/输出(I/O)技术...
The book explains how to define and use pointers to structs, and how to dynamically allocate memory for data structures. ### Chapter 2: Introduction to Executable Statements #### 2.1 Introduction ...
### 动态自适应网格技术在潜在奇异性解中的高效应用 #### 摘要与背景 本文介绍了一种高效动态自适应网格生成方法,旨在解决时间依赖问题中出现的复杂结构甚至奇异性行为。该方法的核心是通过求解一组非线性椭圆偏...
- **4.5–2 Plotting with a For Loop**: Here, plotting functions are used in conjunction with loops to visualize data dynamically. This technique is particularly useful for engineers who need to ...
Writing Linux Device Drivers is designed to show experienced programmers how to develop device drivers for Linux systems, and give them a basic understanding and familiarity with the Linux kernel....
6、 How do I dynamically change the mainframe menu? 43 7、 How do I get the current view? 43 8、How do I create a CDC from an HDC? 43 9、Enabling or disabling dialog controls 44 10、Maximize MDI child...
you’ll learn how to be a great programmer., Understand Python’s unique method of dynamically storing data, Build Python-enabled web servers and web applications, Write mobile apps on the Android ...