Skip to content

Instantly share code, notes, and snippets.

@taylor
Created December 3, 2013 20:25
Show Gist options
  • Select an option

  • Save taylor/7776914 to your computer and use it in GitHub Desktop.

Select an option

Save taylor/7776914 to your computer and use it in GitHub Desktop.
#!/bin/bash
testbucket="testhistories$RANDOM"
#testfile1=mockquote$RANDOM
#testfile2=mockquote$RANDOM
echo "Test bucket: $testbucket"
#echo "Creating test files: $testfile1 $testfile2"
echo "Installing post commit hook on bucket $testbucket"
set -x
search-cmd install "$testbucket"
set +x
mydir=$(dirname $0)
#testfile="mockquote.json"
testfile="${mydir}/mockquote.json"
echo "Uploading ${testfile} to riak"
set -x
#curl -X PUT "http://127.0.0.1:8098/riak/${testbucket}/${testfile1}" -H "Content-Type: text/plain" -d "@mockquote.txt"
#curl -X PUT "http://127.0.0.1:8098/riak/${testbucket}/${testfile1}" -H "Content-Type: text/plain" -d "@mockquote.json"
#curl -X PUT "http://127.0.0.1:8098/riak/${testbucket}/${testfile1}" -H "Content-Type: text/plain" -d "@kinesis-tips.txt"
#curl -X PUT "http://127.0.0.1:8098/riak/${testbucket}/${testfile1}" -d "@mockquote.json"
#curl -X PUT "http://127.0.0.1:8098/riak/${testbucket}/${testfile1}" -H "Content-Type: text/plain" -d "@test.txt"
#curl -X PUT "http://127.0.0.1:8098/riak/${testbucket}/${testfile1}" -H "Content-Type: text/plain" -d "@mockquote.json"
#curl -X PUT "http://127.0.0.1:8098/riak/${testbucket}/test$RANDOM" -H "Content-Type: text/plain" -d "@mockquote.txt"
#curl -X PUT "http://127.0.0.1:8098/riak/${testbucket}/test$RANDOM" -H "Content-Type: text/plain" -d "@mockquote.json"
curl -X PUT "http://127.0.0.1:8098/riak/${testbucket}/test$RANDOM" -H "Content-Type: text/plain" -d "@${testfile}"
set +x
#curl -qs "http://127.0.0.1:8098/riak/${testbucket}/${testfile1}"
set -x
echo "Should work and find data when using two or more terms space separated and one term is valid (q.op defaults to OR)"
t1='\"agentContractNumber\"\:'
t2='\"999994\"\,'
curl "http://localhost:8098/solr/${testbucket}/select?wt=json&q=${t1}%20${t2}"
echo "BROKEN: Should fail but does not with q.op=and and one BAD term (FALSE POSITIVE)"
t1='\"agentContractNumber\"\:'
t2='\"999994\"\,' # Invalid TERM - exact match
curl "http://localhost:8098/solr/${testbucket}/select?wt=json&q.op=and&q=${t1}%20${t2}"
echo "Should fail for exact term match with AND if one term is not found (1)"
t1='\"agentContractNumber\"\:'
t2='\"999994\"\,' # Invalid TERM - exact match
curl "http://localhost:8098/solr/${testbucket}/select?wt=json&q=${t1}%20AND%20${t2}"
echo "Should fail for exact term match with AND if one term is not found (2)"
t1='\"agentContractNumber\"\:'
t2='\"999' # Invalid TERM - partial match with out wildcard
curl "http://localhost:8098/solr/${testbucket}/select?wt=json&q=${t1}%20AND%20${t2}"
echo "Should find something with correct terms and wildcard"
t1='\"agentContractNumber\"\:'
t2='\"99999*'
curl "http://localhost:8098/solr/${testbucket}/select?wt=json&q=${t1}%20AND%20${t2}"
echo "Should not find anything with wildcard on unknown TERM (not found)"
t1='\"agentContractNumber\"\:'
t2='\"777777*'
curl "http://localhost:8098/solr/${testbucket}/select?wt=json&q=${t1}%20AND%20${t2}"
echo "Should find something with spaces in a correct term"
t1='\"streetAddress\"\:'
t2='\"100%20Big%20Money%20Rd\",'
curl "http://localhost:8098/solr/${testbucket}/select?wt=json&q=${t1}%20AND%20${t2}"
echo "Adding ${testfile} with Content-Type application/json"
curl -X PUT "http://127.0.0.1:8098/riak/${testbucket}/test$RANDOM" -H "Content-Type: application/json" -d "@${testfile}"
echo "Should find doc with search for id:2"
t1='id:2'
curl "http://localhost:8098/solr/${testbucket}/select?wt=json&q=${t1}"
echo "Should find doc applicant_lastName:Wellington search"
t1='applicant_lastName:Wellington'
curl "http://localhost:8098/solr/${testbucket}/select?wt=json&q=${t1}"
echo "Should find doc applicant_lastName:Well* search"
t1='applicant_lastName:Well*'
curl "http://localhost:8098/solr/${testbucket}/select?wt=json&q=${t1}"
echo "Should find doc applicant_firstName:Wesley AND applicant_lastName:Wellington search"
t1='applicant_firstName:Wesley'
t2='applicant_lastName:Wellington'
curl "http://localhost:8098/solr/${testbucket}/select?wt=json&q=${t1}%20AND%20${t2}"
echo "Should find doc applicant_firstName:Wes* AND applicant_lastName:Well* search"
t1='applicant_firstName:Wes*'
t2='applicant_lastName:Well*'
curl "http://localhost:8098/solr/${testbucket}/select?wt=json&q=${t1}%20AND%20${t2}"
echo "BROKEN: Should find doc a*:Well* search"
t1='a*:Well*'
curl "http://localhost:8098/solr/${testbucket}/select?wt=json&q=${t1}"
echo "BROKEN: Should find doc *:Well* search"
t1='*:Well*'
curl "http://localhost:8098/solr/${testbucket}/select?wt=json&q=${t1}"
echo "Should NOT find doc applicant_lastName:NotAName search"
t1='applicant_lastName:NotAName'
curl "http://localhost:8098/solr/${testbucket}/select?wt=json&q=${t1}"
echo "BROKEN: Should find doc *:Wellington search"
t1='*:Wellington'
curl "http://localhost:8098/solr/${testbucket}/select?wt=json&q=${t1}"
echo "BROKEN: Should find doc *:* search"
t1='*:*'
curl "http://localhost:8098/solr/${testbucket}/select?wt=json&q=${t1}"
# curl "http://localhost:8098/solr/${testbucket}/select?wt=json&q=\"agentContractNumber\"\:%20\"999994\"\,"
# curl "http://localhost:8098/solr/${testbucket}/select?wt=json&q.op=and&q=\"agentContractNumber\"\:%20\"999994\"\,"
# curl "http://localhost:8098/solr/${testbucket}/select?wt=json&q=\"refe\"*" ; echo
# curl "http://localhost:8098/solr/${testbucket}/select?wt=json&q=\"999998\"*" ; echo
# curl "http://localhost:8098/solr/${testbucket}/select?wt=json&q=\"agentContractNumber\"%20AND%20\"999998\""
#curl "http://localhost:8098/solr/${testbucket}/select?wt=json&q=value:Kinesis*" ; echo
##curl "http://localhost:8098/solr/${testbucket}/select?wt=json&q=value:\"Buick\"*" ; echo
#curl "http://localhost:8098/solr/${testbucket}/select?wt=json&q=\"uick\"*" ; echo
#curl "http://localhost:8098/solr/${testbucket}/select?wt=json&q=value:MASTER%20AND%20RTRWINTEST" ; echo
#curl "http://localhost:8098/solr/${testbucket}/select?wt=json&q=value:"MASTER"*" ; echo
#curl "http://localhost:8098/solr/${testbucket}/select?wt=json&q="RTRWIN"*" ; echo
#curl "http://localhost:8098/solr/${testbucket}/select?wt=json&q=WWW*" ; echo
#curl "http://localhost:8098/solr/${testbucket}/select?wt=json&q=value:RTRWIN*" ; echo
#curl "http://localhost:8098/solr/${testbucket}/select?wt=json&q=value:RTRWIN" ; echo
#curl "http://localhost:8098/solr/${testbucket}/select?wt=json&q=RTRWINTEST" ; echo
#curl "http://localhost:8098/solr/${testbucket}/select?wt=json&q=\"RTRWINTEST\"" ; echo
#curl "http://localhost:8098/solr/${testbucket}/select?wt=json&q=value:MASTERWWW*RTRWINTEST" ; echo
#curl "http://localhost:8098/solr/${testbucket}/select?wt=json&q=value:MASTERWWW.example.comRTRWINTEST" ; echo
set +x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment