Created
June 22, 2012 19:10
-
-
Save anonymous/2974568 to your computer and use it in GitHub Desktop.
elasticsearch scoring test
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
# 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