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

苏州企业网站制作报价网站cms下载

苏州企业网站制作报价,网站cms下载,wordpress short code,mvc5 网站开发在之前的文章 “Elasticsearch 8.10 中引入查询规则 - query rules”#xff0c;我们详述了如何使用 query rules 来进行搜索。这个交互式笔记本将向你介绍如何使用官方 Elasticsearch Python 客户端来使用查询规则。 你将使用 query rules API 将查询规则存储在 Elasticsearc…在之前的文章 “Elasticsearch 8.10 中引入查询规则 - query rules”我们详述了如何使用 query rules 来进行搜索。这个交互式笔记本将向你介绍如何使用官方 Elasticsearch Python 客户端来使用查询规则。 你将使用 query rules API 将查询规则存储在 Elasticsearch 中并使用 rule_query 查询它们。 安装 安装 Elasticsearch 及 Kibana 如果你还没有安装好自己的 Elasticsearch 及 Kibana那么请参考一下的文章来进行安装 如何在 LinuxMacOS 及 Windows 上进行安装 Elasticsearch Kibana如何在 LinuxMacOS 及 Windows 上安装 Elastic 栈中的 Kibana 在安装的时候请选择 Elastic Stack 8.x 进行安装。在安装的时候我们可以看到如下的安装信息 环境变量 在启动 Jupyter 之前我们设置如下的环境变量 export ES_USERelastic export ES_PASSWORDxnLj56lTrH98Lf_6n76y export ES_ENDPOINTlocalhost请在上面修改相应的变量的值。这个需要在启动 jupyter 之前运行。 拷贝 Elasticsearch 证书 我们把 Elasticsearch 的证书拷贝到当前的目录下 $ pwd /Users/liuxg/python/elser $ cp ~/elastic/elasticsearch-8.12.0/config/certs/http_ca.crt . $ ls http_ca.crt http_ca.crt 安装 Python 依赖包 python3 -m pip install -qU elasticsearch load_dotenv 准备数据 我们在项目当前的目录下创建如下的数据文件 query-rules-data.json  [{id: us1,content: {name: PureJuice Pro,description: PureJuice Pro: Experience the pinnacle of wireless charging. Blending rapid charging tech with sleek design, it ensures your devices are powered swiftly and safely. The future of charging is here.,price: 15.00,currency: USD,plug_type: B,voltage: 120v}},{id: uk1,content: {name: PureJuice Pro - UK Compatible,description: PureJuice Pro: Redefining wireless charging. Seamlessly merging swift charging capabilities with a refined aesthetic, it guarantees your devices receive rapid and secure power. Welcome to the next generation of charging.,price: 20.00,currency: GBP,plug_type: G,voltage: 230V}},{id: eu1,content: {name: PureJuice Pro - Wireless Charger suitable for European plugs,description: PureJuice Pro: Elevating wireless charging. Combining unparalleled charging speeds with elegant design, it promises both rapid and dependable energy for your devices. Embrace the future of wireless charging.,price: 18.00,currency: EUR,plug_type: C,voltage: 230V}},{id: preview1,content: {name: PureJuice Pro - Pre-order next version,description: Newest version of the PureJuice Pro wireless charger, coming soon! The newest model of the PureJuice Pro boasts a 2x faster charge than the current model, and a sturdier cable with an eighteen month full warranty. We also have a battery backup to charge on-the-go, up to two full charges. Pre-order yours today!,price: 36.00,currency: USD,plug_type: [B, C, G],voltage: [230V, 120V]}} ] 创建应用并展示 我们在当前的目录下打入如下的命令来创建 notebook $ pwd /Users/liuxg/python/elser $ jupyter notebook 导入包及连接到 Elasticsearch from elasticsearch import Elasticsearch from dotenv import load_dotenv import osload_dotenv()openai_api_keyos.getenv(OPENAI_API_KEY) elastic_useros.getenv(ES_USER) elastic_passwordos.getenv(ES_PASSWORD) elastic_endpointos.getenv(ES_ENDPOINT)url fhttps://{elastic_user}:{elastic_password}{elastic_endpoint}:9200 client Elasticsearch(url, ca_certs ./http_ca.crt, verify_certs True)print(client.info()) 索引一些测试数据 我们的客户端已设置并连接到我们的 Elastic 部署。 现在我们需要一些数据来测试 Elasticsearch 查询的基础知识。 我们将使用具有以下字段的小型产品索引 namedescriptionpricecurrencyplug_typevoltage 运行以下命令上传一些示例数据 import json# Load data into a JSON object with open(query-rules-data.json) as f:docs json.load(f)operations [] for doc in docs:operations.append({index: {_index: products_index, _id: doc[id]}})operations.append(doc[content]) client.bulk(indexproducts_index, operationsoperations, refreshTrue) 我们可以在 Kibana 中进行查看 搜索测试数据 首先让我们搜索数据寻找 “reliable wireless charger.”。 在搜索数据之前我们将定义一些方便的函数将来自 Elasticsearch 的原始 JSON 响应输出为更易于理解的格式。 def pretty_response(response):if len(response[hits][hits]) 0:print(Your search returned no results.)else:for hit in response[hits][hits]:id hit[_id]score hit[_score]name hit[_source][name]description hit[_source][description]price hit[_source][price]currency hit[_source][currency]plug_type hit[_source][plug_type]voltage hit[_source][voltage]pretty_output (f\nID: {id}\nName: {name}\nDescription: {description}\nPrice: {price}\nCurrency: {currency}\nPlug type: {plug_type}\nVoltage: {voltage}\nScore: {score})print(pretty_output)def pretty_ruleset(response):print(Ruleset ID: response[ruleset_id])for rule in response[rules]:rule_id rule[rule_id]type rule[type]print(f\nRule ID: {rule_id}\n\tType: {type}\n\tCriteria:)criteria rule[criteria]for rule_criteria in criteria:criteria_type rule_criteria[type]metadata rule_criteria[metadata]values rule_criteria[values]print(f\t\t{metadata} {criteria_type} {values})ids rule[actions][ids]print(f\tPinned ids: {ids}) 接下来进行搜索 不使用 query rules 的正常搜索 response client.search(indexproducts_index, query{multi_match: {query: reliable wireless charger for iPhone,fields: [ name^5, description ]} })pretty_response(response) 创建 query rules 我们分别假设我们知道我们的用户来自哪个国家/地区可能通过 IP 地址或登录的用户帐户信息进行地理位置定位。 现在我们希望创建查询规则以便当人们搜索包含短语 “wireless charger (无线充电器)” 的任何内容时根据该信息增强无线充电器的性能。 client.query_ruleset.put(ruleset_idpromotion-rules, rules[{rule_id: us-charger,type: pinned,criteria: [{type: contains,metadata: my_query,values: [wireless charger]},{type: exact,metadata: country,values: [us]}],actions: {ids: [us1]}},{rule_id: uk-charger,type: pinned,criteria: [{type: contains,metadata: my_query,values: [wireless charger]},{type: exact,metadata: country,values: [uk]}],actions: {ids: [uk1]}}]) 为了使这些规则匹配必须满足以下条件之一 my_query 包含字符串 “wireless charger” 并且 country “us”my_query 包含字符串 “wireless charger” 并且 country 为 “uk” 我们也可以使用 API 查看我们的规则集使用另一个 Pretty_ruleset 函数以提高可读性 response client.query_ruleset.get(ruleset_idpromotion-rules) pretty_ruleset(response) response client.search(indexproducts_index, query{rule_query: {organic: {multi_match: {query: reliable wireless charger for iPhone,fields: [ name^5, description ]}},match_criteria: {my_query: reliable wireless charger for iPhone,country: us},ruleset_id: promotion-rules} })pretty_response(response) 整个 notebook 的源码可以在地址下载https://github.com/liu-xiao-guo/semantic_search_es/blob/main/search_using_query_rules.ipynb
http://www.dnsts.com.cn/news/87892.html

