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.
Solved! Go to Solution.
Views
Replies
Total Likes
Hi,
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
I tried with '-' in the query builder and in the query builder, I got the 'IllegalargumentException'
but when I tried with the escape character '/' , it worked fine. Can you try this and see if it works for you aswell ?
ex: add the escape character if your searchtext has '-' in it.
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
Views
Replies
Total Likes
Hi,
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
I tried with '-' in the query builder and in the query builder, I got the 'IllegalargumentException'
but when I tried with the escape character '/' , it worked fine. Can you try this and see if it works for you aswell ?
ex: add the escape character if your searchtext has '-' in it.
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
Views
Replies
Total Likes
Great tip. Thanks. That worked. It's just surprising since text can always have hyphens.
Didn't know though that you could escape it that way. For now we will use that fix, but hoping product can handle hyphen in future.
Views
Replies
Total Likes
Excellent info, we will update help community article. Good work Lokesh
Views
Replies
Total Likes