Debugging QPL

Jump to: navigation, search

For Information on Aspire 3.1 Click Here

This Page is Locked - Content no longer maintained - See QPL for the latest information.

Use Solr param debugQuery=true

You can see how QPL processed your original query by sending debugQuery=true,

For example: http://localhost:8983/solr/collection1/qplselect?q=martha+married+george+washington&wt=xml&indent=true&debugQuery=true would produce :

<lst name="debug">
<str name="rawquerystring">martha married george washington</str>
<str name="querystring">martha married george washington</str>
<str name="parsedquery">
(PhraseQuery(subject_lemma:"martha married george washington"^3.0) ((+subject_lemma:martha +subject_lemma:married  +subject_lemma:george +subject_lemma:washington)^2.0)) ((subject_lemma:martha subject_lemma:married subject_lemma:george  subject_lemma:washington)~2)
<str name="parsedquery_toString">
(subject_lemma:"martha married george washington"^3.0 ((+subject_lemma:martha +subject_lemma:married +subject_lemma:george  +subject_lemma:washington)^2.0)) ((subject_lemma:martha subject_lemma:married subject_lemma:george subject_lemma:washington)~2)

for QPL:

def myParser = makeParser(extended:true, customOperators:true, wildcard:true);
if (query != null && query != "*:*"){
phraseQ = phrase(myTerms);
andQ = and(myTerms);
orQ = (myTerms.size() <= 2) ? null : orMin((int)((myTerms.size()+1)/2), myTerms);
return phraseQ^3.0 | andQ^2.0 | orQ;
//return all results
return field("*", "*")	

Stepping thru QPL in the Eclipse Debugger

  • start solr in debug mode and connect to solr as a Remote Java Application in Eclipse
  • import query-processing-language maven project into Eclipse workspace
  • add the conf folder of your Solr distribution to the source path of your project/workspace
    • right click the new query-processing-language project
    • select Java Build Path -> Source Tab
    • choose Link Source, browse to conf dir (where qpl script is), click Finish
  • set breakpoint in QPLUtilities depunctuate() method
    • all static methods in QPLUtilities are automatically imported into your script
    • this means you can set your breakpoint inside any static method in QPLUtilities
    • depunctuate(String) is a good choice because you can pass in a descriptive string, describing where you are in your script
      • depunctuate("inside TERM transform")
      • depunctuate("inside collapse nested AND transform")
    • in the future, we could add a static method named debugBreakpoint(String) in order to be more explicit
  • call depunctuate() in your script, pass in a descriptive string
    • hit breakpoint, step out and then step in and you will be in your QPL script
    • in QPL, use def with your variables to get them to show up in Variables window
    • you cannot step into closures
      • if you want to step thru closure code, add a depunctuate() line

Please NOTE

  • if your script file name has more than one period, Eclipse will not be able to find the source of the QPL file
  • e.g. script.test01.qpl - if your script has this name, the compilation untit will be test01, and Eclipse will not be able to resolve this to your script file