相关文章:

  • 怎么解决360导航的网站建设个人主页模板下载
  • h5响应式网站公司网站开发用到的研究方法
  • 网站密度苏州模板建站平台
  • 大连零基础网站建设教学在哪里游戏网站建设成功案例
  • 做爰 网站asp门户网站系统
  • 高端企业网站要多少钱软件开发公司专业的有哪些
  • 莆田市城厢区建设局网站网站服务器怎么启动
  • 网站开发公司erpwordpress外贸主题购买
  • 简单网站php源码下载怎么做百度网站会显示图片在旁边
  • 做网站怎样连数据库外贸订单源码
  • 万能网站网址下载网站的代运营
  • 沛县网站设计怎么建设课程网站
  • 网页设计作品欣赏网站泰安市人才市场招聘网
  • 创意字体设计网站网站建设合同封面模板下载
  • 网站推广排名公司wordpress 插件 翻译
  • 网站制作 网站建设 杭州庆阳网上车管所
  • 湖南省军区强军网网站群建设项目6周口市住房和城乡建设局门户网站
  • 青岛制作网站的wordpress照片记录模板
  • 网站建设服务器的选择方案有北京网站建设手机号
  • 网站关键词优化推广东莞短视频推广方法
  • 利津网站制作百度总部地址
  • 菏泽+网站建设公司网站开发工程师有证书考试吗
  • 温州新闻优化设计七年级上册英语答案
  • 付网站建设费教育网站制作实训报告
  • 做招标应该关注什么网站wordpress公共函数在哪
  • 网站向哪里备案查询网站备案时间查询
  • 网站建设基础教学设计天津有哪些互联网公司
  • 南通网站制作公司中学网站建设方案 分校区
  • 网站改版怎么弄厦门市建设局局长
  • 网站建设流程范文抖音流量推广神器软件免费