[英]How to remove extra fields from ElasticSearch response
嗨,我是ElasticSearch的新手,我正努力從ElasticSearch的響應中刪除所有多余的字段。 請參見以下回復:
"report": {
"unique_users": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": 1234,
"doc_count": 2,
"user_details": {
"hits": {
"total": 2,
"max_score": 1.4E-45,
"hits": [
{
"_index": "orders-test",
"_type": "order",
"_id": "2",
"_score": 0.0,
"_source": {
"customer_email": "reba_dickens@blick.name",
"customer_phone": "476.824.4998 x498",
"customer_name": "Mohammed Abernathy"
}
}
]
}
}
},
{
"key": 5678,
"doc_count": 1,
"user_details": {
"hits": {
"total": 1,
"max_score": 1.4E-45,
"hits": [
{
"_index": "orders-test",
"_type": "order",
"_id": "1",
"_score": 0.0,
"_source": {
"customer_email": "yolanda.batz@ruel.biz",
"customer_phone": "1-715-183-8343 x026",
"customer_name": "Richie Tillman II"
}
}
]
}
}
}
]
}
}
在上方,您可以看到響應中還包含其他一些字段,例如_index,_type,_score,max_score等。我已經按照ElasticSearch response_filtering指南刪除了這些字段,但是對我來說不起作用。 我還已將filter_path參數傳遞給請求0.0.0.0:5000/v4/reports/user.json?filter_path=unique_users,unique_users.user_details.hits.hits._source,但沒有得到任何響應。 我正在使用以下功能來處理Elasticsearch查詢。
def query(options = {})
aggregations = {}
buckets = {}
buckets_for_unique_users buckets, aggregations
buckets_for_new_users buckets, aggregations
buckets_for_high_rollers buckets, aggregations
filters = []
filters << time_filter(options)
filters << restaurant_filter(options) if options[:restaurant_id]
filters << channel_filter(options) if options[:channel_id]
query = {
query: { bool: { filter: filters } },
aggregations: buckets
}
query
end
任何人都可以讓我知道我做錯了什么。
在請求中使用“ _source”和所需的屬性。 這將幫助您僅獲取指定的字段。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.