Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Excerpt/hit.getExcerpt() is giving {relevant_links} as value when using QueryBuilderAPI

Avatar

Avatar
Validate 1
Level 2
kamalakannank62
Level 2

Likes

10 likes

Total Posts

27 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile

Avatar
Validate 1
Level 2
kamalakannank62
Level 2

Likes

10 likes

Total Posts

27 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile
kamalakannank62
Level 2

02-04-2019

I am Using Query builder API for fulltext search, When using hits.getExcerpt() i am getting value as {relevant_links} for few pages. But when checking the same under http://localhost:4502/libs/cq/search/content/querydebug.html  i was able to see proper excerpt for the pages. I have set setExcerpt to true while constructing the query before executing is there something am missing?

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Boost 5
Level 2
chandu_t
Level 2

Likes

7 likes

Total Posts

29 posts

Correct Reply

5 solutions
Top badges earned
Boost 5
Boost 3
Boost 1
Applaud 5
Affirm 5
View profile

Avatar
Boost 5
Level 2
chandu_t
Level 2

Likes

7 likes

Total Posts

29 posts

Correct Reply

5 solutions
Top badges earned
Boost 5
Boost 3
Boost 1
Applaud 5
Affirm 5
View profile
chandu_t
Level 2

03-04-2019

Strange issue, double check your content most likely some content issue.

Answers (11)

Answers (11)

Avatar

Avatar
Validate 25
MVP
bsloki
MVP

Likes

182 likes

Total Posts

1,859 posts

Correct Reply

545 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Boost 50
Boost 5
View profile

Avatar
Validate 25
MVP
bsloki
MVP

Likes

182 likes

Total Posts

1,859 posts

Correct Reply

545 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Boost 50
Boost 5
View profile
bsloki
MVP

02-04-2019

Also, raise a daycare ticket if you will not be able to share the content package here..

Avatar

Avatar
Validate 1
Level 2
kamalakannank62
Level 2

Likes

10 likes

Total Posts

27 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile

Avatar
Validate 1
Level 2
kamalakannank62
Level 2

Likes

10 likes

Total Posts

27 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile
kamalakannank62
Level 2

03-04-2019

yeah its an content issue, got it.

Thank you bsloki​ , chandu t

Avatar

Avatar
Validate 1
Level 2
kamalakannank62
Level 2

Likes

10 likes

Total Posts

27 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile

Avatar
Validate 1
Level 2
kamalakannank62
Level 2

Likes

10 likes

Total Posts

27 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile
kamalakannank62
Level 2

03-04-2019

One more thing is that when a page is having a text="Shipping" and if my search term is "ship", I am getting "{relevant_link}" as excerpt but when I Search "Shipping" i am getting a proper excerpt , Is there a way to make the Query to search exact word?

Avatar

Avatar
Validate 1
Level 2
kamalakannank62
Level 2

Likes

10 likes

Total Posts

27 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile

Avatar
Validate 1
Level 2
kamalakannank62
Level 2

Likes

10 likes

Total Posts

27 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile
kamalakannank62
Level 2

03-04-2019

I am not supposed to share the content package.

Avatar

Avatar
Validate 1
Level 2
kamalakannank62
Level 2

Likes

10 likes

Total Posts

27 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile

Avatar
Validate 1
Level 2
kamalakannank62
Level 2

Likes

10 likes

Total Posts

27 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile
kamalakannank62
Level 2

03-04-2019

bsloki​ thank you for the inputs, will raise a Day care ticket.

Avatar

Avatar
Validate 25
MVP
bsloki
MVP

Likes

182 likes

Total Posts

1,859 posts

Correct Reply

545 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Boost 50
Boost 5
View profile

Avatar
Validate 25
MVP
bsloki
MVP

Likes

182 likes

Total Posts

1,859 posts

Correct Reply

545 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Boost 50
Boost 5
View profile
bsloki
MVP

02-04-2019

That doesnt sound right ! If you are getting right result in querydebug.hml, you should get the same with hit.getExcerpts aswell.. Did you see if there is any difference in the content between the pages where the correct excerpt is coming with the content on the other page ?

Can you provide a package with the sample content where you are seeing the wrong excerpt so that I can try to debug ?

Avatar

Avatar
Validate 1
Level 2
kamalakannank62
Level 2

Likes

10 likes

Total Posts

27 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile

Avatar
Validate 1
Level 2
kamalakannank62
Level 2

Likes

10 likes

Total Posts

27 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile
kamalakannank62
Level 2

02-04-2019

Yeah, I just added to check, Its not consistent, When tried the same with querydebug.html i was able to see consistent result, but here for some pages am getting proper result but for some pages i am not getting excerpt.

Avatar

Avatar
Validate 25
MVP
bsloki
MVP

Likes

182 likes

Total Posts

1,859 posts

Correct Reply

545 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Boost 50
Boost 5
View profile

Avatar
Validate 25
MVP
bsloki
MVP

Likes

182 likes

Total Posts

1,859 posts

Correct Reply

545 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Boost 50
Boost 5
View profile
bsloki
MVP

02-04-2019

Hi,

I see you have already set "p.excerpt":"true", so you dont have to say q.setExcerpt(true); again.. you can remove that.

Also, is this output consistent for every result or only for few result ?

Avatar

Avatar
Validate 1
Level 2
kamalakannank62
Level 2

Likes

10 likes

Total Posts

27 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile

Avatar
Validate 1
Level 2
kamalakannank62
Level 2

Likes

10 likes

Total Posts

27 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile
kamalakannank62
Level 2

02-04-2019

bsloki​,

Please find the query snippet

Map<String, String> map = new HashMap<>();

  map.put("type", "nt:unstructured");

  map.put("fulltext", fulltextSearchTerm);

  map.put("path", localeRootPath);

  map.put("p.excerpt", "true");

  map.put("orderby", "@jcr:score");

  map.put("orderby.sort", "desc");

  map.put("p.limit", "-1");

  final QueryBuilder queryBuilder = getSling().getService(QueryBuilder.class);

  Query q = queryBuilder.createQuery(PredicateGroup.create(map),

                      getSling().getRequest().getResourceResolver().adaptTo(Session.class));

   q.setExcerpt(true);

  result = q.getResult();

for (Hit hit : result.getHits()) {

String excerpt = hit.getExcerpt(); //output is // {relevant_links}

}

Avatar

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,406 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,406 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile
smacdonald2008
Level 10

02-04-2019

Please post - as Lokesh suggests - your full query. The community will help more given more details here.

Avatar

Avatar
Validate 25
MVP
bsloki
MVP

Likes

182 likes

Total Posts

1,859 posts

Correct Reply

545 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Boost 50
Boost 5
View profile

Avatar
Validate 25
MVP
bsloki
MVP

Likes

182 likes

Total Posts

1,859 posts

Correct Reply

545 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Boost 50
Boost 5
View profile
bsloki
MVP

02-04-2019

Hi Kamal,

Are you getting it for all the pages or only few ? Can you post your query and sample output ?