我看过这篇文章:https://www.elastic.co/blog/you-complete-me 但是,它需要在客户端编写一些逻辑来创建多个"输入".有没有办法定义一个分析器(可能使用shingle或ngram/edge-ngram)来生成多个输入项?
这是我尝试过的(显然不起作用):
DELETE /products/
PUT /products/
{
"settings": {
"analysis": {
"filter": {
"autocomplete_filter": {
"type":"shingle",
"max_shingle_size":5,
"min_shingle_size":2
}
},
"analyzer": {
"autocomplete": {
"filter": [
"lowercase",
"autocomplete_filter"
],
"tokenizer": "standard"
}
}
}
},
"mappings": {
"product": {
"properties": {
"name": {"type": "string"
,"copy_to": ["name_suggest"]
}
,"name_suggest": {
"type": "completion",
"payloads": false,
"analyzer": "autocomplete"
}
}
}
}
}
PUT /products/product/1
{
"name": "Apple iPhone 5"
}
PUT /products/product/2
{
"name": "iPhone 4 16GB"
} …Run Code Online (Sandbox Code Playgroud) 我的网站是单页webapp.我正在使用我的实验ID加载实验代码:
<script src="//www.google-analytics.com/cx/api.js?experiment={@ js_settings.analytics.experimentid @}"></script>
Run Code Online (Sandbox Code Playgroud)
加载完毕后,在我显示页面的那一刻,我通过调用执行以下操作的函数选择正确的模板:
ga('set', 'expId', experiment_id);
var variation = cxApi.getChosenVariation(experiment_id) || cxApi.chooseVariation();
cxApi.setChosenVariation(variation, experiment_id);
ga('set', 'expVar', variation);
ga('set', 'dimension1', variation);
ga('send', 'pageview');
Run Code Online (Sandbox Code Playgroud)
现在,似乎cxApi.chooseVariation()总是返回0.到目前为止,205个会话中的100%被赋予默认变体(0).为什么?
autocomplete ×1