如何在ElasticSearch中排除索引字段



我正试图利用ElasticSearch来存储大量数据。大多数数据都是可搜索的,然而,也有一些字段会在那里,只是为了存储数据并根据请求返回。

这是我的地图

{
"mappings": {
"properties": {
"amenities": {
"type": "completion"
},
"summary": {
"type": "text"
},
"street_number": {
"type": "text"
},
"street_name": {
"type": "text"
},
"street_suffix": {
"type": "text"
},
"city": {
"type": "text",
"fields": {
"raw": { 
"type":  "keyword"
}
},
"state_or_province": {
"type": "text"
},
"postal_code": {
"type": "text"
},
"mlsid": {
"type": "text"
},
"source_id": {
"type": "text"
},
"status": {
"type": "keyword"
},
"type": {
"type": "keyword"
},
"subtype": {
"type": "keyword"
},
"year_built": {
"type": "short"
},
"community": {
"type": "keyword"
},
"elementary_school": {
"type": "keyword"
},
"middle_school": {
"type": "keyword"
},
"jr_high_school": {
"type": "keyword"
},
"high_school": {
"type": "keyword"
},
"area_size": {
"type": "double"
},
"lot_size": {
"type": "double"
},
"bathrooms": {
"type": "double"
},
"bedrooms": {
"type": "double"
},
"listed_at": {
"type": "date"
},
"price": {
"type": "double"
},
"sold_at": {
"type": "date"
},
"sold_for": {
"type": "double"
},
"total_photos": {
"type": "short"
},
"formatted_addressLine": {
"type": "text"
},
"formatted_address": {
"type": "text"
},
"location": {
"type": "geo_point"
},
"price_changes": {
"type": "object"
},
"fields": {
"type": "object"
},
"deleted_at": {
"type": "date"
},
"is_available": {
"type": "boolean"
},
"is_unable_to_find_coordinates": {
"type": "boolean"
},
"source": {
"type": "keyword"
}
}
}
}

fieldsprice_changes属性在那里,以防用户想要读取该信息。但这些信息不应该被搜索或索引。fields保存key-value对的大列表,而price_changes字段保存相同类型的多个对象。

目前,当我尝试批量创建记录时,我会收到Limit of total fields [1000] has been exceeded错误。我猜发生这个错误是因为fields集合中的每个键值对都被认为是弹性搜索中的一个字段。

如何将fieldsprice_changes对象存储为不可搜索的数据,而不对其进行索引或将其计入字段计数?

您可以在字段级别使用enabled属性来存储字段,而无需对其进行索引。在此处阅读https://www.elastic.co/guide/en/elasticsearch/reference/current/enabled.html

"price_changes": { 
"type": "object",
"enabled": false
}

注意:您是否能够使用问题中给出的映射创建索引?它在"处给了我语法错误(Duplicate key(;类型";领域我想你漏掉了";城市;领域

最新更新