CN106021625A - 基于solr搜索引擎的两种分词器的混合应用方法 - Google Patents

基于solr搜索引擎的两种分词器的混合应用方法 Download PDF

Info

Publication number
CN106021625A
CN106021625A CN201610590042.4A CN201610590042A CN106021625A CN 106021625 A CN106021625 A CN 106021625A CN 201610590042 A CN201610590042 A CN 201610590042A CN 106021625 A CN106021625 A CN 106021625A
Authority
CN
China
Prior art keywords
solr
analyzer
class
segmenter
mmseg4j
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201610590042.4A
Other languages
English (en)
Inventor
孔彪
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Inspur Software Group Co Ltd
Original Assignee
Inspur Software Group Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Inspur Software Group Co Ltd filed Critical Inspur Software Group Co Ltd
Priority to CN201610590042.4A priority Critical patent/CN106021625A/zh
Publication of CN106021625A publication Critical patent/CN106021625A/zh
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/33Querying
    • G06F16/3331Query processing
    • G06F16/334Query execution
    • G06F16/3344Query execution using natural language analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/951Indexing; Web crawling techniques

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Artificial Intelligence (AREA)
  • Computational Linguistics (AREA)
  • Stored Programmes (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

本发明公开了一种基于SOLR搜索引擎的两种分词器的混合应用方法,该方法是在应用搜索引擎搜索时,利用solr中可以集成多种分词插件的特性,在建立索引时利用IK Analyzer分词的细密粒度分词方式,同时在搜索索引时又利用mmseg4j的分词方式进行搜索。本发明的基于SOLR搜索引擎的两种分词器的混合应用方法和现有技术相比,可以解决solr分词方式对于中文分词的不足,弥补了因分词方式单一,造成的搜索引擎搜索不够精确,涵盖范围不够广的问题;使得搜索引擎的可用性得到了极大的提升。

Description

基于SOLR搜索引擎的两种分词器的混合应用方法
技术领域
本发明涉及搜索引擎技术领域,具体地说是一种基于SOLR搜索引擎的两种分词器的混合应用方法。
背景技术
Apache Solr它是一种开放源码的、基于 Lucene Java 的搜索服务器,易于加入到 Web 应用程序中。Solr 提供了层面搜索、命中醒目显示并且支持多种输出格式(包括XML/XSLT 和 JSON 格式)。它易于安装和配置,而且附带了一个基于 HTTP 的管理界面。您可以坚持使用 Solr 的表现优异的基本搜索功能,也可以对它进行扩展从而满足企业的需要。
对于搜索引擎来说,分词技术的重要程度是显而易见的,它关系搜索引擎最重要的部分,搜索精确的问题。Solr自带的分词器不能满足对中文的准确分词,因此需要引入外部中文分词技术。
中文分词到底对搜索引擎有多大影响?对于搜索引擎来说,最重要的并不是找到所有结果,因为在上百亿的网页中找到所有结果没有太多的意义,没有人能看得完,最重要的是把最相关的结果排在最前面,这也称为相关度排序。中文分词的准确与否,常常直接影响到对搜索结果的相关度排序。也就影响到了产品是否能够被用户所认可的关键。
随着互联网的发展,现在正在逐步向人们学习,工作,休闲等各个空间延伸,因此互联网上信息迎来了***式的增长,信息多元化使人们分辨搜索起来困难无比,如何快速的让人们在多种多样的信息中找到自己想要的内容,搜索引擎通过整合大量的网络信息并提供极快的查询速度,其中所用的垂直搜所引擎模式解决了信息量大,查询不准确,深度不够等问题。
发明内容
本发明的技术任务是提供一种基于SOLR搜索引擎的两种分词器的混合应用方法。
本发明的技术任务是按以下方式实现的,该方法是在应用搜索引擎搜索时,利用solr中可以集成多种分词插件的特性,在建立索引时利用IK Analyzer分词的细密粒度分词方式,同时在搜索索引时又利用mmseg4j的分词方式进行搜索。
该方法步骤如下:
步骤1、首先在solr中配置IK Analyzer分词器;
步骤2、其次在solr中配置mmseg4j分词器;
步骤3、最后指定对应的分词方式。
所述的步骤1、首先在solr中配置IK Analyzer分词器;
1)在配置文件schema.xml(位置{SOLR_HOME}/config/下),配置信息如下:
<fieldType name="text_ikMM" class="solr.TextField">
<!—建立索引时调用Ik分词 -->
<analyzer type="index" isMaxWordLength="false" class="org.wltea.analyzer.lucene.IKAnalyzer"/>
<!—查询时用mmseg分词器 -->
<analyzer type="query">
<tokenizer class="com.chenlb.mmseg4j.solr.MMSegTokenizerFactory"
mode="complex" dicPath="/hadoop/kbscloud/hhh/solr/credit/conf" />
<!—添加停用词 -->
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" />
<!-- 不区分大小写 -->
<filter class="solr.LowerCaseFilterFactory" />
</analyzer>
</fieldType>
2)IKAnalyzer.cfg.xml配置文件
把stopword.dic和IKAnalyzer.cfg.xml复制到class根目录就可以启用停用词功能和扩展自己的词典
<?xmlversion="1.0"encoding="UTF-8"?>
<!DOCTYPEpropertiesSYSTEM"http://java.sun.com/dtd/properties.dtd">
<properties>
<comment>IK Analyzer 扩展配置</comment>
<!--用户可以在这里配置自己的扩展字典 -->
<entrykey="ext_dict">ext.dic;</entry>
<!--用户可以在这里配置自己的扩展停止词字典-->
<entrykey="ext_stopwords">stopword.dic;</entry>
</properties>。
所述的步骤2、其次在solr中配置mmseg4j分词器;
在配置文件schema.xml(位置{SOLR_HOME}/config/下),配置信息如下:
<fieldType name="text_mmseg4j_complex" class="solr.TextField"positionIncrementGap="100">
<!-- 创建索引使用 -->
<analyzer type="index">
<tokenizer class="com.chenlb.mmseg4j.solr.MMSegTokenizerFactory"mode="complex" dicPath="/hadoop/kbscloud/hhh/solr/credit/conf" />
<filter class="solr.StopFilterFactory" ignoreCase="true words="stopwords.txt"/>
</analyzer>
<!-- 搜索时使用 -->
<analyzer type="query">
<tokenizer class="com.chenlb.mmseg4j.solr.MMSegTokenizerFactory"mode="complex" dicPath="/hadoop/kbscloud/hhh/solr/credit/conf" />
<!-- 添加停用词 -->
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt"/>
<!-- 不区分大小写 -->
<filter class="solr.LowerCaseFilterFactory" />
</analyzer>
</fieldType>。
所述的步骤3、最后指定对应的分词方式;
在配置文件schema.xml(位置{SOLR_HOME}/config/下),配置信息如下:
<field name="WdMc" type="text_ikMM" indexed= "true" stored= "true" />
<field name="WdId" type="text_mmseg4j_complex" indexed= "true" stored= "true" />。
本发明的基于SOLR搜索引擎的两种分词器的混合应用方法和现有技术相比,可以解决solr分词方式对于中文分词的不足,弥补了因分词方式单一,造成的搜索引擎搜索不够精确,涵盖范围不够广的问题;使得搜索引擎的可用性得到了极大的提升。
具体实施方式
实施例1:
该基于SOLR搜索引擎的两种分词器的混合应用方法是在应用搜索引擎搜索时,利用solr中可以集成多种分词插件的特性,在建立索引时利用IK Analyzer分词的细密粒度分词方式,同时在搜索索引时又利用mmseg4j的分词方式进行搜索。
该方法步骤如下:
步骤1、首先在solr中配置IK Analyzer分词器;
1)在配置文件schema.xml(位置{SOLR_HOME}/config/下),配置信息如下:
<fieldType name="text_ikMM" class="solr.TextField">
<!—建立索引时调用Ik分词 -->
<analyzer type="index" isMaxWordLength="false" class="org.wltea.analyzer.lucene.IKAnalyzer"/>
<!—查询时用mmseg分词器 -->
<analyzer type="query">
<tokenizer class="com.chenlb.mmseg4j.solr.MMSegTokenizerFactory"
mode="complex" dicPath="/hadoop/kbscloud/hhh/solr/credit/conf" />
<!—添加停用词 -->
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" />
<!-- 不区分大小写 -->
<filter class="solr.LowerCaseFilterFactory" />
</analyzer>
</fieldType>
2)IKAnalyzer.cfg.xml配置文件
把stopword.dic和IKAnalyzer.cfg.xml复制到class根目录就可以启用停用词功能和扩展自己的词典
<?xmlversion="1.0"encoding="UTF-8"?>
<!DOCTYPEpropertiesSYSTEM"http://java.sun.com/dtd/properties.dtd">
<properties>
<comment>IK Analyzer 扩展配置</comment>
<!--用户可以在这里配置自己的扩展字典 -->
<entrykey="ext_dict">ext.dic;</entry>
<!--用户可以在这里配置自己的扩展停止词字典-->
<entrykey="ext_stopwords">stopword.dic;</entry>
</properties>。
步骤2、其次在solr中配置mmseg4j分词器;
在配置文件schema.xml(位置{SOLR_HOME}/config/下),配置信息如下:
<fieldType name="text_mmseg4j_complex" class="solr.TextField"positionIncrementGap="100">
<!-- 创建索引使用 -->
<analyzer type="index">
<tokenizer class="com.chenlb.mmseg4j.solr.MMSegTokenizerFactory"mode="complex" dicPath="/hadoop/kbscloud/hhh/solr/credit/conf" />
<filter class="solr.StopFilterFactory" ignoreCase="true words="stopwords.txt"/>
</analyzer>
<!-- 搜索时使用 -->
<analyzer type="query">
<tokenizer class="com.chenlb.mmseg4j.solr.MMSegTokenizerFactory"mode="complex" dicPath="/hadoop/kbscloud/hhh/solr/credit/conf" />
<!-- 添加停用词 -->
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt"/>
<!-- 不区分大小写 -->
<filter class="solr.LowerCaseFilterFactory" />
</analyzer>
</fieldType>。
步骤3、最后指定对应的分词方式;
在配置文件schema.xml(位置{SOLR_HOME}/config/下),配置信息如下:
<field name="WdMc" type="text_ikMM" indexed= "true" stored= "true" />
<field name="WdId" type="text_mmseg4j_complex" indexed= "true" stored= "true" />。
这样再搜所字段时,既可以单纯应用mmseg4j分词器,也可以混合使用mmseg4j分词和IK Analyzer分词器。
上述的IK Analyzer分词器采用“正向迭代最细粒度切分算法”,分词工具类IKQueryParser起至关重要的作用, 它对搜索关键词采用从最大词到最小词层层迭代检索方式切分,如此细密的分割方式,满足建立索引所需的词库基础,是索引的关键词包含的非常广泛。
上述的MMSeg算法有两种分词方法:Simple和Complex,都是基于正向最大匹配。mmseg4j在 Complex 算法基础上实现了最多分词(max-word)。这样就可以满足尽量准确的查找出所用的词的内容。
通过上面具体实施方式,所述技术领域的技术人员可容易的实现本发明。但是应当理解,本发明并不限于上述的几种具体实施方式。在公开的实施方式的基础上,所述技术领域的技术人员可任意组合不同的技术特征,从而实现不同的技术方案。

