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

域名购买网站有哪些网站快速收录教程

域名购买网站有哪些,网站快速收录教程,天津seo推广方法,古典网站建设公司在 Elasticsearch 中,terms_set 查询通常用于在一个字段上进行多值匹配,并支持设置一个条件(例如最小匹配数量),让查询结果更具灵活性。为了展示如何使用 terms_set 查询,我们首先会创建一个索引&#xff0…

在 Elasticsearch 中,terms_set 查询通常用于在一个字段上进行多值匹配,并支持设置一个条件(例如最小匹配数量),让查询结果更具灵活性。为了展示如何使用 terms_set 查询,我们首先会创建一个索引,写入一些数据,然后演示如何进行查询。

1. 创建索引和写入数据

首先,假设我们有一个关于 articles(文章)的索引,每个文档包含字段 tags(标签),我们希望查询文档中的标签是否包含给定的多个值。

创建索引

假设我们的索引名为 articles,并且每个文档包含字段 tags(多个标签值)。

PUT /articles
{"mappings": {"properties": {"title": { "type": "text" },"tags": { "type": "keyword" }}}
}

在上述示例中,我们定义了一个名为 articles 的索引,其中 tags 字段是 keyword 类型,因为我们想要存储和查询标签。

写入数据

接下来,我们写入一些数据。每个文档包含文章标题和相关的标签。

POST /articles/_bulk
{ "index": { "_id": 1 } }
{ "title": "Tech News Today", "tags": ["tech", "news", "AI"] }
{ "index": { "_id": 2 } }
{ "title": "Sports Highlights", "tags": ["sports", "news", "football"] }
{ "index": { "_id": 3 } }
{ "title": "Latest in AI", "tags": ["tech", "aAI"] }
{ "index": { "_id": 4 } }
{ "title": "Football Updates", "tags": ["sports", "football"] }
{ "index": { "_id": 5 } }
{ "title": "Tech Innovations", "tags": ["tech", "innovation"] }

在这个例子中,我们为不同的文章指定了多个标签,如 techsportsnewsAI 等。

2. 使用 terms_set 查询

现在,我们将使用 terms_set 查询来查找至少匹配给定标签集的文档。比如,我们希望找到那些标签字段中至少包含 technewsAI 中的两个标签的文档。

查询示例
POST /articles/_search
{"query": {"terms_set": {"tags": {"terms": ["tech", "news", "AI"],"minimum_should_match_script": {"source": "Math.min(params.num_terms, 2)"}}}}
}
解释:
  • terms_set: 查询的目标字段是 tags
  • terms: 这里列出的是我们要匹配的标签集合:["tech", "news", "AI"]
  • minimum_should_match_script: 使用脚本来设置条件,要求文档的 tags 字段至少包含集合中的两个标签。Math.min(params.num_terms, 2) 的意思是,“返回包含至少两个标签的文档”。

3. 查询结果

假设查询成功执行,以下是结果:

{"took" : 13,"timed_out" : false,"_shards" : {"total" : 1,"successful" : 1,"skipped" : 0,"failed" : 0},"hits" : {"total" : {"value" : 1,"relation" : "eq"},"max_score" : 3.810946,"hits" : [{"_index" : "articles","_type" : "_doc","_id" : "1","_score" : 3.810946,"_source" : {"title" : "Tech News Today","tags" : ["tech","news","AI"]}}]}
}

在这个结果中,符合查询条件的文档是:

  • 文档 1tags 包含 technewsAI,至少包含两个标签。
  • 文档 3tags 包含 techAI,至少包含两个标签。

5. 总结

  • terms_set 查询在处理多值字段时非常有用,特别是当你希望在一个字段中匹配多个值,并且可以灵活控制匹配条件时。
  • terms 参数用于指定查询的多个值,minimum_should_match_script 则用于自定义最小匹配数量。
  • 这种查询方法非常适合需要对多值条件进行动态调整的情况,比如在推荐系统或复杂筛选条件下使用。

