Skip to content

Instantly share code, notes, and snippets.

Created June 22, 2012 19:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/2974568 to your computer and use it in GitHub Desktop.
Save anonymous/2974568 to your computer and use it in GitHub Desktop.
elasticsearch scoring test
# Deletes then recreates an index, adds 4 documents, queries the index.
# Identical documents will sometimes have different scores.
# NOTE: Might need to run multiple times.
# NOTE: Testing with es 19.2
HOST=localhost
PORT=9200
INDEX=movies
TYPE=actors
echo "Running test on host $HOST"
echo "Killing index..."
curl -XDELETE $HOST:$PORT/$INDEX/
echo "Creating mapping..."
curl -XPUT $HOST:$PORT/$INDEX -d '{
"mappings" : {
"actors" : {
"properties" : {
"actor" : { "type" : "string", "index" : "analyzed" }
}
}
}
}'
echo "Viewing mappings"
curl $HOST:$PORT/$INDEX/_mapping?pretty
names=( "crime" "crime" "crime" "crimeq" )
for name in "${names[@]}"; do
echo ""
echo "Adding actor ${name} to crime index"
curl -XPOST $HOST:$PORT/$INDEX/$TYPE/ -d '{"actor" : "'$name'"}'
done
echo ""
sleep 1
echo "Querying dater..."
curl -XGET $HOST:$PORT/$INDEX/$TYPE/_search?pretty=true\&search_type=dfs_query_then_fetch -d '{
query : {
"query_string": {"query":"actor:crime~0.5"}
}
}'
echo ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment