solr安装指南

注本文以solr3.3为例
  Solr 是一个开源的企业级搜索服务器,底层使用易于扩展和修改的Java 来实现。
Solr 主要特性有:强大的全文检索功能,高亮显示检索结果,动态集群,数据库接口和电子文档(Word ,PDF 等)的处理。而且Solr 具有高度的可扩展,支持分布搜索和索引的复制。

Solr 底层的核心技术是使用Apache Lucene 来实现的,简单的说Solr 是Lucene 的服务器化。需要注意的是Solr 并不是简单的对Lucene 进行封装,它所提供的大部分功能都区别于Lucene 。

WINDOWS/linux SOLR安装
【linux参考】:/admin/blogs/1171098

【windows如下】

环境参数:
Solr apache-solr-3.3.0
搭建步骤:
1. 下载所需软件,安装配置Tomcat。
下载软件为 :Tomcat与Solr,jdk1.6,官网都可免费下载。
2. Tomcat 配置文件conf\server.xml
添加编码的配置 URIEncoding=”UTF-8” (如不添加,中文检索时因为乱码搜索不到)。
添加后为:
&Connector port=”8983” protocol=”HTTP/1.1” connectionTimeout=”20000”
redirectPort=”8443” URIEncoding=”UTF-8”
4. 将D:\solr\apache-solr-3.3.0 解压
5. 建立d:/solr/home主目录(可以根据自己的情况建立),把D:\solr\apache-solr-3.3.0\example\solr复制到该目录下。
6. 建立solr.home 环境变量:置为 d:/solr/home
7. 将solr.War复制到tomcat的webapp下启动是会自动解压。
8. 修改D:\resouce\java\tomcat\webapps\solr\WEB-INF\web.xml.
&env-entry&
&env-entry-name&solr/home&/env-entry-name&
&env-entry-value&d:\solr\home&/env-entry-value&
&env-entry-type&java.lang.String&/env-entry-type&
&/env-entry&
9. 启动tomcat,浏览器输入:

10.看到页面说明部署成功

solr 将MYSQL数据库做成索引数据源【注意格式】

参考:/apachesolr/apache-solr-mysql-sample-data-config

1、在solrconfig.xml中添加,增加导入数据功能
&requestHandler name=”/dataimport” class=”org.apache.solr.handler.dataimport.DataImportHandler”&
&lst name=”defaults”&
&str name=”config”&data-config.xml&/str&
&/requestHandler&
2、添加一个数据源data-config.xml,代码如下
&dataConfig&
&dataSource type=”JdbcDataSource”
driver=”com.mysql.jdbc.Driver”
url=”jdbc:mysql://localhost/test”
user=”root”
password=”“/&
&document name=”content”&
&entity name=”node” query=”select id,name,title from solrdb”&
&field column=”nid” name=”id” /&
&field column=”name” name=”name” /&
&field column=”title” name=”title” /&
&/document&
&/dataConfig&
3、创建schema.xml语法,代码如下
&?xml version=”1.0” encoding=”UTF-8” ?&
&schema name=”example” version=”1.4”&
&fieldType name=”tint” class=”solr.TrieIntField” precisionStep=”8” omitNorms=”true” positionIncrementGap=”0”/&
&fieldType name=”string” class=”solr.StrField” sortMissingLast=”true” omitNorms=”true”/&
&fieldType name=”text” class=”solr.TextField” positionIncrementGap=”100”&
&analyzer type=”index”&
&tokenizer class=”solr.StandardTokenizerFactory”/&
&filter class=”solr.StopFilterFactory” ignoreCase=”true” words=”stopwords.txt” enablePositionIncrements=”true” /&
&filter class=”solr.LowerCaseFilterFactory”/&
&/analyzer&
&analyzer type=”query”&
&tokenizer class=”solr.StandardTokenizerFactory”/&
&filter class=”solr.StopFilterFactory” ignoreCase=”true” words=”stopwords.txt” enablePositionIncrements=”true” /&
&filter class=”solr.SynonymFilterFactory” synonyms=”synonyms.txt” ignoreCase=”true” expand=”true”/&
&filter class=”solr.LowerCaseFilterFactory”/&
&/analyzer&
&/fieldType&
&fieldType name=”date” class=”solr.TrieDateField” omitNorms=”true” precisionStep=”0” positionIncrementGap=”0”/&
&field name=”id” type=”string” indexed=”true” stored=”true” required=”true” /&
&field name=”title” type=”string” indexed=”true” stored=”true”/&
&field name=”contents” type=”text” indexed=”true” stored=”true”/&
&uniqueKey&id&/uniqueKey&
&defaultSearchField&contents&/defaultSearchField&
&solrQueryParser defaultOperator=”OR”/&
&copyField source=”title” dest=”contents”/&
schema.xml 里重要的字段
要有这个copyField字段SOLR才能检索多个字段的值【以下设置将同时搜索 title,name,contents中的值】
&defaultSearchField&contents&/defaultSearchField&
copyField是用???你一??位?的值到另一?位用. 如你可以?name?的?西copy到default?, ??solr做?索?也??索到name?的?西.
&copyField source=”name” dest=”contents”/&
&copyField source=”title” dest=”contents”/&
4、创建索引
http://192.168.171.129:8983/solr/dataimport?command=full-import

