Solr Requirements For Advanced Search: - Query - :" (!dismax QF $ (QF - Name1) PF $ (PF - Name1) ) (Xform-Query
Solr Requirements For Advanced Search: - Query - :" (!dismax QF $ (QF - Name1) PF $ (PF - Name1) ) (Xform-Query
Page 1 of 5
SolrRequirementsforAdvancedSearch
MappingTextBoxesinAdvancedSearchFormtoSolrquerypieces
Eachtextbox(orcheckbox)intheadvancedsearchqueryformmapstoaparticularsetof Solrfieldsandboostingvalues(plainboostingandphraseboosting)tobeusedintheSolr query.Theparticularfieldsandboostvalues(andphrasefieldsandboostvalues)foreach textboxwillbeconfiguredontheSolrserver,viatheadvancedrequesthandler. Theuserqueryitselfisalsotransformed;seebelowunderQueryTransformation. Foreachtextboxcontainingusersuppliedtext,therewillbeachunkinthevalueofqsent tosolrthatlookslikethis: Piecesinsquarebracketswillbereplacedwithspecificstrings.Theboldareallpartofthe actualstringsenttosolr:quotes,curlybraces,exclamationpointanddollarsignsareall senttoSolr. Soiftheuserhastypedintotwotextboxes,andthetextboxesaretobecombined(AND), thentheqparamsenttoSolrwouldhavethisform:
q=_query_:{!dismax qf=$[qf_name1] pf=$[pf_name1]}[xformed-queryterms1] AND _query_:{!dismax qf=$[qf_name2] pf=$[pf_name2]}[xformed-queryterms2] _query_:{!dismax qf=$[qf_name1] pf=$[pf_name1]}[xform-queryterms]
IftheuserchoosestocombinethetextboxeswithanOR,theqparamsenttoSolrwould havethisform:
q=_query_:{!dismax qf=$[qf_name1] pf=$[pf_name1]}[xformed-queryterms1] OR _query_:{!dismax qf=$[qf_name2] pf=$[pf_name2]}[xformed-queryterms2]
Atthistime,theqtargumentfortheSolrrequestMUSTbesettoastandardrequest handler(inourcase,advanced).OtherwiseSolrwillalwaysreturn0results.
Page 2 of 5
Iwillprovideamappingofadvancedsearchformtextboxestoparticularqfandpf argumentsintheconfig/initializer/stanford_config.rb,alongthelinesof:
config[:advanced] = { author => { :qf => qf_author, :pf => pf_author }, title => { :qf => qf_title, :pf => pf_title }, pub_info => { :qf => qf_publisher, :pf => pf_publisher } }
QueryTransformations
RecognizedBooleanOperators AND OR NOT Booleanoperatorswillalwaysbeallcharsuppercase(i.e.AND,OR,NOT).Lowercaseand mixedcaseexpressionsofthesewordscanbetreatedlikeanyotherword.Jennifer explainsthatthisisgood,becausewhenpeoplecutandpastetitlesorwhatever,theydont wantandAndorOrnotNotinterpretedasBoolean. ThedefaultoperatorisAND.Thatis,whenthereisnooperator,ANDisimplicit. Term: Booleanoperatorsworkwithterms:aword,oragroupofwords.Atermcanbe: charactersnotseparatedbywhitespace or aclausejoinedbytheAND(orplain,whichisimplicitAND)orORoperator: o dogANDcat o dogcat o dogORcat or asetofparenthesesandthecharactersinside o EACHsetofparensisaterm o whatiswithineachsetofparensneedstogothroughtreatmentbelowbut preservetheparens
Page 3 of 5
or
o example:(lesbianORgay)AND(videoORbook)has6terms: 1. (lesbianORgay) 2. lesbian 3. gay 4. (videoORbook) 5. video 6. book o parenscanbenested: o example:creamAND((filoANDdough)ORpastry)has6terms 1. cream 2. ((filoANDdough)ORpastry) 3. (filoANDdough) 4. filo 5. dough 6. pastry aclausejoinedbytheAND(orplain,whichisimplicitAND)orORoperator: o (lesbianORgay)(videoORbook)has6terms: 1. (lesbianORgay) 2. lesbian 3. gay 4. (videoORbook) 5. video 6. book
Page 4 of 5
Combos:ANDandPlain
tom lynn AND jessie tom AND lynn mcrae +tom +lynn +jessie +tom +lynn +mcrae
OR ORcanbeleftalone.
nabokov OR pushkin nabokov OR pushkin (tom lynn) OR Jessie (tom lynn) OR Jessie
Combos:ANDandOR
(dog AND cat) OR mouse (dog OR cat) AND mouse tom lynn OR jessie (Lynn AND Naomi) OR (Stu +Jessie) (Lynn OR Naomi) AND (Stu Jessie) AND (+dog +cat) OR mouse +(dog OR cat) +mouse +tom lynn jessie Jessie) (+Lynn +Naomi) OR (+Stu +(Lynn OR Naomi) +(Stu OR
OR Jessie)
WhentherearemultipletermsinatextboxandoneormoreisprecededbyNOT,theNOT shouldbeleftalone.
cat NOT cat NOT NOT dog NOT mouse +cat NOT mouse mouse cat NOT mouse +cat AND NOT mouse +cat NOT mouse mouse AND cat NOT mouse +cat mouse cat dog NOT mouse +cat +dog NOT mouse cat +dog NOT mouse +cat
+dog +cat NOT mouse dog OR cat NOT mouse cat NOT mouse OR dog
Page 5 of 5
termsinparens:
(dog AND cat) NOT mouse +(+dog +cat) NOT mouse (dog OR cat) NOT mouse +(dog OR cat) NOT mouse NOT mouse (dog OR cat) NOT mouse +(dog OR cat) NOT (dog OR cat) AND mouse NOT (dog OR cat) +mouse
SingleTerm Asingleterminasearchbox,withoutanyoperator,maybeleftalone:
fred fred
singletermcanbeaparentheticalphrase
(joe OR fred) (joe OR fred) ((dog cat) AND (mouse bug)) (+(+dog +cat) +(+mouse +bug))
NOT blahthisisnottreatedasasingleterm,becauseoftheNOTSeeabove.