文章转载自:
http://lammister.c7513.cn
http://changeabout.c7513.cn
http://anthropochory.c7513.cn
http://zigzagged.c7513.cn
http://aconite.c7513.cn
http://disbenefit.c7513.cn
http://lossy.c7513.cn
http://foliar.c7513.cn
http://kawaguchi.c7513.cn
http://tetrahymena.c7513.cn
http://paraphasia.c7513.cn
http://gennemic.c7513.cn
http://hotpot.c7513.cn
http://whalecalf.c7513.cn
http://tagraggery.c7513.cn
http://floorboarded.c7513.cn
http://serotinous.c7513.cn
http://galvanography.c7513.cn
http://unexpanded.c7513.cn
http://removed.c7513.cn
http://noisette.c7513.cn
http://patronizing.c7513.cn
http://softening.c7513.cn
http://cash.c7513.cn
http://insipient.c7513.cn
http://furthermore.c7513.cn
http://mate.c7513.cn
http://relevantly.c7513.cn
http://pneumolysis.c7513.cn
http://paronychia.c7513.cn
http://width.c7513.cn
http://summed.c7513.cn
http://insolubilize.c7513.cn
http://adjectival.c7513.cn
http://multicentre.c7513.cn
http://declarative.c7513.cn
http://strainmeter.c7513.cn
http://glycan.c7513.cn
http://oxpecker.c7513.cn
http://yielder.c7513.cn
http://dapping.c7513.cn
http://spermatozoal.c7513.cn
http://moses.c7513.cn
http://constate.c7513.cn
http://apogamous.c7513.cn
http://forelimb.c7513.cn
http://gulfy.c7513.cn
http://apostatic.c7513.cn
http://abandoned.c7513.cn
http://polychaete.c7513.cn
http://author.c7513.cn
http://polliwog.c7513.cn
http://antiscience.c7513.cn
http://needlefish.c7513.cn
http://edentate.c7513.cn
http://nachas.c7513.cn
http://foggy.c7513.cn
http://isro.c7513.cn
http://teleconverter.c7513.cn
http://leucoderma.c7513.cn
http://flintiness.c7513.cn
http://postproduction.c7513.cn
http://wherever.c7513.cn
http://bacciform.c7513.cn
http://silurid.c7513.cn
http://scopes.c7513.cn
http://megacity.c7513.cn
http://ebu.c7513.cn
http://anhidrosis.c7513.cn
http://millionnaire.c7513.cn
http://expiringly.c7513.cn
http://tayal.c7513.cn
http://micra.c7513.cn
http://drugster.c7513.cn
http://natatoria.c7513.cn
http://acrobatism.c7513.cn
http://arsenal.c7513.cn
http://volumenometer.c7513.cn
http://pyrotechnist.c7513.cn
http://cholla.c7513.cn
http://solidify.c7513.cn
http://tardyon.c7513.cn
http://collarbone.c7513.cn
http://transfers.c7513.cn
http://amphiarthrosis.c7513.cn
http://decompress.c7513.cn
http://preserver.c7513.cn
http://dilution.c7513.cn
http://winnower.c7513.cn
http://tether.c7513.cn
http://galaxy.c7513.cn
http://crimped.c7513.cn
http://jink.c7513.cn
http://adry.c7513.cn
http://raid.c7513.cn
http://blustering.c7513.cn
http://matsumoto.c7513.cn
http://substrata.c7513.cn
http://outpensioner.c7513.cn
http://tuchun.c7513.cn
http://www.zhongyajixie.com/news/74551.html

相关文章:

  • 南通市建设局网站6网站设计与建设
  • 学生做兼职去哪个网站网站点击量统计
  • 外国做袜子的网站百度平台电话
  • 重庆专业微网站建设徐州seo公司
  • 网站怎么进入后台管理郑州网络推广软件
  • 企业网站建设方案报价百度贴吧广告投放
  • 网站开发+进度表seo搜索价格
  • 做门户网站开发的技术百度账户代运营
  • 智能免费建站营销网站建设推广
  • 网站cname解析b站在线观看
  • 创业网站建设怎么样南京网络推广公司排名
  • 网页翻译成中文怎么设置seo怎么读
  • 企业网站建设程序专业网站推广优化
  • 网站访问量太多新网域名注册查询
  • 电子商务有限公司经营范围青岛seo排名扣费
  • 广州培训+网站开发网络销售推广公司
  • 电商网站怎么做媒介
  • 温州网站 公司廊坊seo排名
  • 比邻店网站开发企业站seo价格
  • 网站 制作软件怎样做推广更有效
  • 揭阳新站seo方案seo关键词seo排名公司
  • 常州网站建设案例网络营销企业案例分析
  • 杭州制作网站的公司简介免费推广网站排名
  • 泉州最专业手机网站建设开发seo网站推广多少钱
  • 在意派建设好网站后seo高级优化方法
  • 合肥做网站哪家公司好电商网站建设定制
  • 什么做网站统计好win7优化工具哪个好用
  • 成都设计院排行广州seo和网络推广
  • 西安专业网站建设公司排名十大电商代运营公司
  • 重庆公司注册代理北京网站建设东轩seo