This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Install the required packages | |
## pip install -qU elasticsearch openai | |
import os | |
from elasticsearch import Elasticsearch | |
from openai import OpenAI | |
es_client = Elasticsearch( | |
"undefined", | |
api_key=os.environ["ES_API_KEY"] | |
) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 1) Pull all records from index named fedeastsql | |
POST /_xpack/sql?format=txt | |
{ | |
"query": "SELECT * FROM fedeastsql" | |
} | |
## 2) List all columns and datatype of this index |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PUT my_index | |
{ | |
"mappings": { | |
"properties": { | |
"securityTags": { | |
"type": "keyword", | |
"fields": { | |
"length": { | |
"type": "token_count", | |
"analyzer": "standard" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
import json | |
def prettyPrint(doc): | |
print(json.dumps(doc, indent=4, sort_keys=True)) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"bool": { | |
"should": [ | |
[ | |
{ | |
"bool": { | |
"must": [ | |
[ | |
{ | |
"term": { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/python3 | |
import json | |
import moment | |
from elasticsearch import helpers | |
from elasticsearch import Elasticsearch | |
esConnString = 'http://elastic:changeme@localhost:9200' | |
esTo = Elasticsearch([esConnString],request_timeout=100) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### EXAMPLE SEARCH: Has Spotify run in the last 30 seconds? | |
GET /topbeat-*/_search | |
{ | |
"query": { | |
"bool": { | |
"must": [ | |
{"term": { | |
"proc.name": { | |
"value": "Spotify" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script src="../dist/aframe.min.js"></script> | |
<script> | |
AFRAME.registerComponent('spectator',{ | |
'schema': { | |
canvas: { | |
type: 'string', | |
default: '' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Example of pulling data from DC Capital bikeshare to Elasticsearch in real time | |
## HTTP Poller -> XML Splitting -> Elasticsearch | |
input { | |
## pull data from Capital Bikeshare every 60 seconds | |
http_poller { | |
urls => { | |
bikeshare_dc => "https://www.capitalbikeshare.com/data/stations/bikeStations.xml" | |
} | |
request_timeout => 30 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DELETE /foo | |
PUT /foo | |
{ | |
"settings": { | |
"number_of_replicas": 0, | |
"number_of_shards": 1 | |
}, | |
"mappings": { | |
"people": { |
NewerOlder