Skip to content
This repository was archived by the owner on Jan 31, 2022. It is now read-only.

Commit 8d55a21

Browse files
author
Clément Le Provost
committed
New snippetEllipsisText search parameter exposed
1 parent 141f79d commit 8d55a21

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,7 @@ You can use the following optional arguments:
348348
* **setAttributesToSnippet**: The list of attributes to snippet alongside the number of words to return (syntax is `attributeName:nbWords`). By default, no snippet is computed.
349349
* **getRankingInfo**: If set to true, the result hits will contain ranking information in the **_rankingInfo** attribute.
350350
* **setHighlightingTags**: (string, string) Specify the string that is inserted before the highlighted parts in the query result (defaults to "<em>") and the string that is inserted after the highlighted parts in the query result (defaults to "</em>")..
351+
* **setSnippetEllipsisText**: (string) String used as an ellipsis indicator when a snippet is truncated (defaults to empty).
351352
352353
353354
#### Numeric Search Parameters

algoliasearch/src/main/java/com/algolia/search/saas/Query.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ public enum TypoTolerance {
9797
protected String tags;
9898
protected String highlightPreTag;
9999
protected String highlightPostTag;
100+
protected String snippetEllipsisText;
100101
protected Integer minProximity;
101102
protected String numerics;
102103
protected String insideBoundingBox;
@@ -167,6 +168,7 @@ public Query(Query other) {
167168
minProximity = other.minProximity;
168169
highlightPreTag = other.highlightPreTag;
169170
highlightPostTag = other.highlightPostTag;
171+
snippetEllipsisText = other.snippetEllipsisText;
170172
distinct = other.distinct;
171173
advancedSyntax = other.advancedSyntax;
172174
removeStopWords = other.removeStopWords;
@@ -407,6 +409,15 @@ public Query setHighlightingTags(String preTag, String postTag) {
407409
return this;
408410
}
409411

412+
/**
413+
* Specify the string that is used as an ellipsis indicator when a snippet
414+
* is truncated (defaults to the empty string).
415+
*/
416+
public Query setSnippetEllipsisText(String snippetEllipsisText) {
417+
this.snippetEllipsisText = snippetEllipsisText;
418+
return this;
419+
}
420+
410421
/**
411422
* Specify the minimum number of characters in a query word to accept two
412423
* typos in this word. Defaults to 7.
@@ -954,6 +965,12 @@ protected String getQueryString() {
954965
stringBuilder.append("&highlightPostTag=");
955966
stringBuilder.append(highlightPostTag);
956967
}
968+
if (snippetEllipsisText != null) {
969+
if (stringBuilder.length() > 0)
970+
stringBuilder.append('&');
971+
stringBuilder.append("snippetEllipsisText=");
972+
stringBuilder.append(URLEncoder.encode(snippetEllipsisText, "UTF-8"));
973+
}
957974
if (hitsPerPage != null) {
958975
if (stringBuilder.length() > 0)
959976
stringBuilder.append('&');

0 commit comments

Comments
 (0)