Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
| Beide Seiten der vorigen Revision Vorhergehende Überarbeitung Nächste Überarbeitung | Vorhergehende Überarbeitung | ||
|
opensearch [2025/03/25 01:06] jango |
opensearch [2025/03/27 11:49] (aktuell) jango |
||
|---|---|---|---|
| Zeile 1: | Zeile 1: | ||
| + | Siehe auch [[ElasticSearch]] (z.B Scripte, API, etc. sind identisch). [[Wazuh]] verwendet [[OpenSearch]]. | ||
| + | |||
| =====Installation===== | =====Installation===== | ||
| Zeile 71: | Zeile 73: | ||
| } | } | ||
| client.index(index=" | client.index(index=" | ||
| + | </ | ||
| + | |||
| + | More data in a bulk | ||
| + | |||
| + | <code python> | ||
| + | from opensearchpy.helpers import bulk | ||
| + | |||
| + | bulk_data = [] | ||
| + | for i,row in df.iterrows(): | ||
| + | bulk_data.append( | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | } | ||
| + | } | ||
| + | ) | ||
| + | bulk(client, | ||
| + | </ | ||
| + | |||
| + | Count the inserted data | ||
| + | |||
| + | <code python> | ||
| + | client.indices.refresh(index=" | ||
| + | client.cat.count(index=" | ||
| + | </ | ||
| + | |||
| + | Search the data | ||
| + | |||
| + | <code python> | ||
| + | resp = client.search( | ||
| + | index=" | ||
| + | body={ | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | } | ||
| + | }, | ||
| + | " | ||
| + | }, | ||
| + | }, | ||
| + | } | ||
| + | ) | ||
| + | resp | ||
| + | </ | ||
| + | |||
| + | Remove documents | ||
| + | <code python> | ||
| + | client.delete(index=" | ||
| + | </ | ||
| + | |||
| + | Delete the index | ||
| + | <code python> | ||
| + | client.indices.delete(index=' | ||
| </ | </ | ||