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

Elasticsearch(13) match_phrase的使用

elasticsearch version: 7.10.1

match_phrase 语法

POST <index>/_search
{"query": {"match_phrase": {"<field_name>": {"query": "<your_search_phrase>","slop": <max_distance>,"analyzer": "<analyzer_name>" (optional)}}}
}
  • <your_search_phrase>: 要搜索的确切短语
  • 可选参数,表示短语中词语的最大允许间隔数,默认值为0(即词语必须相邻)。

例题

场景

索引创建

PUT /product-reviews
{"mappings": {"properties": {"review": {"type": "text","analyzer": "standard"}}}
}

文档插入

POST /product-reviews/_doc/
{"review": "This product is really easy to use and very efficient, I highly recommend it."
}
POST /product-reviews/_doc/
{"review": "This product is easy to use, efficient and has a great design."
}POST /product-reviews/_doc/
{"review": "It's not just easy to use but also very energy-efficient, making it a top choice."
}POST /product-reviews/_doc/
{"review": "Easy-to-use products are always my favorite, this one is highly efficient as well."
}POST /product-reviews/_doc/
{"review": "I was surprised by how user-friendly and efficient this product turned out to be."
}POST /product-reviews/_doc/
{"review": "The usability and efficiency of this product exceeded all my expectations."
}

查询语句

POST /product-reviews/_search
{"query": {"match_phrase": {"review": {"query": "easy to use efficient","slop": 1}}}
}
http://www.lryc.cn/news/321063.html

相关文章:

  • 通过路由器监控,优化网络效率
  • 使用canvas实现图纸标记及回显
  • 鸿蒙-自定义组件的生命周期
  • 【Linux】自动化构建工具-make/Makefile
  • week07day03(power bi dax公式 零售数据业务分析)
  • rembg报错onnxruntime_providers_tensorrt.dll
  • 精酿啤酒:一口啤酒,一份享受
  • git报: “fatal: detected dubious ownership in repository“
  • 代码随想录算法训练营第27天|93.复原IP地址、78.子集、90.子集二
  • Java微服务轻松部署服务器
  • Wordpress站点通过修改.htaccess 设置重定向实现强制 https 访问
  • 人大金仓助力国家电网调度中心培养国产数据库专家人才
  • 什么是增强型SSL证书?购买一张需要多少钱?
  • C++:函数传参到函数执行结束发生了什么
  • QT中dumpcpp以及dumpdoc使用
  • RPM与DNF的操作实践
  • 车道线检测之LaneNet
  • MySQL连接数不足导致服务异常GetConnectionTimeoutException
  • 软考76-上午题-【面向对象技术3-设计模式】-创建型设计模式01
  • Matlab 双目相机标定(内置函数)
  • 【博客7.4】缤果Qt5_TWS串口调试助手V2.0 (高级篇)
  • CSS案例-4.padding导航栏练习
  • 5.1.4.2、【AI技术新纪元:Spring AI解码】Llama2 Chat
  • 后台发送GET/POST方法
  • 计算机考研|双非一战135上岸,408经验分享+复盘
  • 低代码与数字化工具:重塑软件开发的新范式
  • 如何使用 ArcGIS Pro 生成TIN
  • 你真的会做抖音小店吗?你做抖店的方法是正确的吗?教学分享
  • ssh免密登陆更换目标主机后无法连接
  • Java获取视频封面图,利用FFmpegFrameGrabber获取视频封面图