solr

Solr实现类似MySQL的LIKE查询功能

本小妞迷上赌 提交于 2020-03-17 09:32:20
某厂面试归来,发现自己落伍了!>>> 最近在工作中遇到需要对大文本进行关键词查询。需要实现的效果为,当用户输入一个字或者一个词,要搜出包含这个字或者词的所有内容。就相当于 MySQL 的 LIKE 查询效果一样。 在这种场景下,第一时间想到的肯定是直接使用 MySQL 存储,然后进行查询就可以了,完全符合业务需求。但是经过尝试,当数据量比较大的时候,查询的速度慢得让人根本无法接受。 于是只能考虑其他方案,由于和搜索有关,于是想到了之前使用过的 Solr 。经过一系列折腾,最后得出最终方案如下。 schema 设计的时候,需要自定义字段类型,使用 solr.NGramTokenizerFactory 分词器,并且将分片参数设置成1。 <fieldType name="text_ng1" class="solr.TextField" positionIncrementGap="100"> <analyzer type="index"> <tokenizer class="solr.NGramTokenizerFactory" minGramSize="1" maxGramSize="1"/> </analyzer> <analyzer type="query"> <tokenizer class="solr.NGramTokenizerFactory" minGramSize="1"

搭建solr的简单应用服务(一)

六眼飞鱼酱① 提交于 2020-03-16 16:26:19
环境:Centos7 + jdk1.8 + solr-7.7.2 + tomcat-8.5.43 Centos7下载地址: https://www.jianshu.com/p/a63f47e096e8 jdk1.8下载地址: https://www.oracle.com/java/technologies/javase-jdk8-downloads.html solr-7.7.2下载地址: http://archive.apache.org/dist/lucene/solr/ tomcat-8.5.43下载地址: http://archive.apache.org/dist/tomcat/tomcat-8/v8.5.43/bin/ 第一部分: tomcat中配置solr服务 1. 解压solr-7.7.2进入server/webapps复制webapp文件到tomcat的webapps下并改名字为solr进行访问 2. 添加到tomcat容器内 3. 添加solr依赖的包到solr项目内的WEB-INF/lib文件下   3.1 添加server下的lib/ext下的所有包     3.2 添加server下lib文件夹下的6个依赖包 4. 在usr/local [符合项目规范的任意文件夹] 下创建solrhome文件夹作为索引库的目录 5. 复制solr-7.7

Static field for document in Data Import Handlerfor Solr

穿精又带淫゛_ 提交于 2020-03-16 07:43:26
问题 Im making an index in solr from db in the following way: <document name="Index"> <entity name="c" query="SELECT * FROM C"> <field column="Name" name="name"/> </entity> <entity name="p" query="SELECT * FROM P"> <field column="Name" name="name"/> </entity> </document> Is it possible to have a static field that is set for each row that signify what type is returned to client so that one can make a call to the right database table based on that information from the json result? That is a field

Solr does not search into integers?

廉价感情. 提交于 2020-03-15 05:46:21
问题 I'm currently developping a search engine using Solr for an ecommerce website. So I get these two fields in my schema.xml: <field name="sku" type="string" indexed="true" stored="true" required="false" /> <field name="collection" type="string" indexed="true" stored="true" required="false" /> (The complete schema.xml is available below) For information: sku looks like this: 959620, 929345, 912365, ... collection looks like this: Alcott, Spigrim, Tantal,... They are well indexed. For instance,

Solr does not search into integers?

谁都会走 提交于 2020-03-15 05:45:41
问题 I'm currently developping a search engine using Solr for an ecommerce website. So I get these two fields in my schema.xml: <field name="sku" type="string" indexed="true" stored="true" required="false" /> <field name="collection" type="string" indexed="true" stored="true" required="false" /> (The complete schema.xml is available below) For information: sku looks like this: 959620, 929345, 912365, ... collection looks like this: Alcott, Spigrim, Tantal,... They are well indexed. For instance,

Solr does not search into integers?

天涯浪子 提交于 2020-03-15 05:43:34
问题 I'm currently developping a search engine using Solr for an ecommerce website. So I get these two fields in my schema.xml: <field name="sku" type="string" indexed="true" stored="true" required="false" /> <field name="collection" type="string" indexed="true" stored="true" required="false" /> (The complete schema.xml is available below) For information: sku looks like this: 959620, 929345, 912365, ... collection looks like this: Alcott, Spigrim, Tantal,... They are well indexed. For instance,

第一章:elasticsearch介绍

