#!/bin/sh
#
# select commands using CONTAINS, and WORD and COMBINEDWORD indexes
#   using the journalcits table.
#
# This may be run with the -noindex option to compare/verify indexing systems

SHSQL="shsql -echo -delim space"
# SHSQL="shsql -echo -delim space -noindex"

echo "*************************************************************"
echo "0. contains"
$SHSQL "select title, _matchscore from journalcits where title contains 'morphine' 
	order by _matchscore, authorlist, pmid limit 5 " 2>&1

echo "*************************************************************"
echo "1. contains"
$SHSQL "select title, _matchscore from journalcits where title contains 'morphine gene' 
	order by _matchscore, authorlist, pmid limit 10 " 2>&1

echo "*************************************************************"
echo "2. contains"
$SHSQL "select title, _matchscore from journalcits where title containslike 'retina' 
	order by _matchscore, authorlist, pmid limit 5 " 2>&1

echo "*************************************************************"
echo "3. contains"
$SHSQL "select title, _matchscore from journalcits where title contains 'retina degen' 
	order by _matchscore, authorlist, pmid limit 5 " 2>&1

echo "*************************************************************"
echo "4. contains with a quoted term"
$SHSQL "select title, _matchscore from journalcits where title contains '\"retinal degeneration\"' 
	order by _matchscore, authorlist, pmid limit 5 " 2>&1

echo "*************************************************************"
echo "5. contains with comma separating the terms"
$SHSQL "select authorlist, pmid, _matchscore from journalcits where authorlist contains 'smith, rs' 
	order by _matchscore, authorlist, pmid limit 5 " 2>&1

echo "*************************************************************"
echo "6. contains: _matchscore in where clause"
$SHSQL "select authorlist, pmid, _matchscore from journalcits where authorlist contains 'smith rs' 
	and _matchscore = 0
	order by _matchscore, authorlist, pmid limit 5 " 2>&1

echo "*************************************************************"
echo "7. 2 contains, OR'ed together.."
$SHSQL "select authorlist, title, _matchscore from journalcits where authorlist contains 'booth' and title contains 'mice' 
	order by _matchscore, authorlist, pmid limit 5 " 2>&1

echo "*************************************************************"
echo "8. 2 contains AND'ed together.."
$SHSQL "select authorlist, title, _matchscore from journalcits where authorlist contains 'booth smith' 
	and title contains 'mice' order by _matchscore, authorlist, pmid limit 5 " 2>&1

echo "*************************************************************"
echo "9. 2 contains OR'ed together.."
$SHSQL "select authorlist, title, _matchscore from journalcits where authorlist contains 'booth johnson' 
	OR title contains 'booth johnson' 
	order by _matchscore, authorlist, pmid limit 5 " 2>&1

echo "*************************************************************"
echo "10. 2 contains OR'ed together.. "
$SHSQL "select authorlist, title, _matchscore from journalcits where authorlist contains 'booth johnson hearing' 
	OR title contains 'booth johnson hearing' 
	order by _matchscore, authorlist, pmid limit 5 " 2>&1


echo "*************************************************************"
echo "11. finding null with a word index"
$SHSQL "select authorlist, title from journalcits where authorlist is null
	order by authorlist limit 5 " 2>&1

echo "*************************************************************"
echo "12. GROUP BY using the curcits table"
$SHSQL "select pubtype, count(*) from curcits group by pubtype" 2>&1


