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

做网站单页烧钱中富国建设有限公司网站

做网站单页烧钱,中富国建设有限公司网站,深圳网页设计培训班价格,免费高清视频在中文搜索场景中#xff0c;用户经常使用拼音输入#xff08;如 “iPhone”、“pingguo”#xff09;来搜索中文内容#xff08;如“苹果手机”#xff09;。为了提升用户体验#xff0c;Elasticsearch 可通过 拼音分词器 Completion Suggester 实现 拼音补全#xff…在中文搜索场景中用户经常使用拼音输入如 “iPhone”、“pingguo”来搜索中文内容如“苹果手机”。为了提升用户体验Elasticsearch 可通过 拼音分词器 Completion Suggester 实现 拼音补全Pinyin Completion 功能。 本文提供一套 完整、可落地的 Elasticsearch 拼音补全配置模板支持 中文输入 → 中文补全拼音输入 → 中文补全拼音首字母输入 → 中文补全自动纠错与模糊匹配 一、前置准备 1. 安装拼音分词插件 Elasticsearch 官方不自带拼音分词器需安装第三方插件 # 进入 Elasticsearch 插件目录 cd /usr/share/elasticsearch# 安装拼音分词器根据 ES 版本选择 bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-pinyin/releases/download/v8.11.0/elasticsearch-analysis-pinyin-8.11.0-linux-x86_64.zip✅ 支持版本6.x ~ 8.xGitHub 项目地址 重启 Elasticsearch 使插件生效。 二、索引配置模板 PUT /products-pinyin {settings: {analysis: {analyzer: {pinyin_analyzer: {type: custom,tokenizer: pinyin,filter: [lowercase]}},tokenizer: {pinyin: {type: pinyin,keep_separate_first_letter: false,keep_full_pinyin: true,keep_original: true,limit_first_letter_length: 16,lowercase: true,remove_duplicated_term: true}}}},mappings: {properties: {title: {type: text,analyzer: ik_max_word,fields: {pinyin: {type: text,analyzer: pinyin_analyzer}}},suggest: {type: completion,analyzer: simple,preserve_separators: true,preserve_position_increments: true,max_input_length: 50},suggest_pinyin: {type: completion,analyzer: pinyin_analyzer,preserve_separators: false,preserve_position_increments: false,max_input_length: 50}}} }三、字段说明 字段用途title原始文本用于全文搜索title.pinyin用于拼音搜索如 match: { title.pinyin: pingguo }suggest支持中文输入补全如“苹” → “苹果手机”suggest_pinyin支持拼音输入补全如“ping” → “苹果手机”四、写入文档示例 PUT /products-pinyin/_doc/1 {title: 苹果手机 iPhone 15,suggest: {input: [苹果手机,iPhone 15,苹果,手机],weight: 30},suggest_pinyin: {input: [pingguoshouji,yinguoshouji,pingguo,shouji,pgs,pg],weight: 30} }✅ input 列表包含 完整拼音pingguoshouji首字母pgs、pg分词拼音pingguo, shouji 五、查询方式 1. 中文前缀补全 POST /products-pinyin/_search {suggest: {text: 苹,completion: {field: suggest}} }返回 suggest: [{text: 苹,options: [{ text: 苹果手机, score: 30 }]} ]2. 拼音前缀补全 POST /products-pinyin/_search {suggest: {text: ping,completion: {field: suggest_pinyin}} }返回 options: [{ text: pingguoshouji, score: 30 } ]⚠️ 返回的是拼音需在应用层映射回原始标题。 ✅ 建议在 suggest_pinyin 的 _source 中存储原始 title suggest_pinyin: {input: [pingguo],weight: 30,_source: 苹果手机 iPhone 15 }3. 拼音首字母补全 POST /products-pinyin/_search {suggest: {text: pgs,completion: {field: suggest_pinyin}} }只要 input 中包含 pgs即可匹配。 4. 模糊拼音补全支持纠错 suggest: {text: pinggou,completion: {field: suggest_pinyin,fuzzy: {fuzziness: 1,transpositions: true}} }可匹配 pingguo编辑距离为 1。 六、优化建议 ✅ 场景建议输入性能预生成拼音和首字母避免运行时计算存储空间suggest_pinyin.input 可能较多控制 max_input_length权重控制热门商品设置更高 weight缓存应用层缓存高频拼音前缀如“i”, “ip”, “iph”多语言支持英文、拼音混合输入七、完整补全流程应用层 def get_suggestions(user_input):suggestions []# 1. 如果是中文查 suggestif is_chinese(user_input):res es.search(indexproducts-pinyin, suggest{text: user_input, completion: {field: suggest}})for opt in res[suggest][0][options]:suggestions.append(opt[text])# 2. 如果是拼音查 suggest_pinyinelif is_pinyin(user_input):res es.search(indexproducts-pinyin, suggest{text: user_input, completion: {field: suggest_pinyin}, fuzzy: {fuzziness: 1}})for opt in res[suggest][0][options]:# 从 _source 或映射表获取原始标题original get_title_by_pinyin(opt[text])if original not in suggestions:suggestions.append(original)return suggestions[:10]八、扩展建议 场景建议方案动态拼音生成写入时用 Ingest Pipeline 自动生成拼音拼音 中文混合补全使用 multi_match 查询 title.pinyin 和 title个性化补全结合用户历史行为调整 weight冷启动问题初始填充运营配置的热门词性能监控监控 suggest 查询延迟与命中率九、Ingest Pipeline 自动生成拼音可选 PUT /_ingest/pipeline/add_pinyin_suggest {description: 自动添加拼音补全字段,processors: [{script: {lang: painless,source: ctx.suggest_pinyin [];def inputs [ctx.title];// 可调用外部服务生成拼音// 此处简化为固定值ctx.suggest_pinyin.add(pingguoshouji);ctx.suggest_pinyin.add(pgs);}}] }写入时使用 PUT /products-pinyin/_doc/2?pipelineadd_pinyin_suggest {title: 华为手机 }
http://www.pierceye.com/news/892919/

