我想知道这是否是展示和讨论我的用例的正确位置。如果没有,请帮我将这个问题重定向到其他地方。
我在社交媒体网站上使用ES 5.2作为我们的搜索功能(看起来像youtube)。而且我很难找到如何搜索带有剧集编号的视频。 例如:
$ag-icons-path: '~ag-grid/src/styles/icons/';
$ag-mat-icons-path: '~ag-grid/src/styles/material-icons/';
// Change the primary / accent colors
$primary-color: red;
$accent-color: green;
@import '~ag-grid/src/styles/ag-grid.scss';
@import '~ag-grid/src/styles/ag-theme-material.scss';
虽然我用剧集编号更改了关键字搜索,但我总是得到相同的结果。
{"id": "1","title": "Four Beautyful Sun Flower - Episode 01"}
{"id": "2","title": "Four Beautyful Sun Flower - Episode 15"}
{"id": "3","title": "Four Beautyful Sun Flower - Episode 17"}
{"id": "4","title": "Four Beautyful Sun Flower - Episode 23"}
{"id": "5","title": "Sun Flower In Morning - Episode 01"}
{"id": "6","title": "Sun Flower In Morning - Episode 15"}
{"id": "7","title": "Sun Flower In Morning - Episode 17"}
{"id": "8","title": "Sun Flower In Morning - Episode 23"}
这是我得到的结果
{ "query": {
"match": {
"title": "Four Beautyful Sun Flower Episode 17"
} } }
我希望这一集会出现在第一集中。但结果始终是相同的顺序。除此之外,我只想获得四个美丽的太阳花电影,但结果显示机器人四美丽的太阳花和早晨的太阳花。 有人可以帮我怎么做这样的搜索。我尝试了ES页面文档中的所有建议,但仍无法正常工作。
这是重现此案例的bash脚本。
"hits": {
"total": 8,
"max_score": 3.5898633,
"hits": [
{
"_index": "test_file",
"_type": "sample",
"_id": "1",
"_score": 3.5898633,
"_source": {
"id": "1",
"title": "Four Beautyful Sun Flower - Episode 01"
}
},
{
"_index": "test_file",
"_type": "sample",
"_id": "3",
"_score": 2.6694531,
"_source": {
"id": "3",
"title": "Four Beautyful Sun Flower - Episode 17"
}
},
{
"_index": "test_file",
"_type": "sample",
"_id": "2",
"_score": 2.4949138,
"_source": {
"id": "2",
"title": "Four Beautyful Sun Flower - Episode 15"
}
},
{
"_index": "test_file",
"_type": "sample",
"_id": "4",
"_score": 2.4949138,
"_source": {
"id": "4",
"title": "Four Beautyful Sun Flower - Episode 23"
}
},
{
"_index": "test_file",
"_type": "sample",
"_id": "7",
"_score": 1.0144347,
"_source": {
"id": "7",
"title": "Sun Flower In Morning - Episode 17"
}
},
{
"_index": "test_file",
"_type": "sample",
"_id": "5",
"_score": 1.0068512,
"_source": {
"id": "5",
"title": "Sun Flower In Morning - Episode 01"
}
},
{
"_index": "test_file",
"_type": "sample",
"_id": "8",
"_score": 1.0068512,
"_source": {
"id": "8",
"title": "Sun Flower In Morning - Episode 23"
}
},
{
"_index": "test_file",
"_type": "sample",
"_id": "6",
"_score": 0.7445657,
"_source": {
"id": "6",
"title": "Sun Flower In Morning - Episode 15"
}
}
]
}
非常感谢您的时间。
答案 0 :(得分:0)
您正在使用带有"min_gram": 3
的edge-ngram过滤器。这意味着将忽略任何小于3的令牌。如果您浏览分析链,则首先使用"Four Beautyful Sun Flower Episode 17"
标记生成器将查询standard
拆分为标记。这会产生
Four
Beautyful
Sun
Flower
Episode
17
接下来应用小写过滤器,产生以下标记:
four
beautyful
sun
flower
episode
17
接下来是autocomplete_filter
,它运行在上述每个标记上。由于17
小于3个字符,因此将其忽略。
如果您将min_gram更改为2 "min_gram": 2
,您将获得正确的结果!
{
"took": 7,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"failed": 0
},
"hits": {
"total": 8,
"max_score": 4.818736,
"hits": [
{
"_index": "test_1",
"_type": "sample",
"_id": "3",
"_score": 4.818736,
"_source": {
"id": "3",
"title": "Four Beautyful Sun Flower - Episode 17"
}
},
{
"_index": "test_1",
"_type": "sample",
"_id": "1",
"_score": 3.033192,
"_source": {
"id": "1",
"title": "Four Beautyful Sun Flower - Episode 01"
}
},
{
"_index": "test_1",
"_type": "sample",
"_id": "2",
"_score": 3.033192,
"_source": {
"id": "2",
"title": "Four Beautyful Sun Flower - Episode 15"
}
},
{
"_index": "test_1",
"_type": "sample",
"_id": "4",
"_score": 3.033192,
"_source": {
"id": "4",
"title": "Four Beautyful Sun Flower - Episode 23"
}
},
{
"_index": "test_1",
"_type": "sample",
"_id": "7",
"_score": 2.118117,
"_source": {
"id": "7",
"title": "Sun Flower In Morning - Episode 17"
}
},
{
"_index": "test_1",
"_type": "sample",
"_id": "5",
"_score": 0.33257294,
"_source": {
"id": "5",
"title": "Sun Flower In Morning - Episode 01"
}
},
{
"_index": "test_1",
"_type": "sample",
"_id": "6",
"_score": 0.33257294,
"_source": {
"id": "6",
"title": "Sun Flower In Morning - Episode 15"
}
},
{
"_index": "test_1",
"_type": "sample",
"_id": "8",
"_score": 0.33257294,
"_source": {
"id": "8",
"title": "Sun Flower In Morning - Episode 23"
}
}
]
}
}