簡體   English   中英

如何從 elasticsearch 中的特定索引中獲取數據?

[英]How can i fetch data from a particular index in elasticsearch?

當我試圖獲取數據時,我得到的只是一些無用的信息,如數據類型等。如何獲取存儲在索引中的真實數據。

{"rpa-trans-2020.02.26":{"aliases":{},"mappings":{"rpa-trans":{"dynamic":"true","properties":{"@timestamp":{"type":"date"},"@version":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"AreaImpacted":{"type":"keyword"},"AssigneeUserId":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"CreatedByUserId":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"CrossReferenceId":{"type":"keyword"},"EntityName":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"ErrorCode":{"type":"keyword"},"ErrorDescription":{"type":"keyword"},"FailureTransaction":{"type":"integer"},"Initiator":{"type":"keyword"},"InstanceId":{"type":"integer"},"IsApplication":{"type":"keyword"},"ListenerReqEndTime":{"type":"long"},"ListenerReqStartTime":{"type":"long"},"NotQualifiedRequest":{"type":"integer"},"Param1":{"type":"float"},"Param2":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"Param3":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"Param4":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"ProcessName":{"type":"keyword"},"Processes":{"type":"keyword"},"QualifiedRequest":{"type":"integer"},"RetryTrans":{"properties":{"ReasonRequestUnsuccessful":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"RetryAttemptNumber":{"type":"long"},"RetryReason":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}}}},"RobotReqEndTime":{"type":"long"},"RobotReqStartTime":{"type":"long"},"Robots":{"type":"keyword"},"SearchInput":{"type":"keyword"},"SourceApplicationId":{"type":"keyword"},"SourceMachineId":{"type":"keyword"},"StepDescription":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"StepEndTime":{"type":"date"},"StepStartTime":{"type":"date"},"StepStatus":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"SuccessfulTransaction":{"type":"integer"},"TransactionDateTime":{"type":"date","format":"yyyy-MM-dd'T'HH:mm:ss.SSSZZ"},"TransactionEndTime":{"type":"date"},"TransactionId":{"type":"keyword"},"TransactionMessage":{"type":"keyword"},"TransactionProcessName":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"TransactionProfileName":{"type":"keyword"},"TransactionSource":{"type":"keyword"},"TransactionState":{"type":"keyword"},"TransactionStatus":{"type":"keyword"},"TransactionTitle":{"type":"keyword"},"TransactionType":{"type":"keyword"},"UserId":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"elapsed_execution_time":{"type":"float"},"elapsed_execution_time  ":{"type":"float"},"elapsed_handle_time":{"type":"float"},"elapsed_qualification_time":{"type":"float"},"elapsed_qualification_time ":{"type":"float"},"elapsed_timestamp_start":{"type":"date"},"elapsed_wait_time":{"type":"float"},"manual_proc_time":{"type":"integer"},"process_sla":{"type":"integer"},"tags":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"transactions":{"type":"long"},"type":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}}}}},"settings":{"index":{"number_of_shards":"1","provided_name":"rpa-trans-2020.02.26","creation_date":"1582703183260","requests":{"cache":{"enable":"false"}},"number_of_replicas":"0","uuid":"WslG0Q-YT323WZxNuw_sWw","version":{"created":"5050299"}}}},

如果您使用該代碼,則可以執行 the_data["rpa-trans-2020.02.26"]["mappings"] 之類的操作

the_data = {"rpa-trans-2020.02.26":{"aliases":{},"mappings":{"rpa-trans":{"dynamic":"true","properties":{"@timestamp":{"type":"date"},"@version":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"AreaImpacted":{"type":"keyword"},"AssigneeUserId":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"CreatedByUserId":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"CrossReferenceId":{"type":"keyword"},"EntityName":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"ErrorCode":{"type":"keyword"},"ErrorDescription":{"type":"keyword"},"FailureTransaction":{"type":"integer"},"Initiator":{"type":"keyword"},"InstanceId":{"type":"integer"},"IsApplication":{"type":"keyword"},"ListenerReqEndTime":{"type":"long"},"ListenerReqStartTime":{"type":"long"},"NotQualifiedRequest":{"type":"integer"},"Param1":{"type":"float"},"Param2":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"Param3":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"Param4":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"ProcessName":{"type":"keyword"},"Processes":{"type":"keyword"},"QualifiedRequest":{"type":"integer"},"RetryTrans":{"properties":{"ReasonRequestUnsuccessful":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"RetryAttemptNumber":{"type":"long"},"RetryReason":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}}}},"RobotReqEndTime":{"type":"long"},"RobotReqStartTime":{"type":"long"},"Robots":{"type":"keyword"},"SearchInput":{"type":"keyword"},"SourceApplicationId":{"type":"keyword"},"SourceMachineId":{"type":"keyword"},"StepDescription":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"StepEndTime":{"type":"date"},"StepStartTime":{"type":"date"},"StepStatus":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"SuccessfulTransaction":{"type":"integer"},"TransactionDateTime":{"type":"date","format":"yyyy-MM-dd'T'HH:mm:ss.SSSZZ"},"TransactionEndTime":{"type":"date"},"TransactionId":{"type":"keyword"},"TransactionMessage":{"type":"keyword"},"TransactionProcessName":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"TransactionProfileName":{"type":"keyword"},"TransactionSource":{"type":"keyword"},"TransactionState":{"type":"keyword"},"TransactionStatus":{"type":"keyword"},"TransactionTitle":{"type":"keyword"},"TransactionType":{"type":"keyword"},"UserId":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"elapsed_execution_time":{"type":"float"},"elapsed_execution_time  ":{"type":"float"},"elapsed_handle_time":{"type":"float"},"elapsed_qualification_time":{"type":"float"},"elapsed_qualification_time ":{"type":"float"},"elapsed_timestamp_start":{"type":"date"},"elapsed_wait_time":{"type":"float"},"manual_proc_time":{"type":"integer"},"process_sla":{"type":"integer"},"tags":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"transactions":{"type":"long"},"type":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}}}}},"settings":{"index":{"number_of_shards":"1","provided_name":"rpa-trans-2020.02.26","creation_date":"1582703183260","requests":{"cache":{"enable":"false"}},"number_of_replicas":"0","uuid":"WslG0Q-YT323WZxNuw_sWw","version":{"created":"5050299"}}}}}

看起來您正在嘗試以GET myindex格式發出請求。 這將為您提供索引的映射和設置。

要讀取您的數據,請求應類似於GET myindex/_search查詢數據的方法有很多種,您可以閱讀適合您查詢要求的文檔。

https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl.html

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM