Solr 使用入门介绍

原文出处:http://blog.chenlb.com/2009/05/apache-solr-quick-start-and-demo.html

前些日子做了个 apache solr 应用的入门介绍,也在博客记录下,方便新手看看。以搜索论坛帖子为示例。

1、先下载 Apache Solr 1.3 http://apache.etoak.com/lucene/solr/1.3.0/apache-solr-1.3.0.zip,解压到如 E:\apache-solr-1.3.0。

2、下载 Apache Tomcat 6.0.18 http://labs.xiaonei.com/apache-mirror/tomcat/tomcat-6/v6.0.18/bin/apache-tomcat-6.0.18.zip,解压到如 E:\apache-tomcat-6.0.18。

3、solr 安装到 tomcat。修改 E:\apache-tomcat-6.0.18\conf\server.xml,加个 URIEncoding="UTF-8",把 8080 的那一块改为:

把下面的内容保存到 E:\apache-tomcat-6.0.18\conf\Catalina\localhost\solr.xml,没有这个目录自行创建。

solr 的更多方式请看:solr install

4、现在安装好,启动 tomcat,并打开 http://localhost:8080/solr/admin/ 看看界面。

5、为搜索论坛帖子应用设计索引结构:

字段说明
id帖子 id
user发表用户名或UserId
title标题
content内容
timestamp发表时间
text把标题和内容放到这里,可以用同时搜索这些内容。

