【大数据开发运维解决方案】Solr5.1案例文档导入

简介: 1、创建内核[root@hadoop exampledocs]# cd /hadoop/solr/[root@hadoop solr]# ./bin/solr create -c jcg -d basic_configsSetup new core instance directory:/hadoop/solr/server/solr/jcgCreating new core 'jc...

1、创建内核

[root@hadoop exampledocs]# cd /hadoop/solr/
[root@hadoop solr]# ./bin/solr create -c jcg -d basic_configs

Setup new core instance directory:
/hadoop/solr/server/solr/jcg

Creating new core 'jcg' using command:
http://localhost:8983/solr/admin/cores?action=CREATE&name=jcg&instanceDir=jcg

{
  "responseHeader":{
    "status":0,
    "QTime":191},
  "core":"jcg"}

core创建成功之后,会在server/solr目录下生成名为jcg的文件夹,这就是我们创建的jcg core的配置,jcg目录下有两个文件夹和一个文件,如下所示。
[root@hadoop solr]# ls server/solr/
configsets core_one jcg README.txt solr.xml zoo.cfg
[root@hadoop solr]# ls server/solr/jcg/
conf core.properties data
然后在solr控制台就可以看到jcg了。
image.png
根据solr提供的示例,通过设置一个schema,然后导入books.csv(example/exampledocs文件夹下)文件,产生索引,然后重启solr,利用api查询。

[root@hadoop exampledocs]# pwd
/hadoop/solr/example/exampledocs
[root@hadoop exampledocs]# ls
books.csv            hd.xml          manufacturers.xml  monitor2.xml  post.jar     solr-word.pdf  utf8-example.xml
books.json           ipod_other.xml  mem.xml            monitor.xml   sample.html  solr.xml       vidcard.xml
gb18030-example.xml  ipod_video.xml  money.xml          mp500.xml     sd500.xml    test_utf8.sh
books.csv文件的内容:后续我们会根据这些内容进行查询
[root@hadoop exampledocs]# cat books.csv 
id,cat,name,price,inStock,author,series_t,sequence_i,genre_s
0553573403,book,A Game of Thrones,7.99,true,George R.R. Martin,"A Song of Ice and Fire",1,fantasy
0553579908,book,A Clash of Kings,7.99,true,George R.R. Martin,"A Song of Ice and Fire",2,fantasy
055357342X,book,A Storm of Swords,7.99,true,George R.R. Martin,"A Song of Ice and Fire",3,fantasy
0553293354,book,Foundation,7.99,true,Isaac Asimov,Foundation Novels,1,scifi
0812521390,book,The Black Company,6.99,false,Glen Cook,The Chronicles of The Black Company,1,fantasy
0812550706,book,Ender's Game,6.99,true,Orson Scott Card,Ender,1,scifi
0441385532,book,Jhereg,7.95,false,Steven Brust,Vlad Taltos,1,fantasy
0380014300,book,Nine Princes In Amber,6.99,true,Roger Zelazny,the Chronicles of Amber,1,fantasy
0805080481,book,The Book of Three,5.99,true,Lloyd Alexander,The Chronicles of Prydain,1,fantasy
080508049X,book,The Black Cauldron,5.99,true,Lloyd Alexander,The Chronicles of Prydain,2,fantasy
[root@hadoop exampledocs]# 

1、修改server/solr/jcg/conf/manage-schema,添加如下配置

[root@hadoop exampledocs]# cd /hadoop/solr/server/solr/jcg/conf/
[root@hadoop conf]# vim schema.xml 
  <!--fields for book.csv load -->

  <field name="cat" type="text_general" indexed="true" stored="true"/>  
  
  <field name="name" type="text_general" indexed="true" stored="true"/>  
  
  <field name="price" type="tdouble" indexed="true" stored="true"/>  
  
  <field name="inStock" type="boolean" indexed="true" stored="true"/>  
  
  <field name="author" type="text_general" indexed="true" stored="true"/> 

这些配置对应books.csv文件中的一些字段field:
name:名称,随便定义,在查询的时候根据定义的名称来查询。
type:类型
indexed:是否做索引
stored:是否存储
这里我们只配置了部分字段cat,name,price,inStock,author,像series_t,sequence_i,genre_s,这些字段没有配置,这些配置在manage-schema中有默认的配置,他们就是根据字段后缀来做索引,这些字段就称为动态属性字段,每一个后缀对应可以有多个这样的动态属性,但是字段类型需要保持和定义时一致。部分动态属性定义如下:

<dynamicField name="*_i"  type="int"    indexed="true"  stored="true"/>
<dynamicField name="*_is" type="int"    indexed="true"  stored="true"  multiValued="true"/>
<dynamicField name="*_s"  type="string"  indexed="true"  stored="true" />

2、停止solr实例,并重新开启。

[root@hadoop conf]# cd /hadoop/solr/
[root@hadoop solr]# ./bin/solr stop
Sending stop command to Solr running on port 8983 ... waiting 5 seconds to allow Jetty process 50254 to stop gracefully.
[root@hadoop solr]# ./bin/solr start -p 8983
Waiting to see Solr listening on port 8983 [/]  
Started Solr server on port 8983 (pid=51134). Happy searching!
     

进入example/exampledocs文件夹,导入books.csv

导入books.csv文件,使用如下命令

