设为首页 收藏本站
查看: 1161|回复: 0

[经验分享] [搜索] Solr (二) 配置文件

[复制链接]
累计签到:10 天
连续签到:1 天
发表于 2015-11-12 09:18:45 | 显示全部楼层 |阅读模式
Solr配置文件
  Solr包含两个主要配置:solr的主目录solr\collection1\conf下面的schema.xml,solrConfig.xml


  • solrconfig.xml:主要定义solr的处理程序(handler)和一些扩展程序;
  • schema.xml:主要定义索引的字段和字段类型。

schema.xml


  • field 字段节点  <field name=&quot;id&quot;        type=&quot;string&quot;   indexed=&quot;true&quot;  stored=&quot;true&quot;  multiValued=&quot;false&quot; required=&quot;true&quot;/>
    <field name=&quot;type&quot;      type=&quot;string&quot;   indexed=&quot;true&quot;  stored=&quot;true&quot;  multiValued=&quot;false&quot; />
    <field name=&quot;name&quot;      type=&quot;string&quot;   indexed=&quot;true&quot;  stored=&quot;true&quot;  multiValued=&quot;false&quot; />
    <field name=&quot;core0&quot;     type=&quot;string&quot;   indexed=&quot;true&quot;  stored=&quot;true&quot;  multiValued=&quot;false&quot; />
    <field name=&quot;_version_&quot; type=&quot;long&quot;     indexed=&quot;true&quot;  stored=&quot;true&quot;/> <!-- _version_ field是必需的,不能注掉 -->

    • type:字段类型,对应fieldType节点,在此结点中可以配置对应字段类型的相应分词器
    • indexed :是否进行索引
    • stored:是否进行保存,如不保存,可以进行索引但不能显示此字段的内容
    • multiValues:是否允许多&#20540;
    • required:是否是必须字段,如是,则该字段必须有&#20540;,否则索引报错


  • dynamicField 动态字段节点  <dynamicField name=&quot;*_i&quot;  type=&quot;int&quot;    indexed=&quot;true&quot;  stored=&quot;true&quot;/>
    <dynamicField name=&quot;*_is&quot; type=&quot;int&quot;    indexed=&quot;true&quot;  stored=&quot;true&quot;  multiValued=&quot;true&quot;/>
    <dynamicField name=&quot;*_s&quot;  type=&quot;string&quot;  indexed=&quot;true&quot;  stored=&quot;true&quot; />
    <dynamicField name=&quot;*_ss&quot; type=&quot;string&quot;  indexed=&quot;true&quot;  stored=&quot;true&quot; multiValued=&quot;true&quot;/>
    <dynamicField name=&quot;*_l&quot;  type=&quot;long&quot;   indexed=&quot;true&quot;  stored=&quot;true&quot;/>
    <dynamicField name=&quot;*_ls&quot; type=&quot;long&quot;   indexed=&quot;true&quot;  stored=&quot;true&quot;  multiValued=&quot;true&quot;/>
    <dynamicField name=&quot;*_t&quot;  type=&quot;text_general&quot;    indexed=&quot;true&quot;  stored=&quot;true&quot;/>动态字段表示:如果字段的定义没有在配置中找到,例如menu_s字段,field节点中没有配置,就可以在dynamicField中匹配name=&quot;*_s&quot;,表示该字段为string类型
  • copyField 复制字段节点  <copyField source=&quot;title&quot; dest=&quot;text&quot;/>
    <copyField source=&quot;author&quot; dest=&quot;text&quot;/>
    <copyField source=&quot;manu&quot; dest=&quot;manu_exact&quot;/>
    <copyField source=&quot;price&quot; dest=&quot;price_c&quot;/>复制源字段到目标字段。通过复制字段的配置,就可以把这些字段放到一起,这样搜索的时候不用写很复杂的查询组合就可以在所有的字段中搜索
  • fieldType 字段类型节点<fieldType name=&quot;string&quot; class=&quot;solr.StrField&quot; sortMissingLast=&quot;true&quot; />
    <fieldType name=&quot;text_general&quot; class=&quot;solr.TextField&quot; positionIncrementGap=&quot;100&quot;>
    <analyzer type=&quot;index&quot;>
    <tokenizer class=&quot;solr.StandardTokenizerFactory&quot;/>
    <filter class=&quot;solr.StopFilterFactory&quot; ignoreCase=&quot;true&quot; words=&quot;stopwords.txt&quot; />
    <!-- in this example, we will only use synonyms at query time
    <filter class=&quot;solr.SynonymFilterFactory&quot; synonyms=&quot;index_synonyms.txt&quot; ignoreCase=&quot;true&quot; expand=&quot;false&quot;/>
    -->
    <filter class=&quot;solr.LowerCaseFilterFactory&quot;/>
    </analyzer>
    <analyzer type=&quot;query&quot;>
    <tokenizer class=&quot;solr.StandardTokenizerFactory&quot;/>
    <filter class=&quot;solr.StopFilterFactory&quot; ignoreCase=&quot;true&quot; words=&quot;stopwords.txt&quot; />
    <filter class=&quot;solr.SynonymFilterFactory&quot; synonyms=&quot;synonyms.txt&quot; ignoreCase=&quot;true&quot; expand=&quot;true&quot;/>
    <filter class=&quot;solr.LowerCaseFilterFactory&quot;/>
    </analyzer>
    </fieldType>添加处理对应字段类型的方法,包括相应分词器等

  • 其他节点<uniqueKey>id</uniqueKey><!-- 唯一标示,如建索引时遇到重复,则覆盖 -->

           -------------------------------------------------------------------------------------

solrconfig.xml

solrconfig.xml中配置很多,大部分可以保持默认



  • dataDir 索引数据data路径<dataDir>${solr.data.dir:}</dataDir>默认不指定,默认房子每个code下data目录中

  • autoCommit 自动提交<autoCommit>
    <maxTime>${solr.autoCommit.maxTime:15000}</maxTime>
    <openSearcher>false</openSearcher> <!-- 默认关闭-->
    </autoCommit>

  • autoSoftCommit 软提交(近实时搜索)<!-- softAutoCommit is like autoCommit except it causes a
    'soft' commit which only ensures that changes are visible
    but does not ensure that data is synced to disk.  This is
    faster and more near-realtime friendly than a hard commit.
    -->
    <autoSoftCommit>
    <maxTime>${solr.autoSoftCommit.maxTime:-1}</maxTime>
    </autoSoftCommit>Solr创建索引数据时要在提交(Commit)时写入磁盘,这是硬提交,确保即便是停电也不会丢失数据,如果想进行实时的查询操作需要每次进行commit操作,但是这种方式是比较消耗资源的。为了提供更实时的检索能力,同时又能保证性能,Solr设定了一种软提交方式。软提交(soft
    commit):仅把数据提交到内存,index可见,此时没有
    写入到磁盘索引文件中。通常的用法是:每1-10分钟自动触发硬提交,每秒钟自动触发软提交

  • other



    Solr (三) 全量索引与增量索引

版权声明:本文为博主原创文章,未经博主允许不得转载。

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-138176-1-1.html 上篇帖子: Solr配置文件说明 下篇帖子: Solr之关系型数据库导入数据
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表