6、上面的索引结构告诉 solr,把下面的内容覆盖 E:\apache-solr-1.3.0\example\solr\conf\scheam.xml,(可以先备份这文件,方便以后看官方示例):

  1. <?xml version="1.0" encoding="UTF-8" ?>  
  2.   
  3. <schema name="example" version="1.1">  
  4.   
  5.   <types>  
  6.     <fieldType name="string" class="solr.StrField" sortMissingLast="true" omitNorms="true"/>  
  7.     <fieldType name="sint" class="solr.SortableIntField" sortMissingLast="true" omitNorms="true"/>  
  8.   
  9.     <!-- The format for this date field is of the form 1995-12-31T23:59:59Z, and   
  10.          is a more restricted form of the canonical representation of dateTime   
  11.          http://www.w3.org/TR/xmlschema-2/#dateTime   
  12.          The trailing "Z" designates UTC time and is mandatory.   
  13.          Optional fractional seconds are allowed: 1995-12-31T23:59:59.999Z   
  14.          All other components are mandatory.   
  15.   
  16.          Expressions can also be used to denote calculations that should be   
  17.          performed relative to "NOW" to determine the value, ie...   
  18.   
  19.                NOW/HOUR   
  20.                   ... Round to the start of the current hour   
  21.                NOW-1DAY   
  22.                   ... Exactly 1 day prior to now   
  23.                NOW/DAY+6MONTHS+3DAYS   
  24.                   ... 6 months and 3 days in the future from the start of   
  25.                       the current day   
  26.   
  27.          Consult the DateField javadocs for more information.   
  28.       -->  
  29.     <fieldType name="date" class="solr.DateField" sortMissingLast="true" omitNorms="true"/>  
  30.   
  31.     <fieldType name="text" class="solr.TextField" positionIncrementGap="100">  
  32.       <analyzer>  
  33.         <tokenizer class="solr.CJKTokenizerFactory"/>  
  34.       </analyzer>  
  35.     </fieldType>  
  36.   
  37.  </types>  
  38.   
  39.  <fields>  
  40.    <field name="id" type="sint" indexed="true" stored="true" required="true" />  
  41.    <field name="user" type="string" indexed="true" stored="true"/>  
  42.    <field name="title" type="text" indexed="true" stored="true"/>  
  43.    <field name="content" type="text" indexed="true" stored="true" />  
  44.    <field name="timestamp" type="date" indexed="true" stored="true" default="NOW"/>  
  45.   
  46.    <!-- catchall field, containing all other searchable text fields (implemented   
  47.         via copyField further on in this schema  -->  
  48.    <field name="text" type="text" indexed="true" stored="false" multiValued="true"/>  
  49.  </fields>  
  50.   
  51.  <!-- Field to use to determine and enforce document uniqueness.   
  52.       Unless this field is marked with required="false", it will be a required field   
  53.    -->  
  54.  <uniqueKey>id</uniqueKey>  
  55.   
  56.  <!-- field for the QueryParser to use when an explicit fieldname is absent -->  
  57.  <defaultSearchField>text</defaultSearchField>  
  58.   
  59.  <!-- SolrQueryParser configuration: defaultOperator="AND|OR" -->  
  60.  <solrQueryParser defaultOperator="AND"/>  
  61.   
  62.   <!-- copyField commands copy one field to another at the time a document   
  63.         is added to the index.  It's used either to index the same field differently,   
  64.         or to add multiple fields to the same field for easier/faster searching.  -->  
  65. <!-- -->  
  66.    <copyField source="title" dest="text"/>  
  67.    <copyField source="content" dest="text"/>  
  68.   
  69. </schema>  

7、重启 tomcat,然后手动在 E:\apache-solr-1.3.0\example\exampledocs 创建两个 xml 数据文件。分别保存为 demo-doc1.xml 和 demo-doc2.xml:

  1. <?xml version="1.0" encoding="UTF-8" ?>  
  2. <add>  
  3.     <doc>  
  4.         <field name="id">1</field>  
  5.         <field name="user">chenlb</field>  
  6.         <field name="title">solr 应用演讲</field>  
  7.         <field name="content">这一小节是讲提交数据给服务器做索引,这里有一些数据,如:服务器,可以试查找它。</field>  
  8.     </doc>  
  9. </add>  
<?xml version="1.0" encoding="UTF-8" ?>  
  1. <add>  
  2.     <doc>  
  3.         <field name="id">2</field>  
  4.         <field name="user">bory.chan</field>  
  5.         <field name="title">搜索引擎</field>  
  6.         <field name="content">搜索服务器那边有很多数据。</field>  
  7.         <field name="timestamp">2009-02-18T00:00:00Z</field>  
  8.     </doc>  
  9.     <doc>  
  10.         <field name="id">3</field>  
  11.         <field name="user">other</field>  
  12.         <field name="title">这是什么</field>  
  13.         <field name="content">你喜欢什么运动?篮球?</field>  
  14.         <field name="timestamp">2009-02-18T12:33:05.123Z</field>  
  15.     </doc>  
  16. </add>  
8、提交数据做索引,到 E:\apache-solr-1.3.0\example\exampledocs,运行:
E:\apache-solr-1.3.0\example\exampledocs>java -Durl=http://localhost:8080/solr/update -Dcommit=yes -jar post.jar demo-doc*.xml
SimplePostTool: version 1.2
SimplePostTool: WARNING: Make sure your XML documents are encoded in UTF-8, other encodings are not currently supported
SimplePostTool: POSTing files to http://localhost:8080/solr/update..
SimplePostTool: POSTing file demo-doc1.xml
SimplePostTool: POSTing file demo-doc2.xml
SimplePostTool: COMMITting Solr index changes..

9、查看搜索结果:

所有内容 http://localhost:8080/solr/select/?q=*%3A*&version=2.2&start=0&rows=10&indent=on

  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <response>  
  3.   
  4. <lst name="responseHeader">  
  5.  <int name="status">0</int>  
  6.  <int name="QTime">0</int>  
  7.  <lst name="params">  
  8.   <str name="indent">on</str>  
  9.   <str name="start">0</str>  
  10.   <str name="q">*:*</str>  
  11.   <str name="rows">10</str>  
  12.   <str name="version">2.2</str>  
  13.  </lst>  
  14. </lst>  
  15. <result name="response" numFound="3" start="0">  
  16.  <doc>  
  17.   <str name="content">这一小节是讲提交数据给服务器做索引,这里有一些数据,如:服务器,可以试查找它。</str>  
  18.   <int name="id">1</int>  
  19.   <date name="timestamp">2009-05-27T04:07:54.89Z</date>  
  20.   <str name="title">solr 应用演讲</str>  
  21.   <str name="user">chenlb</str>  
  22.  </doc>  
  23.  <doc>  
  24.   <str name="content">搜索服务器那边有很多数据。</str>  
  25.   <int name="id">2</int>  
  26.   <date name="timestamp">2009-02-18T00:00:00Z</date>  
  27.   <str name="title">搜索引擎</str>  
  28.   <str name="user">bory.chan</str>  
  29.  </doc>  
  30.  <doc>  
  31.   <str name="content">你喜欢什么运动?篮球?</str>  
  32.   <int name="id">3</int>  
  33.   <date name="timestamp">2009-02-18T12:33:05.123Z</date>  
  34.   <str name="title">这是什么</str>  
  35.   <str name="user">other</str>  
  36.  </doc>  
  37. </result>  
  38. </response>  

bory.chan 用户的:http://localhost:8080/solr/select/?q=user%3Abory.chan&version=2.2&start=0&rows=10&indent=on

  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <response>  
  3.   
  4. <lst name="responseHeader">  
  5.  <int name="status">0</int>  
  6.  <int name="QTime">0</int>  
  7.  <lst name="params">  
  8.   <str name="indent">on</str>  
  9.   <str name="start">0</str>  
  10.   <str name="q">user:bory.chan</str>  
  11.   <str name="rows">10</str>  
  12.   <str name="version">2.2</str>  
  13.  </lst>  
  14. </lst>  
  15. <result name="response" numFound="1" start="0">  
  16.  <doc>  
  17.   <str name="content">搜索服务器那边有很多数据。</str>  
  18.   <int name="id">2</int>  
  19.   <date name="timestamp">2009-02-18T00:00:00Z</date>  
  20.   <str name="title">搜索引擎</str>  
  21.   <str name="user">bory.chan</str>  
  22.  </doc>  
  23. </result>  
  24. </response>  

时间 http://localhost:8080/solr/select/?q=timestamp%3A%5B%222009-02-18T00%3A00%3A00Z%22+TO+%222009-02-19T00%3A00%3A00Z%22%5D&version=2.2&start=0&rows=10&indent=on

  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <response>  
  3.   
  4. <lst name="responseHeader">  
  5.  <int name="status">0</int>  
  6.  <int name="QTime">16</int>  
  7.  <lst name="params">  
  8.   <str name="indent">on</str>  
  9.   <str name="start">0</str>  
  10.   <str name="q">timestamp:["2009-02-18T00:00:00Z" TO "2009-02-19T00:00:00Z"]</str>  
  11.   <str name="rows">10</str>  
  12.   <str name="version">2.2</str>  
  13.  </lst>  
  14. </lst>  
  15. <result name="response" numFound="2" start="0">  
  16.  <doc>  
  17.   <str name="content">搜索服务器那边有很多数据。</str>  
  18.   <int name="id">2</int>  
  19.   <date name="timestamp">2009-02-18T00:00:00Z</date>  
  20.   <str name="title">搜索引擎</str>  
  21.   <str name="user">bory.chan</str>  
  22.  </doc>  
  23.  <doc>  
  24.   <str name="content">你喜欢什么运动?篮球?</str>  
  25.   <int name="id">3</int>  
  26.   <date name="timestamp">2009-02-18T12:33:05.123Z</date>  
  27.   <str name="title">这是什么</str>  
  28.   <str name="user">other</str>  
  29.  </doc>  
  30. </result>  
  31. </response>  

常用的 solr 查询参数请看:solr 查询参数说明

简单的示例已经完成了,索引文件(默认)会在 CWD/solr/data/index 目录下,要改为 solr.home/data目录下,在 F:\apache-solr-1.3.0\example\solr\conf\solrconfig.xml 把 dataDir 注释掉,如:

  1. <!--  
  2. <dataDir>${solr.data.dir:./solr/data}</dataDir>  
  3. -->  

说明:上面没有使用中文分词,用官方的 CJK 分词,另外有 mmseg4j 中文分词的示例,请看:solr 中文分词 mmseg4j 使用例子

solr 1.4 运行这个例子是有这个问题。报错:

  1. org.apache.solr.common.SolrException: QueryElevationComponent requires the schema to have a uniqueKeyField implemented using StrField。  

把 solrconfig.xml 中删除两个结点:

  1. <!-- a search component that enables you to configure the top results for   
  2.      a given query regardless of the normal lucene scoring.-->  
  3. <searchComponent name="elevator" class="solr.QueryElevationComponent" >  
  4.   <!-- pick a fieldType to analyze queries -->  
  5.   <str name="queryFieldType">string</str>  
  6.   <str name="config-file">elevate.xml</str>  
  7. </searchComponent>  
  8.   
  9. <!-- a request handler utilizing the elevator component -->  
  10. <requestHandler name="/elevate" class="solr.SearchHandler" startup="lazy">  
  11.   <lst name="defaults">  
  12.     <str name="echoParams">explicit</str>  
  13.   </lst>  
  14.   <arr name="last-components">  
  15.     <str>elevator</str>  
  16.   </arr>  
  17. </requestHandler>  

即 Elevation 组件。

 
===============================

solr 中文分词 mmseg4j 使用例子

原文出处:http://blog.chenlb.com/2009/04/solr-chinese-segment-mmseg4j-use-demo.html

mmseg4j 第一个版本就可以方便地与 solr 集成,在 google code 上面有简单的说明,第一版的发布博客也有简单的使用说明:中文分词 mmseg4j。为了更清楚说明在 solr 中使用 mmseg4j 中文分词,还是写篇博客吧。

目前有两个版本的 mmseg4j,1.7 版比较耗内存(一个词库目录就要 50M 左右),所以在默认jvm内存大小会抛出 OutOfMemoryErroy。我这里示例两个词库目录,所以不用目前最新版 1.7.2。而用 1.6.2 版。下载:mmseg4j-1.6.2词库,或就下载一个源码包(包括了词库,从源码构建请看:中文分词 mmseg4j 1.7.2 版发布),把 mmseg4j-all-1.6.2.jar 放到 solr.home/lib 。

mmseg4j 在 solr 中主要支持两个参数:mode、dicPath。mode 表示是什么模式分词(有效值:simplex、complex、max-word,如果输入了无效的默认用 max-word。)。dicPath 是词库目录可以是绝对目录,也可以是相对目录(是相对 solr.home 目录下的,dic 就会在 solr.home/dic 目录下找词库文件),如果不指定就是默认在 CWD/data 目录(程序运行当前目录的data子目录)下找。

改 solr 配置文件,主要是修改 schema.xml,我添加三个 field type,如下:

  1. <fieldType name="textComplex" class="solr.TextField" positionIncrementGap="100" >  
  2.     <analyzer>  
  3.         <tokenizer class="com.chenlb.mmseg4j.solr.MMSegTokenizerFactory" mode="complex" dicPath="dic"/>  
  4.         <filter class="solr.LowerCaseFilterFactory"/>  
  5.     </analyzer>  
  6. </fieldType>  
  7. <fieldType name="textMaxWord" class="solr.TextField" positionIncrementGap="100" >  
  8.     <analyzer>  
  9.         <tokenizer class="com.chenlb.mmseg4j.solr.MMSegTokenizerFactory" mode="max-word" dicPath="dic"/>  
  10.         <filter class="solr.LowerCaseFilterFactory"/>  
  11.     </analyzer>  
  12. </fieldType>  
  13. <fieldType name="textSimple" class="solr.TextField" positionIncrementGap="100" >  
  14.     <analyzer>  
  15.         <tokenizer class="com.chenlb.mmseg4j.solr.MMSegTokenizerFactory" mode="simple" dicPath="n:/OpenSource/apache-solr-1.3.0/example/solr/my_dic"/>  
  16.         <filter class="solr.LowerCaseFilterFactory"/>  
  17.     </analyzer>  
  18. </fieldType>  

说明:有多少不同的词库目录就会有多少个词库数组结构的实例,由上面的配置,会有两个实例。注意用 1.7.2 版会内存溢出。

定义几个字段:

  1. <field name="simple" type="textSimple" indexed="true" stored="true"/>  
  2. <field name="complex" type="textComplex" indexed="true" stored="true"/>  
  3. <field name="text" type="textMaxWord" indexed="true" stored="true"/>  
再添加个 copyField(最后面加吧):
  1. <copyField source="text" dest="simple" />  
  2. <copyField source="text" dest="complex" />  
现在 mmseg4j 在 solr 中的使用配置好了。接下来安装 solr 到 tomcat。

solr 1.3 版早就出了,我就用它为示例的 solr。下载:solr-1.3.0,如:解压放到 N:/OpenSource/apache-solr-1.3.0。在 tomcat 中怎么安装 solr 请看:Solr 使用入门介绍,以搜索论坛帖子为示例 solr install solr tomcat solr on tomcat

我是用 TOMCAT_HOME/conf/Catalina/localhost/solr.xml 的安装方式,指到 n:/OpenSource/apache-solr-1.3.0/example/solr。tomcat 6 可能没有这个目录,手动创建这目录。

启动 tomcat 可以看到 mmseg4j 的相关日志,然后在 http://localhost:8080/solr/admin/analysis.jsp 可以看 mmseg4j 的分词效果。在 Field 的下拉菜单选择 name,然后在应用输入 complex。分词的结果,如下图:

mmseg4j solr analysis 调试,点击放大

mmseg4j solr analysis 调试,点击放大

好了,可以运行起来了,那就添加个文档试下,在 n:/OpenSource/apache-solr-1.3.0/example/exampledocs 下创建 mmseg4j-solr-demo-doc.xml 文档:

  1. <add>  
  2.     <doc>  
  3.         <field name="id">1</field>  
  4.         <field name="text">京华时报2009年1月23日报道 昨天,受一股来自中西伯利亚的强冷空气影响,本市出现大风降温天气,白天最高气温只有零下7摄氏度,同时伴有6到7级的偏北风。</field>  
  5.     </doc>  
  6.     <doc>  
  7.         <field name="id">2</field>  
  8.         <field name="text">昨日金正日抵达长春市,进行两天的长春市内电话系统考察。</field>  
  9.     </doc>  
  10.     <doc>  
  11.         <field name="id">3</field>  
  12.         <field name="text">陈教授正在研究生命起源,他的研究生正在打球。</field>  
  13.     </doc>  
  14.     <doc>  
  15.         <field name="id">4</field>  
  16.         <field name="text">中国人民银行是中华人民共和国的中央银行。</field>  
  17.     </doc>  
  18. </add>  

然后提交到 solr,在 cmd 下运行 post.jar,如下:

N:\OpenSource\apache-solr-1.3.0\example\exampledocs>java -Durl=http://localhost:8080/solr/update -Dcommit=yes -jar post.jar mmseg4j-solr-demo-doc.xml
SimplePostTool: version 1.2
SimplePostTool: WARNING: Make sure your XML documents are encoded in UTF-8, other encodings are not currently supported
SimplePostTool: POSTing files to http://localhost:8080/solr/update..
SimplePostTool: POSTing file mmseg4j-solr-demo-doc.xml
SimplePostTool: COMMITting Solr index changes..

注意:mmseg4j-solr-demo-doc.xml 要是 UTF-8 格式,不然提交后会乱码。

看下是否有数据:http://localhost:8080/solr/select/?q=*:*,有数据,应该正常。

然后,找“西伯利亚”.

simple:http://localhost:8080/solr/select?indent=on&q=simple:%E8%A5%BF%E4%BC%AF%E5%88%A9%E4%BA%9A&hl=on&hl.fl=simple%2Ccomplex%2Ctext&fl=id,结果如下:

  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <response>  
  3.   
  4. <lst name="responseHeader">  
  5.  <int name="status">0</int>  
  6.  <int name="QTime">0</int>  
  7.  <lst name="params">  
  8.   <str name="fl">id</str>  
  9.   <str name="indent">on</str>  
  10.   <str name="q">simple:西伯利亚</str>  
  11.   <str name="hl.fl">simple,complex,text</str>  
  12.   <str name="hl">on</str>  
  13.  </lst>  
  14. </lst>  
  15. <result name="response" numFound="0" start="0"/>  
  16. <lst name="highlighting"/>  
  17. </response>  

comlex:http://localhost:8080/solr/select?indent=on&q=complex:%E8%A5%BF%E4%BC%AF%E5%88%A9%E4%BA%9A&hl=on&hl.fl=simple%2Ccomplex%2Ctext&fl=id,结果如:

  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <response>  
  3.   
  4. <lst name="responseHeader">  
  5.  <int name="status">0</int>  
  6.  <int name="QTime">0</int>  
  7.  <lst name="params">  
  8.   <str name="fl">id</str>  
  9.   <str name="indent">on</str>  
  10.   <str name="q">complex:西伯利亚</str>  
  11.   <str name="hl.fl">simple,complex,text</str>  
  12.   <str name="hl">on</str>  
  13.  </lst>  
  14. </lst>  
  15. <result name="response" numFound="1" start="0">  
  16.  <doc>  
  17.   <str name="id">1</str>  
  18.  </doc>  
  19. </result>  
  20. <lst name="highlighting">  
  21.  <lst name="1">  
  22.   <arr name="complex">  
  23.     <str>京华时报2009年1月23日报道 昨天,受一股来自中<em>西伯利亚</em>的强冷空气影响,本市出现大风降温天气,白天最高气温只有零下7摄氏度,同时伴有6到7级的偏北风。</str>  
  24.   </arr>  
  25.  </lst>  
  26. </lst>  
  27. </response>  

text(其实是 max-word):http://localhost:8080/solr/select?indent=on&q=text:%E8%A5%BF%E4%BC%AF%E5%88%A9%E4%BA%9A&hl=on&hl.fl=simple%2Ccomplex%2Ctext&fl=id,结果:

  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <response>  
  3.   
  4. <lst name="responseHeader">  
  5.  <int name="status">0</int>  
  6.  <int name="QTime">15</int>  
  7.  <lst name="params">  
  8.   <str name="fl">id</str>  
  9.   <str name="indent">on</str>  
  10.   <str name="q">text:西伯利亚</str>  
  11.   <str name="hl.fl">simple,complex,text</str>  
  12.   <str name="hl">on</str>  
  13.  </lst>  
  14. </lst>  
  15. <result name="response" numFound="1" start="0">  
  16.  <doc>  
  17.   <str name="id">1</str>  
  18.  </doc>  
  19. </result>  
  20. <lst name="highlighting">  
  21.  <lst name="1">  
  22.   <arr name="text">  
  23.     <str>京华时报2009年1月23日报道 昨天,受一股来自中<em>西</em><em>伯利亚</em>的强冷空气影响,本市出现大风降温天气,白天最高气温只有零下7摄氏度,同时伴有6到7级的偏北风。</str>  
  24.   </arr>  
  25.  </lst>  
  26. </lst>  
  27. </response>  

 

1 概述 4 1.1 企业搜索引擎方案选型 4 1.2 Solr的特性 4 1.2.1 Solr使用Lucene并且进行了扩展 4 1.2.2 Schema(模式) 5 1.2.3 查询 5 1.2.4 核心 5 1.2.5 缓存 5 1.2.6 复制 6 1.2.7 管理接口 6 1.3 Solr服务原理 6 1.3.1 索引 6 1.3.2 搜索 7 1.4 源码结构 8 1.4.1 目录结构说明 8 1.4.2 Solr home说明 9 1.4.3 solr的各包的说明 10 1.5 版本说明 11 1.5.1 1.3版本 11 1.5.2 1.4版本 12 1.6 分布式和复制 Solr 架构 13 2 Solr的安装与配置 13 2.1 在TomcatSolr安装 13 2.1.1 安装准备 13 2.1.2 安装过程 14 2.1.3 验证安装 15 2.2 中文分词配置 15 2.2.1 mmseg4j 15 2.2.2 paoding 19 2.3 多核(MultiCore)配置 22 2.3.1 MultiCore的配置方法 22 2.3.2 为何使用多core ? 23 2.4 配置文件说明 23 2.4.1 schema.xml 24 2.4.2 solrconfig.xml 25 3 Solr的应用 29 3.1 SOLR应用概述 29 3.1.1 Solr的应用模式 29 3.1.2 SOLR使用过程说明 30 3.2 一个简单的例子 30 3.2.1 Solr Schema 设计 30 3.2.2 构建索引 30 3.2.3 搜索测试 31 3.3 搜索引擎的规划设计 32 3.3.1 定义业务模型 32 3.3.2 定制索引服务 34 3.3.3 定制搜索服务 34 3.4 搜索引擎配置 34 3.4.1 Solr Schema 设计(如何定制索引的结构?) 34 3.5 如何进行索引操作? 36 3.5.1 基本索引操作 36 3.5.2 批量索引操作 37 3.6 如何进行搜索 39 3.6.1 搜索语法 39 3.6.2 排序 42 3.6.3 字段增加权重 42 3.6.4 Solr分词器、过滤器、分析器 42 3.6.5 Solr高亮使用 46 4 SolrJ的用法 46 4.1 搜索接口的调用实例 46 4.2 Solrj的使用说明 47 4.2.1 Adding Data to Solr 47 4.2.2 Directly adding POJOs to Solr 49 4.2.3 Reading Data from Solr 51 4.3 创建查询 51 4.4 使用 SolrJ 创建索引 52 4.5 Solrj包的结构说明 53 4.5.1 CommonsHttpSolrServer 53 4.5.2 Setting XMLResponseParser 53 4.5.3 Changing other Connection Settings 53 4.5.4 EmbeddedSolrServer 54 5 Solr的实际应用测试报告 54 5.1 线下压力测试报告 54 5.2 线上环境运行报告 54 6 solr性能调优 55 6.1 Schema Design Considerations 55 6.1.1 indexed fields 55 6.1.2 stored fields 55 6.2 Configuration Considerations 55 6.2.1 mergeFactor 55 6.2.2 mergeFactor Tradeoffs 56 6.3 Cache autoWarm Count Considerations 56 6.4 Cache hit rate(缓存命中率) 56 6.5 Explicit Warming of Sort Fields 56 6.6 Optimization Considerations 56 6.7 Updates and Commit Frequency Tradeoffs 56 6.8 Query Response Compression 57 6.9 Embedded vs HTTP Post 57 6.10 RAM Usage Considerations(内存方面的考虑) 57 6.10.1 OutOfMemoryErrors 57 6.10.2 Memory allocated to the Java VM 57 7 FAQ 58 7.1 出现乱码或者查不到结果的排查方法: 58
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值