Solr学习总结(三)建立第一个索引
来源:互联网 发布:ubuntu教程 百度云 编辑:程序博客网 时间:2024/05/20 23:39
进入solr-5.5.4的文件夹。复制文件夹basic_configs命名为tmp_configs. 并将managed-schema文件重命名为schema.xml
-bash-3.2$ cp -r server/solr/configsets/basic_configs server/solr/configsets/tmp_configs-bash-3.2$ mv server/solr/configsets/tmp_configs/conf/managed-schema server/solr/configsets/tmp_configs/conf/schema.xml
然后修改solrconfig.xml中的schemaFactory字段,使用ClassicIndexSchemaFactory。这个配置让solr使用schema.xml配置,并允许手动修改,屏蔽了使用API修改schema的权限。
vi server/solr/configsets/tmp_configs/conf/solrconfig.xml
<!-- To disable dynamic schema REST APIs, use the following for <schemaFactory>: <schemaFactory class="ClassicIndexSchemaFactory"/> When ManagedIndexSchemaFactory is specified instead, Solr will load the schema from the resource named in 'managedSchemaResourceName', rather than from schema.xml. Note that the managed schema resource CANNOT be named schema.xml. If the managed schema does not exist, Solr will create it after reading schema.xml, then rename 'schema.xml' to 'schema.xml.bak'. Do NOT hand edit the managed schema - external modifications will be ignored and overwritten as a result of schema modification REST API calls. When ManagedIndexSchemaFactory is specified with mutable = true, schema modification REST API calls will be allowed; otherwise, error responses will be sent back for these requests. --> <!-- <schemaFactory class="ManagedIndexSchemaFactory"> <bool name="mutable">true</bool> <str name="managedSchemaResourceName">managed-schema</str> </schemaFactory> --> <schemaFactory class="ClassicIndexSchemaFactory"/>
然后修改schema.xml文件,添加一个搜索域text。
vi server/solr/configsets/tmp_configs/conf/schema.xml
重命名schema(非必要)
<schema name="tmp" version="1.5">
添加text域
<field name="id" type="string" indexed="true" stored="true" required="true" multiValued="false" /> <field name="text" type="text_general" indexed="true" stored="true" required="false" multiValued="false" />
文档中原来只存在id域。id是被配置为唯一键的,索引中每个文档都应有一个唯一id。所以id的配置中,required=true。
添加的text域,type配置成text_general。这个类在schema下面有配置,是用的一元分词。indexed=true表示这个域的内容会建立索引。stored=true表示内容会被储存。required=false表示不是必须存在的域。multiValued=false表示不是多值域。
<!-- A general text field that has reasonable, generic cross-language defaults: it tokenizes with StandardTokenizer, removes stop words from case-insensitive "stopwords.txt" (empty by default), and down cases. At query time only, it also applies synonyms. --> <fieldType name="text_general" class="solr.TextField" positionIncrementGap="100"> <analyzer type="index"> <tokenizer class="solr.StandardTokenizerFactory"/> <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" /> <!-- in this example, we will only use synonyms at query time <filter class="solr.SynonymFilterFactory" synonyms="index_synonyms.txt" ignoreCase="true" expand="false"/> --> <filter class="solr.LowerCaseFilterFactory"/> </analyzer> <analyzer type="query"> <tokenizer class="solr.StandardTokenizerFactory"/> <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" /> <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/> <filter class="solr.LowerCaseFilterFactory"/> </analyzer> </fieldType>
结束配置后,使用脚本命令创建索引tmp_index:
./bin/solr create -c tmp_index -d tmp_configs -n tmp_configs -p 8983
create 表示建立索引。
<-c 索引名>
<-d 配置目录>
<-n 配置名>
<-P 端口>
运行结束后得到类似下面这段显示success的json就表示建立索引成功:
{ "responseHeader":{ "status":0, "QTime":3699}, "success":{"192.168.0.123:8983_solr":{ "responseHeader":{ "status":0, "QTime":861}, "core":"tmp_index"}}}
现在去浏览器打开:http://your_server:8983/solr/#/tmp_index 可以看到建立的索引。
0 0
- Solr学习总结(三)建立第一个索引
- Solr学习三与mysql集成建立索引
- Solr学习总结(三)solr查询
- Solr学习总结(三)Solr web 管理后台
- 2.myql数据导入到solr,并建立solr索引(学习笔记)
- Solr索引建立
- solr之建立索引
- solr建立索引
- 1、安装solr并建立第一个core
- Solr学习总结-命令行添加索引
- OpenGL学习(三)第一个三角形
- javaweb学习(2)--建立第一个webapp
- 格式在javaweb学习(3)--建立第一个servlet
- STM8学习笔记(一) 建立第一个工程
- solr对数据库建立索引
- Solr对数据库建立索引
- solr和mysql建立索引
- Solr对数据库建立索引
- 为什么我们有必要重新思考和定义“运营”?
- VR真如此吃香?未来五年市场都将保持上升趋势
- Linux yum安装MySQL5.7
- java多线程同步机制的实现方式总结
- Linux常用命令——帮助命令
- Solr学习总结(三)建立第一个索引
- Operators in MXNet-Dropout
- andorid apk 反编译
- 线段树的极值查找
- curl之get请求
- 高并发Java 二 多线程基
- 杭电acm 1230 火星A+B
- 最全面的AndroidStudio配置指南总结-包括护眼模式
- 我的页面