Skip to content

Instantly share code, notes, and snippets.

View clintongormley's full-sized avatar

Clinton Gormley clintongormley

  • Barcelona, Spain
View GitHub Profile
curl -XPUT "http://localhost:9200/test " -d'
{
"settings": {
"analysis": {
"analyzer": {
"prefix": {
"type": "custom",
"tokenizer": "standard",
"filter": [
"lowercase",
@clintongormley
clintongormley / load_test_data.sh
Last active January 5, 2024 07:32
Run these commands in your shell to setup the test data for Chapter 5
curl -XPUT 'http://localhost:9200/us/user/1?pretty=1' -d '
{
"email" : "john@smith.com",
"name" : "John Smith",
"username" : "@john"
}
'
curl -XPUT 'http://localhost:9200/gb/user/2?pretty=1' -d '
{
@clintongormley
clintongormley / gist:7263976
Created November 1, 2013 11:08
(match 'name' to 'foo') OR (NOT match 'email' to 'foo').
curl -XGET "http://localhost:9200/_search" -d'
{
"query": {
"bool": {
"should": [
{
"match": {
"name": "foo"
}
},
POST /documents/_search
{
"query": {
"bool": {
"must": [
{
"function_score": {
"query": {
"has_child": {
"type": "comment",
POST /documents/_search
{
"query": {
"bool": {
"must": {
"function_score": {
"query": {
"has_child": {
"type": "comment",

First, setup the parent/child relationship

curl -XDELETE "http://localhost:9200/test"

curl -XPOST "http://localhost:9200/test" -d'
{
   "mappings": {
      "child": {
curl -XPUT 'http://127.0.0.1:9200/test/?pretty=1' -d '
{
"mappings" : {
"test" : {
"properties" : {
"loc" : {
"type" : "geo_point"
}
}
}
curl -XPUT 'http://127.0.0.1:9200/foo/?pretty=1' -d '
{
"mappings" : {
"bar" : {
"properties" : {
"text" : {
"index" : "not_analyzed",
"fielddata" : {
"filter" : {
curl -XDELETE 'localhost:9200/test%2A?pretty=1'
curl -XPUT 'localhost:9200/test_1?pretty=1' -d '
{
"mappings" : {
"test" : {
"_parent" : {
"type" : "foo"
}
}
@clintongormley
clintongormley / test.sh
Created May 18, 2013 10:50
Scoring missing nested docs
# delete index if exists
curl -XDELETE localhost:9200/test/
# create index with default settings
curl -XPOST localhost:9200/test/
# create mapping
curl -XPUT localhost:9200/test/product/_mapping -d '
{
"product" : {