[root@hadoop exampledocs]# java  -Dtype=text/csv -Durl=http://192.168.1.66:8983/solr/jcg/update -jar post.jar books.csv
SimplePostTool version 5.0.0
Posting files to [base] url http://192.168.1.66:8983/solr/jcg/update using content-type text/csv...
POSTing file books.csv to [base]
1 files indexed.
COMMITting Solr index changes to http://192.168.1.66:8983/solr/jcg/update...
Time spent: 0:00:00.211

这样创建索引的过程就完成了。

4、查询
image.png

相关实践学习
基于MaxCompute的热门话题分析
Apsara Clouder大数据专项技能认证配套课程:基于MaxCompute的热门话题分析
相关文章
|
运维 监控 关系型数据库
AI 时代的 MySQL 数据库运维解决方案
本文探讨了大模型与MySQL数据库运维结合所带来的变革,介绍了构建结构化运维知识库、选择合适的大模型、设计Prompt调用策略、开发MCP Server以及建立监控优化闭环等关键步骤。通过将自然语言处理能力与数据库运维相结合,实现了故障智能诊断、SQL自动优化等功能,显著提升了MySQL运维效率和准确性。
1017 18
|
人工智能 OLAP 数据处理
解锁数仓内AI流水线,AnalyticDB Ray基于多模ETL+ML提效开发与运维
AnalyticDB Ray 是AnalyticDB MySQL 推出的全托管Ray服务,基于开源 Ray 的丰富生态,经过多模态处理、具身智能、搜索推荐、金融风控等场景的锤炼,对Ray内核和服务能力进行了全栈增强。
|
12月前
|
SQL 运维 自然语言处理
Dataphin智能化重磅升级!编码难题一扫光,开发运维更高效!
Dataphin重磅推出三大核心智能化能力:智能代码助手提升SQL开发效率;智能运维助手实现移动化任务管理;智能分析通过自然语言生成SQL,助力数据价值释放。未来将持续开放智能ETL、安全助手等能力,助力企业构建高效、稳定的数据资产体系。
792 0
|
人工智能 运维 安全
AI大模型运维开发探索第四篇:智能体分阶段演进路线
本文探讨了智能体工程的演进历程,从最初的思维链(智能体1.0)到实例化智能体(智能体2.0),再到结构化智能体(智能体3.0),最终展望了自演进智能体(智能体4.0)。文章详细分析了各阶段遇到的问题及解决策略,如工具调用可靠性、推理能力提升等,并引入了大模型中间件的概念以优化业务平台与工具间的协调。此外,文中还提到了RunnableHub开源项目,为读者提供了实际落地的参考方案。通过不断迭代,智能体逐渐具备更强的适应性和解决问题的能力,展现了未来AI发展的潜力。
|
11月前
|
人工智能 运维 监控
智能运维与数据治理:基于 Apache Doris 的 Data Agent 解决方案
本文基于 Apache Doris 数据运维治理 Agent 展开讨论,如何让 AI 成为 Doris 数据运维工程师和数据治理专家的智能助手,并在某些场景下实现对人工操作的全面替代。这种变革不仅仅是技术层面的进步,更是数据运维治理思维方式的根本性转变:从“被动响应”到“主动预防”,从“人工判断”到“智能决策”,从“孤立处理”到“协同治理”。
1660 11
智能运维与数据治理:基于 Apache Doris 的 Data Agent 解决方案
|
运维 监控 关系型数据库
AI 时代的 MySQL 数据库运维解决方案
本方案将大模型与MySQL运维深度融合,构建智能诊断、SQL优化与知识更新的自动化系统。通过知识库建设、大模型调用策略、MCP Server开发及监控闭环设计,全面提升数据库运维效率与准确性,实现从人工经验到智能决策的跃迁。
1201 27
|
12月前
|
敏捷开发 运维 数据可视化
DevOps看板工具中的协作功能:如何打破开发、测试与运维之间的沟通壁垒
在DevOps实践中,看板工具通过可视化任务管理和自动化流程,提升开发与运维团队的协作效率。它支持敏捷开发、持续交付,助力团队高效应对需求变化,实现跨职能协作与流程优化。
|
消息中间件 运维 监控
智能运维,由你定义:SAE自定义日志与监控解决方案
通过引入 Sidecar 容器的技术,SAE 为用户提供了更强大的自定义日志与监控解决方案,帮助用户轻松实现日志采集、监控指标收集等功能。未来,SAE 将会支持 istio 多租场景,帮助用户更高效地部署和管理服务网格。
737 51
|
12月前
|
人工智能 运维 自然语言处理
首个智能体模型实测:产品、开发、运维“全包了”
2025年,AI进入“动手”时代。智谱发布新一代大模型GLM-4.5,全球排名第三、国产第一,专为智能体设计,融合推理、编码与智能体能力,实现自主规划与执行任务。通过8个Demo展示其强大能力,涵盖网页设计、课件制作、小游戏开发等,展现其“带手的脑”特性,推动AI从实验室走向真实场景。
566 0
|
存储 人工智能 运维
idc机房智能运维解决方案
华汇数据中心一体化智能运维方案应运而生,以“自主可控、精准洞察、智能决策”三大核心能力,助力企业实现运维效率提升与综合成本下降的数字化转型目标。
974 24

热门文章

最新文章