cancel
Showing results for 
Search instead for 
Did you mean: 

SearchParamters ParseException

mtw999
Champ in-the-making
Champ in-the-making
Hello,

I have two queries I'm using with SearchParameters. I'm having issue figuring out how to query for a specific property:

General question, what is the best way to test query to know that it is formatted correctly to work as query provided to SearchParameters? NodeBrowser does not work as both these queries execute successfully in Node Browser:

How do I specify a property search in a query passed to SearchParameters.query() and what exactly is this error telling me:
Encountered " ":" ": "" at line 1, column 132


Successful:
PATH:"./app:company_home/st:sites/cm:%s/cm:documentLibrary//*" AND TYPE:"mytype:mydoc" AND ISNOTNULL:"mydoc:myCode"

Resolves to:
PATH:"./app:company_home/st:sites/cm:submissions/cm:documentLibrary//*" AND TYPE:"mytype:mydoc" AND ISNOTNULL:"mydoc:myCode"

Fails:
PATH:"./app:company_home/st:sites/cm:%s/cm:documentLibrary//*" AND TYPE:"mytype:mydoc" AND
mydoc:myCode:%s

Resolves to
PATH:"./app:company_home/st:sites/cm:submissions/cm:documentLibrary//*" AND TYPE:"mytype:mydoc" AND mydoc:myCode:foo

Also tried:
PATH:"./app:company_home/st:sites/cm:submissions/cm:documentLibrary//*" AND TYPE:"mytype:mydoc" AND mydoc:myCode:"foo"

Error on failure(s):
org.apache.solr.common.SolrException: org.apache.lucene.queryParser.ParseException: Cannot parse 'PATH:"./app:company_home/st:sites/cm:mySite/cm:documentLibrary//*" AND TYPE:"mytype:mydoc" AND mydoc:myCode:foo': Encountered " ":" ": "" at line 1, column 132.
Was expecting one of:


Thanks,

Mike
1 REPLY 1

kaynezhang
World-Class Innovator
World-Class Innovator
SearchParameters suppport serveral query languages,So

1.you should specify query language in SearchParameters ,I guess you are using lucene search language here
2.you should correctly escape illegal lucene characters,for example escape double quote;
Here is an example

   SearchParameters sp = new SearchParameters();
        sp.setLanguage(SearchService.LANGUAGE_LUCENE);
        sp.setQuery("PATH:\"/app:company_home/st:sites/cm:submissions/cm:documentLibrary//*\" AND TYPE:\"mytype:mydoc\" AND ISNOTNULL:\"mydoc:myCode\"");