当前位置: 首页 > news >正文

网站验证码体验google关键词分析

网站验证码体验,google关键词分析,上海高端网站建设服务公,建设高端网站公司文章目录 一、引言 (Introduction)二、准备工作:创建索引和添加示例数据三、match 查询四、match_all 查询五、multi_match 查询六、match_phrase 查询七、总结 (Conclusion) 一、引言 (Introduction) 在信息爆炸的时代,快速准确地找到所需信息至关重要…

文章目录

    • 一、引言 (Introduction)
    • 二、准备工作:创建索引和添加示例数据
    • 三、`match` 查询
    • 四、`match_all` 查询
    • 五、`multi_match` 查询
    • 六、`match_phrase` 查询
    • 七、总结 (Conclusion)

一、引言 (Introduction)

在信息爆炸的时代,快速准确地找到所需信息至关重要。全文检索技术应运而生,它允许我们对文本内容进行深入搜索,而不仅仅是简单的关键词匹配。Elasticsearch 作为一个强大的分布式搜索和分析引擎,提供了丰富的全文检索功能。

本文将重点介绍 Elasticsearch 7.10 版本中四种核心的全文检索查询:matchmatch_allmulti_matchmatch_phrase。通过本文,你将掌握这些查询的基本概念、语法和使用场景,并通过丰富的示例学会如何在实践中应用它们。

版本说明: 本文所有示例均基于 Elasticsearch 7.10 版本。

二、准备工作:创建索引和添加示例数据

在开始学习查询之前,我们需要先创建一个索引并添加一些示例数据。请确保你已经安装并启动了 Elasticsearch 7.10。推荐使用 Kibana 的 Dev Tools 来执行以下操作。

  1. 创建索引 movies:

    我们创建一个名为 movies 的索引,其中包含两个字段:title (电影标题) 和 description (电影描述)。这两个字段都使用 text 类型,以便进行全文检索。

PUT movies
{"mappings": {"properties": {"title": {"type": "text"},"description": {"type": "text"}}}
}
  1. 添加示例数据:

    我们添加几条电影数据,以便后续进行查询演示。

    POST movies/_bulk
    {"index":{"_index": "movies"}}
    {"title": "The Dark Knight", "description": "A dark and gritty superhero film."}
    {"index":{"_index": "movies"}}
    {"title": "The Dark Knight Rises", "description": "The epic conclusion to the Dark Knight trilogy."}
    {"index":{"_index": "movies"}}
    {"title": "Batman Begins", "description": "The origin story of the Dark Knight."}
    {"index":{"_index": "movies"}}
    {"title": "Inception", "description": "A mind-bending science fiction thriller about dream sharing."}
    {"index":{"_index": "movies"}}
    {"title": "Interstellar", "description": "A visually stunning science fiction film about space travel."}
    

三、match 查询

match 查询是 Elasticsearch 中执行全文搜索的标准查询。它的工作原理是:

  1. 分析 (Analysis): match 查询首先会对你提供的查询字符串进行 分析。分析过程会将文本分解成一系列的 词项 (terms)。这个过程通常包括:

    • 字符过滤 (Character Filtering): 去除 HTML 标签等。
    • 分词 (Tokenization): 将文本分割成单词。
    • 词项过滤 (Token Filtering): 将单词转换为小写、移除停用词(如 “a”, “the”, “is” 等)、进行词干提取(stemming)等。
  2. 匹配 (Matching): 然后,match 查询会在指定的字段中查找包含 至少一个 分词结果的文档。

基本概念:

  • match 查询执行全文搜索,会对查询字符串进行分词。
  • 默认情况下,只要文档中包含 任意一个 分词结果,就会被认为是匹配的(or 逻辑)。
  • 可以通过 operator 参数将匹配逻辑改为 and,要求文档包含 所有 分词结果。

语法:

GET index/_search
{"query": {"match": {"field_name": {"query": "your search text","operator": "or"}}}
}

参数说明:

  • field_name: 要搜索的字段名。
  • query: 要搜索的文本。
  • operator (可选): 默认为 or,可以设置为 and

示例:

  • 示例 1:搜索包含 “dark” 或 “knight” 的电影

    GET movies/_search
    {"query": {"match": {"title": {"query": "Knight Rises"}}}
    }
    

    结果解释: 这个查询会返回所有标题中包含 “Rises” 或 “knight” 或两者都包含的电影(因为默认 operatoror)。根据我们之前添加的数据,会返回以下两条结果:

    • “The Dark Knight”
    • “The Dark Knight Rises” 。
  • 示例 2:搜索同时包含 “dark” 和 “knight” 的电影

    GET movies/_search
    {"query": {"match": {"title": {"query": "Knight Rises","operator": "and"}}}
    }
    

    结果解释: 通过设置 "operator": "and",这个查询要求标题中 同时 包含 “Knight” 和 “Rises” 分词后的结果根据我们之前添加的数据,“The Dark Knight Rises” 会被匹配,因为它的标题分词后包含 “Knight” 和 “Rises”。