强颜欢笑 提交于 2020-03-13 23:50:08
公司技术更新换代,考虑了各种因素吧,最后选了es,没有选最高版本,选了6.8,后面相关内容章节版本都是基于6.8版本来记录的,深度算是入门吧,望路过众神多批评,指正。 1.es我能用来干什么? 太多了,但是不想呼呼吹一堆牛逼,还是切合自身实际遇到的业务场景来说吧,一切脱离了实际业务场景来谈技术都是耍流氓,基本用到了三个方面分别是: 1.做了电商平台的全文检索 2.一些业务生产数据汇集到es后,做了很多聚合运算。 3.线上生产日志汇集到es后,做了相关数据分析,说白了还是个聚合运算,只是分了一下业务逻辑。 目前公司项目里面主要是用到了这三块。 2.搜了一堆es的资料,发现es底层基于lucene的,那还需要不需要去看lucene的知识体系? 网上一搜,太多了,简直了,大部分都会找出跟lucene的对比,跟solr的对比,成堆成堆的出现,,想了解对比的随便就能去看, 个人感觉lucene的一些原理知识还是很有必要去找找看看了解一下的,因为后面对于es的一些读写索引数据交换等的原理层面你才能够理解,能衔接的上,因为说到底底层还是lucene的一些东西。 3.写在前面 疫情原因,真是闲出屁了,本人中专生毕业,实在无法提升自己的语言能力,用很官方的话来写东西,只能大白话把一些费时间的问题写明白,关于es的本类文章打算坚持不定期更新完毕,主要是基于es一些应用思想理论理解层面的

ElasticSearch和solr的对比

冷暖自知 提交于 2020-03-09 06:30:32
关于ES :ElasticSearch是一个事实分布式搜索和分析引擎,使用其可以以前所未有的速度处理大数据,他用于全文搜索、结构化搜索、分析以及将这三者混合使用。维基百科使用ElasticSearch提供全文搜索并高亮关键字,以及输入实时搜索(search+asyou+type)等搜索纠错(did+you+mean)等搜索建议功能。ElasticSearch是一个基于Apache Lucene(TM)的开源搜索引擎。无论在开源还是在专有领域,Lucene可以被认为是迄今最先进、性能最好的、功能最全的搜索引擎库。 关于Solr :solr是Apache下的一个顶级开源项目,采用java开发,它是基于Lucene的全文搜索服务器。solr提供了比Lucene更为丰富的查询语言,同时实现了可配置、可扩展、并对索引、搜索性能进行了优化。solr可以独立运行,运行在Jetty、Tomcat等这些Servlet容器中,solr索引是实现方法很简单,用post方法向solr服务器发送一个描述Field及其内容的xml文档,solr根据xml文档添加、删除、更新索引。 二者之间对比: 相同点: 都是基于Lucene,都是对Lucene的封装 不同点: 使用 Solr安装略微复杂一些,es基本的开箱急用,非常简单 接口 Solr类似webservice的接口;es是基于restful风格的访问接口

基于docker容器部署Solr 8.1.1

£可爱£侵袭症+ 提交于 2020-03-08 01:14:19
Solr是一个独立的企业级搜索应用服务器,它对外提供类似于Web-service的API接口。用户可以通过http请求,向搜索引擎服务器提交一定格式的XML文件,生成索引;也可以通过Http Get操作提出查找请求,并得到XML格式的返回结果。 https://github.com/docker-solr/docker-solr (1)bin:solr的运行脚本 (2)contrib:solr的一些扩展jar包,用于增强solr的功能 (3)dist:该目录包含build过程中产生的jar文件,以及相关的依赖文件 (4)data:用于存放与zookeeper关联的配置文件zoo.cfg (5)example:solr工程的例子目录 部署Solr $ docker run -d -it --restart=always -p 8983:8983 -privileged=true --name solr solr:v8.1.1 $ docker exec -it --user=solr solr /bin/bash $ mkdir /var/solr/data/new_core $ cp -r /opt/solr-8.1.1/server/solr/configsets/sample_techproducts_configs/conf /var/solr/data/new_core/

记录docker--solr

◇◆丶佛笑我妖孽 提交于 2020-03-07 04:54:11
1.拉取镜像 docker pull solr:7.4.0 2.创建容器 docker run --name solr -p 8983:8983 -d solr:7.4.0 3.访问8983端口 4.页面创建solr核心 (此时会报错) 5.进入solr docker exec -it solr /bin/bash 6.将/opt/solr/server/solr/configsets/_default/conf文件夹拷贝到新建的核心下 cp -r /opt/solr/server/solr/configsets/_default/conf /opt/solr/server/solr/gcg/conf 7.重启solr服务 exit docker restart solr 8.刷新页面再次添加solr核心 9.添加solr索引字段(可以通过修改/opt/solr/server/solr/gcg/conf/managed-schema,也可以页面添加) 此时solr服务已搭建完成 =============================================== 启用中文分词器 1.进入solr容器 docker exec -it solr /bin/bash 2.修改/opt/solr/server/solr/gcg/conf/solrconfig.xml