我的 Elasticsearch 索引有问题。我试图为每一行获取一些字段,但是当我搜索时,弹性不会返回所有字段。如果我尝试通过 id “获取”文档 - 它会返回所有字段
在我的查询中,我尝试使用 _source 字段,但它不起作用 - 查询仅返回来自 _source 的几个字段。
有什么限制吗?限制 _source 字段的数量或大小?
弹性版本 7.1
我的映射:
"video": {
"properties": {
"title": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 128
},
"basic_edge_ngram_analyzer": {
"type": "text",
"analyzer": "basic_edge_ngram_analyzer"
},
"basic_edge_ngram_analyzer_no_digit": {
"type": "text",
"analyzer": "basic_edge_ngram_analyzer_no_digit"
},
"basic_ngram_analyzer": {
"type": "text",
"analyzer": "basic_ngram_analyzer"
},
"basic_ngram_analyzer_no_digit": {
"type": "text",
"analyzer": "basic_ngram_analyzer_no_digit"
},
"numeric_analyzer": {
"type": "text",
"analyzer": "numeric_analyzer"
},
"translit_analyzer": {
"type": "text",
"analyzer": "translit_analyzer"
},
"translit_double_metaphone_analyzer": {
"type": "text",
"analyzer": "translit_double_metaphone_analyzer"
}
}
},
"inverse_title": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 128
},
"basic_edge_ngram_analyzer": {
"type": "text",
"analyzer": "basic_edge_ngram_analyzer"
},
"basic_edge_ngram_analyzer_no_digit": {
"type": "text",
"analyzer": "basic_edge_ngram_analyzer_no_digit"
},
"basic_ngram_analyzer": {
"type": "text",
"analyzer": "basic_ngram_analyzer"
},
"basic_ngram_analyzer_no_digit": {
"type": "text",
"analyzer": "basic_ngram_analyzer_no_digit"
},
"numeric_analyzer": {
"type": "text",
"analyzer": "numeric_analyzer"
},
"translit_analyzer": {
"type": "text",
"analyzer": "translit_analyzer"
},
"translit_double_metaphone_analyzer": {
"type": "text",
"analyzer": "translit_double_metaphone_analyzer"
}
}
},
"thumbnail_url": {
"type": "keyword",
"store": "true"
},
"is_classic": {
"type": "boolean",
"store": "true"
},
"is_club": {
"type": "boolean",
"store": "true"
},
"product_id": {
"type": "integer",
"store": "true"
},
"duration": {
"type": "integer",
"store": "true"
},
"feed_name": {
"type": "keyword",
"store": "true"
},
"feed_url": {
"type": "keyword",
"store": "true"
},
"created_ts": {
"type": "date",
"store": "true"
},
"hot_until": {"type": "date", "format": "date_hour_minute_second_fraction"},
"description": {
"type": "keyword"
},
"mi_tv_id": {"type": "integer"},
"total_views": {"type": "long"},
"month_views": {"type": "long"},
"week_views": {"type": "long"},
"day_views": {"type": "long"},
"blocked_countries": {"type": "keyword"},
"linked_persons": {
"type": "nested",
"properties": {
"id": {"type": "integer"},
"name": {"type": "keyword"}
}
},
"linked_tags": {
"type": "nested",
"properties": {
"id": {"type": "integer"},
"name": {"type": "keyword"}
}
},
"linked_hashtags":{
"type": "nested",
"properties": {
"id": {"type": "integer"},
"name": {"type": "keyword"}
}
},
}
}
我的查询:
GET /video_idx/_search
{
"aggs": {
"mi_tv_id": {
"terms": {
"field": "mi_tv_id",
"size": 10
}
},
"linked_hashtags_id": {
"aggs": {
"linked_hashtags_id": {
"terms": {
"field": "linked_hashtags.id",
"size": 10
}
}
},
"nested": {
"path": "linked_hashtags"
}
},
"author_id": {
"terms": {
"field": "author_id",
"size": 10
}
},
"linked_tags_id": {
"aggs": {
"linked_tags_id": {
"terms": {
"field": "linked_tags.id",
"size": 10
}
}
},
"nested": {
"path": "linked_tags"
}
},
"linked_persons_id": {
"aggs": {
"linked_persons_id": {
"terms": {
"field": "linked_persons.id",
"size": 10
}
}
},
"nested": {
"path": "linked_persons"
}
}
},
"highlight": {
"fields": {
"inverse_title": {
"pre_tags": ["<b>"],
"type": "plain",
"post_tags": ["</b>"]
},
"title": {
"pre_tags": ["<b>"],
"type": "plain",
"post_tags": ["</b>"]
}
}
},
"from": 0,
"size": 20,
"_source": {
"includes":[ "mi_tv_id", "author_id", "hot_until", "id", "linked_persons", "linked_hashtags", "linked_tags", "total_views", "thumbnail_url", "feed_name", "feed_url", "duration", "is_club", "is_classic", "product_id", "created_ts", "title", "inverse_title", "description"]
},
"query": {
"function_score": {
"script_score": {
"script": "\n double total = _score;\n \n if (doc['total_views'].size() > 0) {total = total * Math.log(10 + 0.000087 * doc['total_views'].value)}\n if (doc['month_views'].size() > 0) {total = total * Math.log(10 + 0.00025 * doc['month_views'].value)}\n if (doc['week_views'].size() > 0) {total = total * Math.log(10 + 0.00077 * doc['week_views'].value)}\n if (doc['day_views'].size() > 0) {total = total * Math.log(10 + 0.0025 * doc['day_views'].value)}\n if (doc['hot_until'].size() > 0) {total = 1.5 * total}\n \n if (doc['mi_tv_id'].size() > 0) {total = total * 1.5}\n \n return total \n "
},
"query": {
"bool": {
"minimum_should_match": "20%",
"should": [{
"multi_match": {
"fields": ["title.basic_ngram_analyzer", "inverse_title.basic_ngram_analyzer"],
"operator": "and",
"tie_breaker": 1.0,
"minimum_should_match": "65%",
"type": "cross_fields",
"boost": 5.5,
"query": "\u0434\u043e\u043c 2"
}
}, {
"multi_match": {
"fields": ["title.keyword", "inverse_title.keyword"],
"operator": "and",
"tie_breaker": 1.0,
"minimum_should_match": "100%",
"type": "cross_fields",
"boost": 12.5,
"query": "\u0434\u043e\u043c 2"
}
}, {
"multi_match": {
"fields": ["title.translit_analyzer", "inverse_title.translit_analyzer"],
"operator": "and",
"tie_breaker": 1.0,
"minimum_should_match": "65%",
"type": "cross_fields",
"boost": 3,
"query": "\u0434\u043e\u043c 2"
}
}, {
"multi_match": {
"fields": ["title.numeric_analyzer", "inverse_title.numeric_analyzer"],
"operator": "and",
"tie_breaker": 1.0,
"minimum_should_match": "100%",
"type": "cross_fields",
"boost": 6,
"query": "\u0434\u043e\u043c 2"
}
}, {
"multi_match": {
"fields": ["title.basic_ngram_analyzer_no_digit", "inverse_title.basic_ngram_analyzer_no_digit"],
"operator": "and",
"tie_breaker": 1.0,
"minimum_should_match": "65%",
"type": "cross_fields",
"boost": 5.5,
"query": "\u0434\u043e\u043c 2"
}
}, {
"multi_match": {
"fields": ["title.basic_edge_ngram_analyzer", "inverse_title.basic_edge_ngram_analyzer"],
"operator": "and",
"tie_breaker": 1.0,
"minimum_should_match": "65%",
"type": "cross_fields",
"boost": 5.5,
"query": "\u0434\u043e\u043c 2"
}
}, {
"multi_match": {
"fields": ["title.translit_double_metaphone_analyzer", "inverse_title.translit_double_metaphone_analyzer"],
"operator": "and",
"tie_breaker": 1.0,
"minimum_should_match": "65%",
"type": "cross_fields",
"boost": 1,
"query": "\u0434\u043e\u043c 2"
}
}, {
"multi_match": {
"fields": ["description"],
"operator": "and",
"tie_breaker": 1.0,
"minimum_should_match": "100%",
"type": "cross_fields",
"boost": 1.0,
"query": "\u0434\u043e\u043c 2"
}
}],
"must_not": [{
"terms": {
"blocked_countries": ["RU"]
}
}]
}
}
}
}
}