注:保证与数据库连接正确

solr 创建增量索引

主要是修改data-config.xml 数据源

&dataConfig&
&dataSource driver=”com.mysql.jdbc.Driver” url=”jdbc:mysql://localhost/demo” user=”root” password=”“/&
&document name=”products”&
&entity name=”item” pk=”id”
query=”SELECT id,title,contents,last_index_time FROM solr_articles”
deltaImportQuery=”SELECT id,title,contents,last_index_time FROM solr_articles
WHERE id = ‘{dataimporter.delta.id}’”  
deltaQuery=”SELECT id FROM solr_articles  
WHERE last_index_time & ‘
{dataimporter.last_index_time}’”&
&/document&
&/dataConfig&
注意数据库相关表的创建
如本例中 solr_articles表中有 last_index_time(timestamp)字段,每当增加或者更新了值都应修改last_index_time的值,以便增量索引能更新到
有问题请即时查看TOMCAT的LOG日志文件
运行:http://192.168.171.129:8983/solr/dataimport?command=delta-import

如果运行后未达到你的预期,请查看dataimport.properties文件的日期,并组合新SQL语句查询来调整问题

multiple core(SOLR多个索引共存)

参考:http://wiki.apache.org/solr/CoreAdmin

1、配置多个索引
&solr persistent=”true” sharedLib=”lib”&
&cores adminPath=”/admin/cores”&
&core name=”core0” instanceDir=”core0” dataDir=”D:\solr\home\core0\data”/&
&core name=”core1” instanceDir=”core1” dataDir=”D:\solr\home\core1\data” /&
2、将D:\solr\apache-solr-3.3.0\example\multicore下的 core0,core1两个文件拷贝到D:\solr\home下,D:\solr\home目录下之前的任务目录及文件不变
注:D:\solr\home目录为D:\solr\apache-solr-3.3.0\example\solr
3、建立两个索引数据存放目录
D:\solr\home\core0\data
D:\solr\home\core1\data
4、修改其中一个索引如CORE1
修改solrconfig.xml为如下代码
【注 需要加入 lib 标签主要是因为DataImportHandler 为报错,这可能是官方的BUG】
&?xml version=”1.0” encoding=”UTF-8” ?&
&luceneMatchVersion&LUCENE_33&/luceneMatchVersion&
&directoryFactory name=”DirectoryFactory” class=”${solr.directoryFactory:solr.StandardDirectoryFactory}”/&
&lib dir=”D:/solr/apache-solr-3.3.0/contrib/extraction/lib” /&
&lib dir=”D:/solr/apache-solr-3.3.0/dist/” regex=”apache-solr-cell-\d.*.jar” /&
&lib dir=”D:/solr/apache-solr-3.3.0/dist/” regex=”apache-solr-clustering-\d.*.jar” /&
&lib dir=”D:/solr/apache-solr-3.3.0/dist/” regex=”apache-solr-dataimporthandler-\d.*.jar” /&
&lib dir=”D:/solr/apache-solr-3.3.0/contrib/clustering/lib/” /&
&lib dir=”/total/crap/dir/ignored” /&
&updateHandler class=”solr.DirectUpdateHandler2” /&
&requestDispatcher handleSelect=”true” &
&requestParsers enableRemoteStreaming=”false” multipartUploadLimitInKB=”2048” /&
&/requestDispatcher&
&requestHandler name=”standard” class=”solr.StandardRequestHandler” default=”true” /&
&requestHandler name=”/update” class=”solr.XmlUpdateRequestHandler” /&
&requestHandler name=”/admin/” class=”org.apache.solr.handler.admin.AdminHandlers” /&
&defaultQuery&solr&/defaultQuery&
&requestHandler name=”/dataimport” class=”org.apache.solr.handler.dataimport.DataImportHandler”&
&lst name=”defaults”&
&str name=”config”&data-config.xml&/str&
&/requestHandler&

最后运行 http://localhost:8080/solr/core1/admin/

