cURL recreation script to reproduce Elaticsearch issue #28390
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/env bash | |
# elasticsearch-issue-28390.sh | |
# cURL recreation script to reproduce Elaticsearch issue #28390 | |
NL1="\n" | |
NL2="${NL1}${NL1}" | |
NC='\033[0m' | |
RED='\033[0;31m' | |
GREEN='\033[0;32m' | |
info () { | |
now=$(date +"%m-%d-%y %T") | |
printf "[${now}] ${GREEN}$1${NL1}${NC}" | |
} | |
error () { | |
now=$(date +"%m-%d-%y %T") | |
printf "[${now}] ${RED}$1${NL1}${NC}" | |
} | |
linebreak () { | |
printf "${NL1}" | |
} | |
newline () { | |
printf "${NL2}" | |
} | |
enter() { | |
read -p "Enable your breakpoints and press [ENTER] to continue" | |
} | |
ES_CLUSTER="http://localhost:9200" | |
info "Delete [index1] index" | |
curl -XDELETE "${ES_CLUSTER}/index1" | |
newline | |
info "Create [index1] index" | |
curl -XPUT "${ES_CLUSTER}/index1" -H "Content-Type: application/json" --data '{ | |
"mappings": { | |
"type1": { | |
"properties": { | |
"field1": { | |
"type": "text", | |
"term_vector": "with_positions_offsets" | |
} | |
} | |
} | |
} | |
}' | |
newline | |
info "Create document [1] with routing [1] in index [index1]" | |
curl -XPOST "${ES_CLUSTER}/index1/type1/1?refresh=true&routing=1" -H "Content-Type: application/json" --data '{ | |
"field1" : "quick fox" | |
}' | |
newline | |
info "Create document [2] with routing [2] in index [index1]" | |
curl -XPOST "${ES_CLUSTER}/index1/type1/2?refresh=true&routing=2" -H "Content-Type: application/json" --data '{ | |
"field1" : "brown fox" | |
}' | |
newline | |
enter | |
info "Search document with span query with boost" | |
curl -XGET "${ES_CLUSTER}/index1/_search?_source=false&explain=false&pretty=true" -H "Content-Type: application/json" --data '{ | |
"explain" : true, | |
"query" : { | |
"span_near" : { | |
"slop": 12, | |
"in_order" : true, | |
"clauses" : [ | |
{ | |
"span_or": { | |
"clauses": [ | |
{ | |
"span_term" : { | |
"field1" : { | |
"value" : "quick", | |
"boost" : 2 | |
} | |
} | |
}, | |
{ | |
"span_term" : { | |
"field1" : { | |
"value" : "brown", | |
"boost" : 1 | |
} | |
} | |
} | |
] | |
} | |
}, | |
{ | |
"span_term" : { | |
"field1" : { | |
"value" : "fox", | |
"boost" : 1 | |
} | |
} | |
} | |
] | |
} | |
}, | |
"size":1500 | |
}' | |
linebreak | |
info "Search document with span query without boost >>>> boost has no effect" | |
curl -XGET "${ES_CLUSTER}/index1/_search?_source=false&explain=false&pretty=true" -H "Content-Type: application/json" --data '{ | |
"explain" : true, | |
"query" : { | |
"span_near" : { | |
"slop": 12, | |
"in_order" : true, | |
"clauses" : [ | |
{ | |
"span_or": { | |
"clauses": [ | |
{ | |
"span_term" : { | |
"field1" : { | |
"value" : "quick" | |
} | |
} | |
}, | |
{ | |
"span_term" : { | |
"field1" : { | |
"value" : "brown" | |
} | |
} | |
} | |
] | |
} | |
}, | |
{ | |
"span_term" : { | |
"field1" : { | |
"value" : "fox" | |
} | |
} | |
} | |
] | |
} | |
}, | |
"size":1500 | |
}' | |
linebreak |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment