栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

提前/滚动:不起作用

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

提前/滚动:不起作用

好的,我认为您有两个问题。

问题1:

您看起来像是在使用10.0版之前的预输入API。要使用远程,您必须使用Bloodhound或类似的东西来获取结果。

我最近实现了此功能,这是一个有效的示例:

var $vartypeahead = $(yourjqueryelement);var engine = new Bloodhound({  name: 'typeaheads',  remote: {"url":'/search/typeahead?q=%QUERY'},  datumTokenizer: function(d) { return d;},  queryTokenizer: function(d) { return d;}});engine.initialize();$vartypeahead.typeahead({          "minLength": 2,          "highlight": true        },        {          "source": engine.ttAdapter()          });

我确实必须对所做的事情稍作修改;我在前端使用骨干并将上面的内容拼接到其中(为此,我在typeahead项目中拥有PR)

问题二

就ES而言,我不确定您的映射是否正确,通常您用于预输入项目的映射将如下所示:

{  "settings": {    "analysis": {      "filter": {        "autocomplete_ngram": {          "max_gram": 24,          "min_gram": 2,          "type": "edge_ngram"        }      },      "analyzer": {        "autocomplete_index": {          "filter": [ "lowercase", "autocomplete_ngram"          ],          "tokenizer": "keyword"        },        "autocomplete_search": {          "filter": [ "lowercase"          ],          "tokenizer": "keyword"        }      }    },    "index": {      "number_of_shards": 20,      "number_of_replicas": 1    }  },  "mappings": {    "yourtype": {      "properties": {        "title": {          "type": "multi_field",          "fields": { "title_edgengram": {   "type": "string",   "index": "analyzed",   "index_analyzer": "autocomplete_index",   "search_analyzer": "autocomplete_search" }, "title": {   "type": "string",   "index": "not_analyzed" }          }        }      }    }  }}


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/386960.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号