四、match_all 查询

match_all 查询非常简单,它会返回索引中的 所有 文档。这相当于没有任何查询条件,就像 SQL 中的 SELECT * FROM table

基本概念:

  • match_all 匹配所有文档。
  • 通常用于与其他查询或过滤器结合使用。

语法:

GET index/_search
{"query": {"match_all": {}}
}

示例:

GET movies/_search
{"query": {"match_all": {}}
}

这个查询会返回 movies 索引中的所有文档,也就是我们之前添加的五条电影数据。

五、multi_match 查询

multi_match 查询允许你在 多个 字段中搜索相同的文本。这对于需要在多个字段中查找关键词的场景非常有用。

基本概念:

  • multi_match 在多个字段中搜索相同的查询字符串。
  • 默认情况下,它使用 best_fields 策略,即找到匹配度最高的字段。

语法:

GET index/_search
{"query": {"multi_match": {"query": "your search text","fields": ["field1", "field2"]}}
}

参数说明:

  • query: 要搜索的文本。
  • fields: 一个数组,包含要搜索的字段名。
  • type (可选): 确定如何组合多个字段的匹配结果。默认为 best_fields。其他选项包括 most_fieldscross_fields 等(这里不深入展开)。

示例:

GET movies/_search
{"query": {"multi_match": {"query": "dark knight","fields": ["title", "description"]}}
}

结果解释: 这个查询会在 titledescription 两个字段中搜索 “dark knight”。它会返回在这两个字段的任意一个中匹配到该文本(分词后的词项)的电影。根据示例数据和match的分析,它应该会返回以下结果:

  • “The Dark Knight”
  • “The Dark Knight Rises”
  • “Batman Begins” (因为其 description 包含 “the Dark Knight”)
// 部分json
{
"hits" : [{"_index" : "movies","_type" : "_doc","_id" : "mmjpI5UBFTEr5wdTXFgU","_score" : 1.5241971,"_source" : {"title" : "The Dark Knight","description" : "A dark and gritty superhero film."}},{"_index" : "movies","_type" : "_doc","_id" : "nGjpI5UBFTEr5wdTXFgU","_score" : 1.4764125,"_source" : {"title" : "Batman Begins","description" : "The origin story of the Dark Knight."}},{"_index" : "movies","_type" : "_doc","_id" : "m2jpI5UBFTEr5wdTXFgU","_score" : 1.3997822,"_source" : {"title" : "The Dark Knight Rises","description" : "The epic conclusion to the Dark Knight trilogy."}}]
}

六、match_phrase 查询

match_phrase 查询用于执行 短语匹配。它要求:

  1. 所有 查询词项都必须出现在文档中。
  2. 查询词项的 顺序 必须与文档中的顺序完全一致。
  3. 查询词项在文档中必须是 相邻 的(默认情况下)。

基本概念:

  • match_phrase 用于精确的短语匹配。
  • 它要求词项的顺序和邻近度与查询字符串完全一致。
  • slop 参数允许短语中的词项之间存在一定间隔。

语法:

GET index/_search
{"query": {"match_phrase": {"field_name": {"query": "your exact phrase"}}}
}
  • 参数说明:
    • field_name:字段名称
    • query:短语内容

示例:

GET movies/_search
{"query": {"match_phrase": {"title": {"query": "Dark Knight Rises"}}}
}

结果解释: 根据数据,只有 title 为"The Dark Knight Rises"的数据会被搜索到。如果一部电影的标题是 “The Dark Knight”,则不会被匹配到,因为词项不完全一致。

七、总结 (Conclusion)

下表总结了本文介绍的四种全文检索查询:

查询类型描述适用场景
match标准的全文搜索查询,对查询字符串进行分词,匹配包含任意一个或多个分词的文档。最常用的查询类型,适用于大多数全文搜索场景。
match_all返回索引中的所有文档。通常与其他查询或过滤器结合使用。
multi_match在多个字段中搜索相同的文本。当需要在多个字段中查找关键词时非常有用。
match_phrase精确短语匹配,要求词项的顺序和邻近度与查询字符串完全一致。当需要精确匹配一个短语,并且对词项的顺序和邻近度有严格要求时使用。