定时更新SOLR索引
因SOLR的索引更新是经过HTTP的,所以不能直接使用CRON,现在我们换一种方式
将要访问的HTTP写入到PHP文件中,经过定时运行PHP文件来达到更新SORL索引目录

10/* * * * * /usr/local/php/bin/php /yym/cronfile/solr_cron.php?t=index_delta

  • Created on
  • @author tianyongchun
  • 此文件用于定时更新SOLR的索引
  • @param t为更新类型 带不同的参考更新不同的索引
  • 此文件可以通过LINUX的CRON方法运行以便达到定时更新索引
    set_time_limit(0);
  • 增量更新
  • index_delta
  • index_full
    t= _GET[‘t’];
    //http://192.168.171.129:8983/solr/dataimport?command=delta-import
    $url = ‘http://localhost:8983/solr/dataimport?command=‘;
    r=resulterror;if( t ==’index_delta’){
    r=filegetcontents( url.’delta-import’);
    }else if(t ==”index_full”){r = file_get_contents($url.’full-import’);
    echo ‘param error’;

var_dump($r);

solr 的PHP客户端

从名字就可以看出,这是 Solr 的 PHP 客户端开发包。
通过这个包可以像

/p/solr-php-client/downloads/list

常见错误 org.mon.SolrException: Error loading class ‘org.apache.solr.handler.dataimport.DataImportHandler

将solrconfig.xml中的值改为如下:【主要是指定SOLR的主目录路径出错】
&lib dir=”D:/solr/apache-solr-3.3.0/contrib/extraction/lib” /&
&!– When a regex is specified in addition to a directory, only the
files in that directory which completely match the regex
(anchored on both ends) will be included.
&lib dir=”D:/solr/apache-solr-3.3.0/dist/” regex=”apache-solr-cell-\d.*.jar” /&
&lib dir=”D:/solr/apache-solr-3.3.0/dist/” regex=”apache-solr-clustering-\d.*.jar” /&
&lib dir=”D:/solr/apache-solr-3.3.0/dist/” regex=”apache-solr-dataimporthandler-\d.*.jar” /&
&!– If a dir option (with or without a regex) is used and nothing
is found that matches, it will be ignored

&lib dir=”D:/solr/apache-solr-3.3.0/contrib/clustering/lib/” /&

I experienced the same issue. With Solr 1.x, I was copying out the
‘example’ directory to make my solr installation. However, for the
Solr 3.x distributions, the DataImportHandler class exists in a
directory that is at the same level as example: “dist”, not a
directory within.
You’ll either want to take the entire apache 3.1 directory, or modify
solrconfig to point to the new place you’ve copied it:

&lib dir=”../../dist/” regex=”apache-solr-dataimporthandler-\d.*.jar” /&

solr搜索不出数据

SELECT id,title,main_contents as contents,last_index_time FROM solr_articles

要使用&field column=”NAME” name=”name” /&最好将schema.xml中通过field配置相应的名字

solr 分布式(复制)配置

参考://blog/item/3985aaf1f8f150d00a46e080.html

下载次数: 272
浏览 17074
浏览: 218823 次
来自: 杭州
libmw 写道你好,请问现在爱就是幸福网的首页,扫描二维码为 …
你好,请问现在爱就是幸福网的首页,扫描二维码为啥不是下载apk …
简单,有效,就是速度慢了些!
【就是在建数据源的时候(这时你要填写数据库的IP,用户名及密码 …
“最后在连接的ODBC中使用GB2312结果把乱码给解决了”能 …Apache Solr 5.4.1 发布下载,全文搜索服务器
(window.slotbydup=window.slotbydup || []).push({
id: ‘2611110’,
container: s,
size: ‘240,200’,
display: ‘inlay-fix’
您当前位置: &
[ 所属分类
作者 红领巾 ]
Apache Solr 5.4.1 发布下载,更新如下:
Bug Fixes (8)
SOLR-8460: /analysis/field could throw exceptions for custom attributes.(David Smiley, Uwe Schindler)
SOLR-8373: KerberosPlugin: Using multiple nodes on same machine leads clients to fetch TGT for every request(Ishan Chattopadhyaya via noble)
SOLR-8059: &debug=results for distributed search when distrib.singlePass (sometimes activated automatically) could result in an NPE.(David Smiley, Markus Jelsma)
SOLR-8422: When authentication enabled, requests fail if sent to a node that doesn’t host the collection(noble)
SOLR-7462: AIOOBE in RecordingJSONParser(Scott Dawson, noble)
SOLR-8496: SolrIndexSearcher.getDocSet(List&Query&) incorrectly included deleted documents when all of the queries were uncached (or there was no filter cache). This caused multi-select faceting (including the JSON Facet API) to include deleted doc counts when the remaining non-excluded filters were all uncached. This bug was first introduced in 5.3.0(Andreas Müller, Vasiliy Bout, Erick Erickson, Shawn Heisey, Hossman, yonik)
SOLR-8418: Adapt to changes in LUCENE-6590 for use of boosts with MLTHandler and Simple/CloudMLTQParser(Jens Wille, Ramkumar Aiyengar)
SOLR-8561: Doing a rolling upgrade to 5.4.0 fails because the new nodes cannot find the shard leader properties where they expect. This bug was first introduced in 5.4.0 and a fallback was added so that the leader properties are searched in both the old location and the new one.(Shai Erera)
New Features (1)
SOLR-8470: Make TTL of PKIAuthenticationPlugin’s tokens configurable through a system property (pkiauth.ttl)(noble)
更多内容请看:/lucene/solr/5.4.1/Apache Solr (读音:SOLer)是一个开源的搜索服务器。Solr 使用 Java 语言开发,主要基于 HTTP 和 Apache Lucene 实现。Apache Solr 中存储的资源是以 Document 为对象进行存储的。每个文档由一系列的 Field 构成,每个 Field 表示资源的一个属性。Solr 中的每个 Document 需要有能唯一标识其自身的属性,默认情况下这个属性的名字是 id,在 Schema 配置文件中使用:id进行描述。Solr3.6.1 在Tomcat6下的环境搭建 /Linux/64.htm基于Tomcat的Solr3.5集群部署 http://www.codesec.net/Linux/97.htm在Linux上使用Nginx为Solr集群做负载均衡 http://www.codesec.net/Linux/57.htmLinux下安装使用Solr http://www.codesec.net/Linux/29.htm在 Ubuntu 12.04 LTS 上通过 Tomcat 部署 Solr 4 http://www.codesec.net/Linux/58.htmSolr实现Low Level查询解析(QParser) http://www.codesec.net/Linux/55.htm基于Solr 3.5搭建搜索服务器 http://www.codesec.net/Linux/43.htmSolr 3.5开发应用教程 PDF高清版 http://www.codesec.net/Linux/48.htmSolr 4.0 部署实例教程 http://www.codesec.net/Linux/41.htmSolr 的详细介绍:请点这里Solr 的下载地址:请点这里本文地址:http://www.codesec.net/Linux/725.htm
本文系统(linux)相关术语:linux系统 鸟哥的linux私房菜 linux命令大全 linux操作系统
转载请注明本文标题:本站链接:
分享请点击:
1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限…
你必须要足够努力,才能让别人觉得你毫不费力。
手机客户端
,专注代码审计及安全周边编程,转载请注明出处:http://www.codesec.net
转载文章如有侵权,请邮件 admin[at]codesec.net1. 操作系统:win7 。
2. solr 运行环境: jdk1.7.0_79;apache-tomcat-8.0.23。
3. solr5.4.1下载地址
下载solr-5.4.1.zip,并解压。
4. 拷贝solr-5.4.1\server\solr-webapp下的webapp文件夹到D:\apache-tomcat-8.0.23\webapps下,并且重命名为solr。
5. 拷贝solr-5.4.1\server\lib\ext下的所有jar文件到D:\apache-tomcat-8.0.23\lib下。
6. 将solr-5.4.1/server下solr文件夹拷贝到apache-tomcat-8.0.23根目录下,并重命名为solr_home(存放检索数据)。
7. 修改D:\apache-tomcat-8.0.23\webapps\solr\WEB-INF\web.xml文件,找到&env-entry&节点,该结点处于被注释状态,去掉注释,按如下代码修改:
&&& &env-entry&
&&&&&& &env-entry-name&solr/home&/env-entry-name&
&&&&&& &env-entry-value&D:/apache-tomcat-8.0.23/solr_home&/env-entry-value&
&&&&&& &env-entry-type&java.lang.String&/env-entry-type&
&&&& &/env-entry&
8. 将solr-5.4.1\server\resources/目录下的log4j.properties放到D:\apache-tomcat-8.0.23\webapps\solr\WEB-INF\classes\目录下,如果classes文件夹不存在就手动新建一个;
9. 还需要添加solr-5.4.1\dist目录下的\solr-dataimporthandler-5.3.0.jar和solr-dataimporthandler-extras-5.3.0.jar这2个jar包到目录D:\apache-tomcat-8.0.23\lib下,否则会报错;
10. 重启TOMCAT.
11. 访问:http://127.0.0.1:8080/solr/index.html 可以看到Solr的控制台.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值