Skip to content

Instantly share code, notes, and snippets.

View xeraa's full-sized avatar
🎩
DevRel

Philipp Krenn xeraa

🎩
DevRel
View GitHub Profile
@xeraa
xeraa / beckrock-semantic_text.json
Created February 2, 2025 01:56
Getting started with semantic_text on AWS Bedrock
GET /
PUT starwars
{
"settings": {
"analysis": {
"analyzer": {
"my_analyzer": {
"char_filter": [
"html_strip"
@xeraa
xeraa / 0_shell.sh
Last active November 22, 2024 21:36
Elasticsearch ❤️ Ollama
ollama run llama3.2:1b
curl http://localhost:11434/v1/models --silent | jq
curl http://localhost:11434/v1/embeddings --silent --json '{ "model": "llama3.2:1b", "input": ["You Know, for Search"] }' | jq
curl -fsSL https://elastic.co/start-local | sh
@xeraa
xeraa / nested-metadata.json
Last active July 13, 2024 00:11
Include metadata with dense vector chunks in Elasticsearch
PUT audio
{
"mappings": {
"properties": {
"my_long_content": {
"type": "nested", //because there can be multiple vectors per doc
"properties": {
"vector": {
"type": "dense_vector" //the vector used for ranking
},
@xeraa
xeraa / semantic_text.json
Last active February 2, 2025 01:42
Elasticsearch semantic_text in action
GET /
DELETE starwars
DELETE semantic-starwars
PUT starwars
{
"settings": {
"analysis": {
"analyzer": {
@xeraa
xeraa / chunking-multi-vector.json
Last active May 12, 2024 21:56
Elasticsearch example for chunked documents to multi-vectors and two different retrieval strategies
DELETE my-long-text-index
PUT my-long-text-index
{
"mappings": {
"properties": {
"my_long_text_field": {
"type": "nested", //because there can be multiple vectors per doc
"properties": {
"vector": {
@xeraa
xeraa / esql.console
Last active February 9, 2024 19:29
ES|QL examples
See https://xeraa.net/talks/elasticsearch-piped-query-language-esql/ for an updated version :)
@xeraa
xeraa / rrf-console.json
Last active October 12, 2023 10:00
Reciprocal Rank Fusion
GET bytes-discuss-dense-search/_search
{
"query": {
"multi_match": {
"fields": [ "title" ],
"query": "I don't know how to use ingest pipelines"
}
},
"size": 6,
"fields": [ "title" ],
@xeraa
xeraa / commands.sh
Created February 11, 2022 17:18
Elastic 8.0 security by default: Minimal setup with Docker for a 3 node cluster + Kibana
// Start the first node and keep the generated security credentials handy
docker run -e ES_JAVA_OPTS="-Xms1g -Xmx1g" -p 9200:9200 -it docker.elastic.co/elasticsearch/elasticsearch:8.0.0
// Check if the node has started correctly
curl --insecure --user elastic https://localhost:9200/
// Add your second node
docker run -e ENROLLMENT_TOKEN="..." -e ES_JAVA_OPTS="-Xms1g -Xmx1g" -it docker.elastic.co/elasticsearch/elasticsearch:8.0.0
// Check if it has joined the cluster
@xeraa
xeraa / search_as_you_type
Created March 15, 2021 11:01
Elasticsearch's search_as_you_type and completion suggester fields in action
PUT jobs
{
"mappings": {
"properties": {
"title": {
"type": "search_as_you_type"
}
}
}
}
PUT test/_doc/1
{
"test A": "a",
"test B": "b"
}
GET test/_search
{
"query": {
"match": {
"test A": "a"