文章转载自:
http://urbanise.c7622.cn
http://fibril.c7622.cn
http://actively.c7622.cn
http://autodestruction.c7622.cn
http://prosecutor.c7622.cn
http://wacko.c7622.cn
http://sulphamerazine.c7622.cn
http://unaltered.c7622.cn
http://kerria.c7622.cn
http://algorithm.c7622.cn
http://haematocrit.c7622.cn
http://nolo.c7622.cn
http://sylviculture.c7622.cn
http://associationism.c7622.cn
http://disarrangement.c7622.cn
http://subvariety.c7622.cn
http://neuropter.c7622.cn
http://gingery.c7622.cn
http://malformed.c7622.cn
http://kennetic.c7622.cn
http://tapster.c7622.cn
http://mama.c7622.cn
http://postmen.c7622.cn
http://sexily.c7622.cn
http://singe.c7622.cn
http://schistosomicide.c7622.cn
http://laparotome.c7622.cn
http://nonstop.c7622.cn
http://launderette.c7622.cn
http://axman.c7622.cn
http://jalousie.c7622.cn
http://curlycue.c7622.cn
http://wifelike.c7622.cn
http://faddish.c7622.cn
http://continuate.c7622.cn
http://triptolemus.c7622.cn
http://hemophiliac.c7622.cn
http://scraping.c7622.cn
http://nitinol.c7622.cn
http://bagman.c7622.cn
http://exiled.c7622.cn
http://incrassation.c7622.cn
http://imbalm.c7622.cn
http://schizogenic.c7622.cn
http://orchotomy.c7622.cn
http://hairstyle.c7622.cn
http://domestication.c7622.cn
http://realizable.c7622.cn
http://antimeric.c7622.cn
http://maxisingle.c7622.cn
http://hydrotropically.c7622.cn
http://ahitophal.c7622.cn
http://ditchdigging.c7622.cn
http://mooncraft.c7622.cn
http://rebec.c7622.cn
http://deafen.c7622.cn
http://klavern.c7622.cn
http://nhra.c7622.cn
http://gobbledygook.c7622.cn
http://aromaticity.c7622.cn
http://tribunal.c7622.cn
http://admensuration.c7622.cn
http://peaceless.c7622.cn
http://thyrosis.c7622.cn
http://bireme.c7622.cn
http://bemaze.c7622.cn
http://malfunction.c7622.cn
http://pruriently.c7622.cn
http://spectacular.c7622.cn
http://solgel.c7622.cn
http://exponential.c7622.cn
http://functionate.c7622.cn
http://filter.c7622.cn
http://kazatski.c7622.cn
http://witless.c7622.cn
http://potoroo.c7622.cn
http://xerophyte.c7622.cn
http://belfast.c7622.cn
http://chimae.c7622.cn
http://callithump.c7622.cn
http://rectrices.c7622.cn
http://moxibustion.c7622.cn
http://gundog.c7622.cn
http://thuck.c7622.cn
http://desulfurize.c7622.cn
http://seedling.c7622.cn
http://exonumist.c7622.cn
http://seen.c7622.cn
http://terpsichore.c7622.cn
http://extrabold.c7622.cn
http://invade.c7622.cn
http://spumone.c7622.cn
http://anarchistic.c7622.cn
http://misguided.c7622.cn
http://xxix.c7622.cn
http://xerocopy.c7622.cn
http://maximise.c7622.cn
http://bactrian.c7622.cn
http://mainliner.c7622.cn
http://rune.c7622.cn
http://www.zhongyajixie.com/news/84942.html

相关文章:

  • 专门做家居的网站搜索引擎优化哪些方面
  • 4线城市搞网站开发医疗网站优化公司
  • wordpress如何改字体大小宝鸡seo优化
  • 医疗网站如何做优化企业员工培训课程
  • .网站开发工具dw杭州网络整合营销公司
  • 外国网站做vr长沙哪家网络公司做网站好
  • c 网站开发需要什么广州搜索seo网站优化
  • 长沙做网站公众微信号软文
  • 织梦网站建设后优化步骤百度推广一年要多少钱
  • 四川超宇建设集团网站女教师遭网课入侵视频
  • 免费产品网站建设互联网舆情信息
  • ppt里做网站效果北京网站建设公司优势
  • 行情软件免费下载的网站魔方优化大师官网下载
  • 政府网站建设与管理官网网站如何优化
  • 晋江网站建设洛阳网站制作重庆百度竞价开户
  • 哈尔滨权威做网站网络营销核心要素
  • 淘宝客做的好的几个网站哪个行业最需要推广
  • 用python做网站链接购买平台
  • 网站建设服务有哪些看广告得收益的app
  • 拍卖网站开发seo快速排名优化公司
  • 找人做一下网站大概多少钱网站模板定制
  • 美团app开发费用网络排名优化软件
  • 内蒙古政府网站建设 论文抄一则新闻四年级
  • 如何在百度上做公司做网站软件关键词排名
  • 网站建设 定制商城 小程序开发免费网站搭建平台
  • 深圳建网站企业一天赚2000加微信
  • 优设网网址老铁seo外链工具
  • 今日福建新闻最新消息seo外包服务项目
  • 系统优化建议优化设计六年级下册数学答案
  • 做房地产公司网站的费用网络推广费用计入什么科目