Query throws error using querybuilder but runs fine in querydebug
Here is the query, it runs fine in querybuilder returning zero records that match, which is OK.
path=/content/imf/en/board-meetings/calendar
type=cq:EventCalendar
fulltext= Statement by the Managing Director on the IEO Report on Behind the Scenes with Data at the IMF - An IEO Evaluation
fulltext.relPath=@jcr:title;
orderby=@boardDate
orderby.sort=desc;
p.limit=0
But if I run the same using the code,
Map<String, Object> paramMap = new HashMap<String, Object>();
paramMap.put("path", BOARD_MEETING_EVENTS_PATH);
paramMap.put("type", "cq:EventCalendar");
paramMap.put("fulltext", documentInfo.getDocumentTitle());
paramMap.put("fulltext.relPath", "@jcr:title");
paramMap.put("orderby", "@boardDate");
paramMap.put("orderby.sort", "desc");
paramMap.put("p.limit", "0");
Query query = queryBuilder.createQuery(PredicateGroup.create(paramMap),
session);
SearchResult searchResult = query.getResult();
Throws error:
/jcr:root/content/imf/en/board-meetings/calendar//*[jcr:contains(@jcr:title;(*), 'Statement by the Managing Director on the IEO Report on Behind the Scenes with Data at the IMF - An IEO Evaluation')] order by @boardDate descending; expected: ,
javax.jcr.query.InvalidQueryException: java.lang.IllegalArgumentException: Invalid expression: 'Statement by the Managing Director on the IEO Report on Behind the Scenes with Data at the IMF - An IEO Evaluation'
at org.apache.jackrabbit.oak.jcr.query.QueryManagerImpl.executeQuery(QueryManagerImpl.java:142)
at org.apache.jackrabbit.oak.jcr.query.QueryImpl$2.perform(QueryImpl.java:101)
at org.apache.jackrabbit.oak.jcr.query.QueryImpl$2.perform(QueryImpl.java:98)
at org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate.perform(SessionDelegate.java:216)
at org.apache.jackrabbit.oak.jcr.query.QueryImpl.execute(QueryImpl.java:97)
at com.day.cq.search.impl.builder.QueryImpl.executeXpath(QueryImpl.java:391)
at com.day.cq.search.impl.builder.QueryImpl.execute(QueryImpl.java:429)
at com.day.cq.search.impl.builder.QueryImpl.getResult(QueryImpl.java:106)
at org.imf.document.service.impl.DocumentServiceImpl.findDocumentRelatedEvents(DocumentServiceImpl.java:1024)
at org.imf.document.service.impl.DocumentServiceImpl.publishDocument(DocumentServiceImpl.java:343)
If I change the title of the document to not have any "-", it works fine. How can we overcome this because titles are going to have a "-" in them.