Claims (5)

1.基于SOLR搜索引擎的两种分词器的混合应用方法,其特征在于,该方法是在应用搜索引擎搜索时,利用solr中可以集成多种分词插件的特性,在建立索引时利用IK Analyzer分词的细密粒度分词方式,同时在搜索索引时又利用mmseg4j的分词方式进行搜索。
2.根据权利要求1所述的基于SOLR搜索引擎的两种分词器的混合应用方法,其特征在于,该方法步骤如下:
步骤1、首先在solr中配置IK Analyzer分词器;
步骤2、其次在solr中配置mmseg4j分词器;
步骤3、最后指定对应的分词方式。
3.根据权利要求2所述的基于SOLR搜索引擎的两种分词器的混合应用方法,其特征在于,所述的步骤1、首先在solr中配置IK Analyzer分词器;
1)在配置文件schema.xml(位置{SOLR_HOME}/config/下),配置信息如下:
<fieldType name="text_ikMM" class="solr.TextField">
<!—建立索引时调用Ik分词 -->
<analyzer type="index" isMaxWordLength="false" class="org.wltea.analyzer.lucene.IKAnalyzer"/>
<!—查询时用mmseg分词器 -->
<analyzer type="query">
<tokenizer class="com.chenlb.mmseg4j.solr.MMSegTokenizerFactory"
mode="complex" dicPath="/hadoop/kbscloud/hhh/solr/credit/conf" />
<!—添加停用词 -->
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" />
<!-- 不区分大小写 -->
<filter class="solr.LowerCaseFilterFactory" />
</analyzer>
</fieldType>
2)IKAnalyzer.cfg.xml配置文件
把stopword.dic和IKAnalyzer.cfg.xml复制到class根目录就可以启用停用词功能和扩展自己的词典
<?xmlversion="1.0"encoding="UTF-8"?>
<!DOCTYPEpropertiesSYSTEM"http://java.sun.com/dtd/properties.dtd">
<properties>
<comment>IK Analyzer 扩展配置</comment>
<!--用户可以在这里配置自己的扩展字典 -->
<entrykey="ext_dict">ext.dic;</entry>
<!--用户可以在这里配置自己的扩展停止词字典-->
<entrykey="ext_stopwords">stopword.dic;</entry>
</properties>。
4.根据权利要求2所述的基于SOLR搜索引擎的两种分词器的混合应用方法,其特征在于,所述的步骤2、其次在solr中配置mmseg4j分词器;
在配置文件schema.xml(位置{SOLR_HOME}/config/下),配置信息如下:
<fieldType name="text_mmseg4j_complex" class="solr.TextField" positionIncrementGap="100">
<!-- 创建索引使用 -->
<analyzer type="index">
<tokenizer class="com.chenlb.mmseg4j.solr.MMSegTokenizerFactory"mode="complex" dicPath="/hadoop/kbscloud/hhh/solr/credit/conf" />
<filter class="solr.StopFilterFactory" ignoreCase="true words="stopwords.txt"/>
</analyzer>
<!-- 搜索时使用 -->
<analyzer type="query">
<tokenizer class="com.chenlb.mmseg4j.solr.MMSegTokenizerFactory"mode="complex" dicPath="/hadoop/kbscloud/hhh/solr/credit/conf" />
<!-- 添加停用词 -->
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt"/>
<!-- 不区分大小写 -->
<filter class="solr.LowerCaseFilterFactory" />
</analyzer>
</fieldType>。
5.根据权利要求2所述的基于SOLR搜索引擎的两种分词器的混合应用方法,其特征在于,所述的步骤3、最后指定对应的分词方式;
在配置文件schema.xml(位置{SOLR_HOME}/config/下),配置信息如下:
<field name="WdMc" type="text_ikMM" indexed= "true" stored= "true" />
<field name="WdId" type="text_mmseg4j_complex" indexed= "true" stored= "true" />。
CN201610590042.4A 2016-07-26 2016-07-26 基于solr搜索引擎的两种分词器的混合应用方法 Pending CN106021625A (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610590042.4A CN106021625A (zh) 2016-07-26 2016-07-26 基于solr搜索引擎的两种分词器的混合应用方法

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610590042.4A CN106021625A (zh) 2016-07-26 2016-07-26 基于solr搜索引擎的两种分词器的混合应用方法

Publications (1)

Publication Number Publication Date
CN106021625A true CN106021625A (zh) 2016-10-12

Family

ID=57116494

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610590042.4A Pending CN106021625A (zh) 2016-07-26 2016-07-26 基于solr搜索引擎的两种分词器的混合应用方法

Country Status (1)

Country Link
CN (1) CN106021625A (zh)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106649800A (zh) * 2016-12-29 2017-05-10 南威软件股份有限公司 一种基于Solr的中文检索方法
CN106844633A (zh) * 2017-01-21 2017-06-13 浙江沛宏网络科技有限公司 一种分词搜索方法及其装置
CN109408817A (zh) * 2018-10-12 2019-03-01 科大国创软件股份有限公司 一种中文分词自定义词库***及其动态生效方法

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102402502A (zh) * 2011-11-24 2012-04-04 北京趣拿信息技术有限公司 用于搜索引擎的分词处理方法和装置
CN102890690A (zh) * 2011-07-22 2013-01-23 中兴通讯股份有限公司 目标信息搜索方法和装置
CN104391941A (zh) * 2014-11-25 2015-03-04 浪潮电子信息产业股份有限公司 一种快速构建常用文件全文检索工具的方法

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102890690A (zh) * 2011-07-22 2013-01-23 中兴通讯股份有限公司 目标信息搜索方法和装置
CN102402502A (zh) * 2011-11-24 2012-04-04 北京趣拿信息技术有限公司 用于搜索引擎的分词处理方法和装置
CN104391941A (zh) * 2014-11-25 2015-03-04 浪潮电子信息产业股份有限公司 一种快速构建常用文件全文检索工具的方法

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
白菜89: "Solr6 +mmseg4j+IK-Analyzer + SQLserver +DIH 完全配置", 《博客园》 *

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106649800A (zh) * 2016-12-29 2017-05-10 南威软件股份有限公司 一种基于Solr的中文检索方法
CN106844633A (zh) * 2017-01-21 2017-06-13 浙江沛宏网络科技有限公司 一种分词搜索方法及其装置
CN106844633B (zh) * 2017-01-21 2019-06-14 浙江沛宏网络科技有限公司 一种分词搜索方法及其装置
CN109408817A (zh) * 2018-10-12 2019-03-01 科大国创软件股份有限公司 一种中文分词自定义词库***及其动态生效方法

Similar Documents

Publication Publication Date Title
CN106934062B (zh) 一种查询elasticsearch的实现方法及***
KR102141272B1 (ko) 코드 추천 기법
US8972372B2 (en) Searching code by specifying its behavior
US20190278813A1 (en) Evaluating semantic interpretations of a search query
US10360212B2 (en) Guided keyword-based exploration of data
US20120124547A1 (en) Development artifact searching in an integrated development environment
US7987416B2 (en) Systems and methods for modular information extraction
US11586628B2 (en) Metadata driven dataset management
Diefenbach et al. Qanswer KG: designing a portable question answering system over RDF data
KR20060017765A (ko) 개념 네트워크
US20120290575A1 (en) Mining intent of queries from search log data
Pant Deriving link-context from HTML tag tree
CN106021625A (zh) 基于solr搜索引擎的两种分词器的混合应用方法
CN104462429A (zh) 数据库查询语句的生成方法及装置
Eddy et al. Impact of structural weighting on a latent dirichlet allocation–based feature location technique
JP4769822B2 (ja) ページグループを用いた情報検索サービス提供サーバー、方法及びシステム
US20120173501A1 (en) Configurable catalog builder system
CN105447342B (zh) 脚本加密方法、解密方法及引擎
US7617187B2 (en) Dataset search using reduced collation set
Dlugolinský et al. Evaluation of named entity recognition tools on microposts
Yi et al. Autog: A visual query autocompletion framework for graph databases
Aslam et al. SPedia: a central hub for the linked open data of scientific publications
CN114391142A (zh) 使用结构化和非结构化数据的解析查询
Sangeetha et al. Page ranking algorithms used in Web Mining
Giannakopoulos et al. Interactive text analysis and information extraction

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20161012