相关文章:

  • 呼市网站制作招聘建设网站 托管 费用
  • dede自适应网站模板济南著名网站建设
  • 旅游网站排名榜手机开发网站工具
  • 饰品公司网站建设策划书百度seo优化收费标准
  • wordpress企业建站5网站建设
  • 网站运营解决方案皮具网站设计
  • 地宝网 网站建设上海网站制作网站开发
  • 有哪些出名的工业设计网站做废钢铁生意在哪个网站了解
  • wordpress 根目录函数深圳债务优化公司
  • 基于android的app的设计与开发seo链接优化
  • 怎么用优盘做网站登录密钥百度收录网站名字
  • 网站制作的一般步骤网站域名备案需要多长时间
  • 运城市住房与城乡建设局网站郑州百姓网招聘
  • 网站调用网页怎么做重庆手机网站方案设计
  • 购物 网站建设的市场分析泰兴网站建设吧
  • 企业网站代运营微信网页登录wordpress
  • 专业网站制作流程深圳市 网站建设450
  • 怎么做加盟网站海南网站搭建外包
  • 没有网站可以做落地页网站体验方案
  • 重庆便宜做网站的网站内容注意事项
  • 温岭手机网站建设企业网站建设遵循的原则
  • 美丽乡村 村级网站建设wordpress地图主题
  • 做双语网站多少钱建立设计网站富阳
  • 为什么有网网站打不开怎么回事网站怎样添加友情链接
  • 中国五码一级做爰网站wordpress去掉评论注册
  • 网站备案修改域名贵阳仿站定制模板建站
  • 渭南 网站集约化建设淘宝网站开发技术名称
  • 临沂做网站费用wordpress新浪微博图床插件
  • 游戏网站建设收费明细WordPress 中英文翻译
  • 如何建设一个企业网站wordpress底部导航代码