`
qindongliang1922
  • 浏览: 2196900 次
  • 性别: Icon_minigender_1
  • 来自: 北京
博客专栏
7265517b-f87e-3137-b62c-5c6e30e26109
证道Lucene4
浏览量:117907
097be4a0-491e-39c0-89ff-3456fadf8262
证道Hadoop
浏览量:126317
41c37529-f6d8-32e4-8563-3b42b2712a50
证道shell编程
浏览量:60273
43832365-bc15-3f5d-b3cd-c9161722a70c
ELK修真
浏览量:71617
社区版块
存档分类
最新评论

How to dynamically loading data for solr ?

阅读更多
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动

    标题中的"A class to dynamically read data from any ODBC data source"是指一个可以动态地从任何ODBC数据源读取数据的类。ODBC(Open Database Connectivity)是微软开发的一种数据库访问接口,它允许应用程序通过...

    How to dynamically create, edit, display UI elements in WebDynpro

    " 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_...

    A simple tutorial that shows how to dynamically replace tool

    这篇教程主要介绍的是如何在运行时动态替换工具栏,这对于软件开发者来说是一个非常实用的技术,尤其是在需要根据用户需求或特定场景灵活调整界面元素的应用中。动态更换工具栏可以使应用程序更加灵活,提供更好的...

    CODBCDynamic - A class to dynamically read data from any ODB

    CODBCDynamic是一个面向ODBC(Open Database Connectivity)数据源的类,它允许程序员以动态的方式从各种数据库中读取数据。ODBC是微软提供的一种标准接口,使得应用程序能够与多种数据库管理系统(DBMS)进行交互,...

    Apache Flume Distributed Log Collection for Hadoop(PACKT,2ed,2015)

    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 ...

    Program Library Howto

    This HOWTO for programmers discusses how to create and use program libraries on Linux. This includes static libraries, shared libraries, and dynamically loaded libraries.

    GObject Reference Manual

    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 ...

    Dynamically loading classes from DLLs(7KB)

    动态加载DLL(Dynamic Link Library)中的类是一种在运行时按需加载代码的机制,它可以提高程序的灵活性,减少应用程序的启动时间和内存占用。这个压缩包包含的文件是关于如何实现这一功能的源代码示例。...

    Dynamically Programmable DRU for V5

    ### Dynamically Programmable DRU for V5:关键技术点解析 #### 概述 在现代多服务光学网络中,为了能够支持各种数据传输速率,需要具备能够灵活调整工作频率的收发器。通常情况下,高速串行输入/输出(I/O)技术...

    c-programming-for-scientists-and-engineers-manufacturing-engineering-series

    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 ...

    An Efficient Dynamically Adaptive Mesh for potentially singular solutions

    ### 动态自适应网格技术在潜在奇异性解中的高效应用 #### 摘要与背景 本文介绍了一种高效动态自适应网格生成方法,旨在解决时间依赖问题中出现的复杂结构甚至奇异性行为。该方法的核心是通过求解一组非线性椭圆偏...

    Introduction to MATLAB for Engineers

    - **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: a guide with exercises

    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....

    VC代码示例及说明,代码片段,自己总结和来自网上

    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...

    Head First Python

    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 ...

Global site tag (gtag.js) - Google Analytics