为什么 DSL 的查询字符串搜索得分为 1.0
Why DSL is giving score of 1.0 for query string search
我在一个索引中有数据
下面是前3个文件,我有111个文件。我只削减前 3 个
q = {"size":3,"query":{ "match_all":{}}}
{'took': 1, 'timed_out': False, '_shards': {'total': 1, 'successful': 1, 'skipped': 0, 'failed': 0}, 'hits': {'total': {'value': 111, 'relation': 'eq'}, 'max_score': 1.0, 'hits': [{'_index': 'movie_data_01_03', '_type': '_doc', '_id': '0', '_score': 1.0, '_source': {'id': 0, 'Title': 'The Land Girls', 'US Gross': 146083, 'Worldwide Gross': 146083, 'US DVD Sales': None, 'Production Budget': 8000000, 'Release Date': 'Jun 12 1998', 'MPAA Rating': 'R', 'Running Time min': None, 'Distributor': 'Gramercy', 'Source': None, 'Major Genre': None, 'Creative Type': None, 'Director': None, 'Rotten Tomatoes Rating': None, 'IMDB Rating': 6.1, 'IMDB Votes': 1071}}, {'_index': 'movie_data_01_03', '_type': '_doc', '_id': '1', '_score': 1.0, '_source': {'id': 1, 'Title': 'First Love, Last Rites', 'US Gross': 10876, 'Worldwide Gross': 10876, 'US DVD Sales': None, 'Production Budget': 300000, 'Release Date': 'Aug 07 1998', 'MPAA Rating': 'R', 'Running Time min': None, 'Distributor': 'Strand', 'Source': None, 'Major Genre': 'Drama', 'Creative Type': None, 'Director': None, 'Rotten Tomatoes Rating': None, 'IMDB Rating': 6.9, 'IMDB Votes': 207}}, {'_index': 'movie_data_01_03', '_type': '_doc', '_id': '2', '_score': 1.0, '_source': {'id': 2, 'Title': 'I Married a Strange Person', 'US Gross': 203134, 'Worldwide Gross': 203134, 'US DVD Sales': None, 'Production Budget': 250000, 'Release Date': 'Aug 28 1998', 'MPAA Rating': None, 'Running Time min': None, 'Distributor': 'Lionsgate', 'Source': None, 'Major Genre': 'Comedy', 'Creative Type': None, 'Director': None, 'Rotten Tomatoes Rating': None, 'IMDB Rating': 6.8, 'IMDB Votes': 865}}]}}
下面的查询是否为每个文档提供 _score 1.0?为什么
我正在 elasticsearch 中搜索 Live
query = {'from': 0, 'size': 30, 'query': {'bool': {'must': {'query_string': {'query': '**Live**'}}}}}
我的输出如下
{'took': 23, 'timed_out': False, '_shards': {'total': 1, 'successful': 1, 'skipped': 0, 'failed': 0}, 'hits': {'total': {'value': 3, 'relation': 'eq'}, 'max_score': 1.0, 'hits': [{'_index': 'movie_data_01_03', '_type': '_doc', '_id': '11', '_score': 1.0, '_source': {'id': 11, 'Title': 'Oliver!', 'US Gross': 37402877, 'Worldwide Gross': 37402877, 'US DVD Sales': None, 'Production Budget': 10000000, 'Release Date': 'Dec 11 1968', 'MPAA Rating': None, 'Running Time min': None, 'Distributor': 'Sony Pictures', 'Source': None, 'Major Genre': 'Musical', 'Creative Type': None, 'Director': None, 'Rotten Tomatoes Rating': 84, 'IMDB Rating': 7.5, 'IMDB Votes': 9111}}, {'_index': 'movie_data_01_03', '_type': '_doc', '_id': '52', '_score': 1.0, '_source': {'id': 52, 'Title': 'Alive', 'US Gross': 36299670, 'Worldwide Gross': 36299670, 'US DVD Sales': None, 'Production Budget': 32000000, 'Release Date': 'Jan 15 1993', 'MPAA Rating': 'R', 'Running Time min': None, 'Distributor': 'Walt Disney Pictures', 'Source': 'Based on Book/Short Story', 'Major Genre': 'Adventure', 'Creative Type': 'Dramatization', 'Director': 'Frank Marshall', 'Rotten Tomatoes Rating': 71, 'IMDB Rating': 3.2, 'IMDB Votes': 124}}, {'_index': 'movie_data_01_03', '_type': '_doc', '_id': '90', '_score': 1.0, '_source': {'id': 90, 'Title': 'The Best Years of Our Lives', 'US Gross': 23600000, 'Worldwide Gross': 23600000, 'US DVD Sales': None, 'Production Budget': 2100000, 'Release Date': 'Nov 21 2046', 'MPAA Rating': None, 'Running Time min': None, 'Distributor': 'RKO Radio Pictures', 'Source': 'Based on Book/Short Story', 'Major Genre': 'Drama', 'Creative Type': None, 'Director': 'William Wyler', 'Rotten Tomatoes Rating': 97, 'IMDB Rating': 8.2, 'IMDB Votes': 17338}}]}}
当您搜索 **Live**
(即进行通配符搜索)时,默认情况下会应用常量分数,因此您得到的分数为 1.0
您需要添加 rewrite parameter,这将决定相关性得分的计算方式。将您的搜索查询修改为
{
"from": 0,
"size": 30,
"query": {
"bool": {
"must": {
"query_string": {
"query": "**live**",
"rewrite": "scoring_boolean"
}
}
}
}
}
搜索结果将是
"hits": [
{
"_index": "66684902",
"_type": "_doc",
"_id": "1",
"_score": 1.3177552,
"_source": {
"id": 11,
"Title": "Oliver!",
"US Gross": 37402877,
"Worldwide Gross": 37402877,
"US DVD Sales": "None",
"Production Budget": 10000000,
"Release Date": "Dec 11 1968",
"MPAA Rating": "None",
"Running Time min": "None",
"Distributor": "Sony Pictures",
"Source": "None",
"Major Genre": "Musical",
"Creative Type": "None",
"Director": "None",
"Rotten Tomatoes Rating": 84,
"IMDB Rating": 7.5,
"IMDB Votes": 9111
}
},
{
"_index": "66684902",
"_type": "_doc",
"_id": "2",
"_score": 1.3177552,
"_source": {
"id": 52,
"Title": "Alive",
"US Gross": 36299670,
"Worldwide Gross": 36299670,
"US DVD Sales": "None",
"Production Budget": 32000000,
"Release Date": "Jan 15 1993",
"MPAA Rating": "R",
"Running Time min": "None",
"Distributor": "Walt Disney Pictures",
"Source": "Based on Book/Short Story",
"Major Genre": "Adventure",
"Creative Type": "Dramatization",
"Director": "Frank Marshall",
"Rotten Tomatoes Rating": 71,
"IMDB Rating": 3.2,
"IMDB Votes": 124
}
},
{
"_index": "66684902",
"_type": "_doc",
"_id": "3",
"_score": 0.64896965,
"_source": {
"id": 90,
"Title": "The Best Years of Our Lives",
"US Gross": 23600000,
"Worldwide Gross": 23600000,
"US DVD Sales": "None",
"Production Budget": 2100000,
"Release Date": "Nov 21 2046",
"MPAA Rating": "None",
"Running Time min": "None",
"Distributor": "RKO Radio Pictures",
"Source": "Based on Book/Short Story",
"Major Genre": "Drama",
"Creative Type": "None",
"Director": "William Wyler",
"Rotten Tomatoes Rating": 97,
"IMDB Rating": 8.2,
"IMDB Votes": 17338
}
}
]
我在一个索引中有数据
下面是前3个文件,我有111个文件。我只削减前 3 个
q = {"size":3,"query":{ "match_all":{}}}
{'took': 1, 'timed_out': False, '_shards': {'total': 1, 'successful': 1, 'skipped': 0, 'failed': 0}, 'hits': {'total': {'value': 111, 'relation': 'eq'}, 'max_score': 1.0, 'hits': [{'_index': 'movie_data_01_03', '_type': '_doc', '_id': '0', '_score': 1.0, '_source': {'id': 0, 'Title': 'The Land Girls', 'US Gross': 146083, 'Worldwide Gross': 146083, 'US DVD Sales': None, 'Production Budget': 8000000, 'Release Date': 'Jun 12 1998', 'MPAA Rating': 'R', 'Running Time min': None, 'Distributor': 'Gramercy', 'Source': None, 'Major Genre': None, 'Creative Type': None, 'Director': None, 'Rotten Tomatoes Rating': None, 'IMDB Rating': 6.1, 'IMDB Votes': 1071}}, {'_index': 'movie_data_01_03', '_type': '_doc', '_id': '1', '_score': 1.0, '_source': {'id': 1, 'Title': 'First Love, Last Rites', 'US Gross': 10876, 'Worldwide Gross': 10876, 'US DVD Sales': None, 'Production Budget': 300000, 'Release Date': 'Aug 07 1998', 'MPAA Rating': 'R', 'Running Time min': None, 'Distributor': 'Strand', 'Source': None, 'Major Genre': 'Drama', 'Creative Type': None, 'Director': None, 'Rotten Tomatoes Rating': None, 'IMDB Rating': 6.9, 'IMDB Votes': 207}}, {'_index': 'movie_data_01_03', '_type': '_doc', '_id': '2', '_score': 1.0, '_source': {'id': 2, 'Title': 'I Married a Strange Person', 'US Gross': 203134, 'Worldwide Gross': 203134, 'US DVD Sales': None, 'Production Budget': 250000, 'Release Date': 'Aug 28 1998', 'MPAA Rating': None, 'Running Time min': None, 'Distributor': 'Lionsgate', 'Source': None, 'Major Genre': 'Comedy', 'Creative Type': None, 'Director': None, 'Rotten Tomatoes Rating': None, 'IMDB Rating': 6.8, 'IMDB Votes': 865}}]}}
下面的查询是否为每个文档提供 _score 1.0?为什么
我正在 elasticsearch 中搜索 Live
query = {'from': 0, 'size': 30, 'query': {'bool': {'must': {'query_string': {'query': '**Live**'}}}}}
我的输出如下
{'took': 23, 'timed_out': False, '_shards': {'total': 1, 'successful': 1, 'skipped': 0, 'failed': 0}, 'hits': {'total': {'value': 3, 'relation': 'eq'}, 'max_score': 1.0, 'hits': [{'_index': 'movie_data_01_03', '_type': '_doc', '_id': '11', '_score': 1.0, '_source': {'id': 11, 'Title': 'Oliver!', 'US Gross': 37402877, 'Worldwide Gross': 37402877, 'US DVD Sales': None, 'Production Budget': 10000000, 'Release Date': 'Dec 11 1968', 'MPAA Rating': None, 'Running Time min': None, 'Distributor': 'Sony Pictures', 'Source': None, 'Major Genre': 'Musical', 'Creative Type': None, 'Director': None, 'Rotten Tomatoes Rating': 84, 'IMDB Rating': 7.5, 'IMDB Votes': 9111}}, {'_index': 'movie_data_01_03', '_type': '_doc', '_id': '52', '_score': 1.0, '_source': {'id': 52, 'Title': 'Alive', 'US Gross': 36299670, 'Worldwide Gross': 36299670, 'US DVD Sales': None, 'Production Budget': 32000000, 'Release Date': 'Jan 15 1993', 'MPAA Rating': 'R', 'Running Time min': None, 'Distributor': 'Walt Disney Pictures', 'Source': 'Based on Book/Short Story', 'Major Genre': 'Adventure', 'Creative Type': 'Dramatization', 'Director': 'Frank Marshall', 'Rotten Tomatoes Rating': 71, 'IMDB Rating': 3.2, 'IMDB Votes': 124}}, {'_index': 'movie_data_01_03', '_type': '_doc', '_id': '90', '_score': 1.0, '_source': {'id': 90, 'Title': 'The Best Years of Our Lives', 'US Gross': 23600000, 'Worldwide Gross': 23600000, 'US DVD Sales': None, 'Production Budget': 2100000, 'Release Date': 'Nov 21 2046', 'MPAA Rating': None, 'Running Time min': None, 'Distributor': 'RKO Radio Pictures', 'Source': 'Based on Book/Short Story', 'Major Genre': 'Drama', 'Creative Type': None, 'Director': 'William Wyler', 'Rotten Tomatoes Rating': 97, 'IMDB Rating': 8.2, 'IMDB Votes': 17338}}]}}
当您搜索 **Live**
(即进行通配符搜索)时,默认情况下会应用常量分数,因此您得到的分数为 1.0
您需要添加 rewrite parameter,这将决定相关性得分的计算方式。将您的搜索查询修改为
{
"from": 0,
"size": 30,
"query": {
"bool": {
"must": {
"query_string": {
"query": "**live**",
"rewrite": "scoring_boolean"
}
}
}
}
}
搜索结果将是
"hits": [
{
"_index": "66684902",
"_type": "_doc",
"_id": "1",
"_score": 1.3177552,
"_source": {
"id": 11,
"Title": "Oliver!",
"US Gross": 37402877,
"Worldwide Gross": 37402877,
"US DVD Sales": "None",
"Production Budget": 10000000,
"Release Date": "Dec 11 1968",
"MPAA Rating": "None",
"Running Time min": "None",
"Distributor": "Sony Pictures",
"Source": "None",
"Major Genre": "Musical",
"Creative Type": "None",
"Director": "None",
"Rotten Tomatoes Rating": 84,
"IMDB Rating": 7.5,
"IMDB Votes": 9111
}
},
{
"_index": "66684902",
"_type": "_doc",
"_id": "2",
"_score": 1.3177552,
"_source": {
"id": 52,
"Title": "Alive",
"US Gross": 36299670,
"Worldwide Gross": 36299670,
"US DVD Sales": "None",
"Production Budget": 32000000,
"Release Date": "Jan 15 1993",
"MPAA Rating": "R",
"Running Time min": "None",
"Distributor": "Walt Disney Pictures",
"Source": "Based on Book/Short Story",
"Major Genre": "Adventure",
"Creative Type": "Dramatization",
"Director": "Frank Marshall",
"Rotten Tomatoes Rating": 71,
"IMDB Rating": 3.2,
"IMDB Votes": 124
}
},
{
"_index": "66684902",
"_type": "_doc",
"_id": "3",
"_score": 0.64896965,
"_source": {
"id": 90,
"Title": "The Best Years of Our Lives",
"US Gross": 23600000,
"Worldwide Gross": 23600000,
"US DVD Sales": "None",
"Production Budget": 2100000,
"Release Date": "Nov 21 2046",
"MPAA Rating": "None",
"Running Time min": "None",
"Distributor": "RKO Radio Pictures",
"Source": "Based on Book/Short Story",
"Major Genre": "Drama",
"Creative Type": "None",
"Director": "William Wyler",
"Rotten Tomatoes Rating": 97,
"IMDB Rating": 8.2,
"IMDB Votes": 17338
}
}
]