diff --git a/server/AyaNova/Controllers/SearchController.cs b/server/AyaNova/Controllers/SearchController.cs
index 2e7f20f2..3066ec74 100644
--- a/server/AyaNova/Controllers/SearchController.cs
+++ b/server/AyaNova/Controllers/SearchController.cs
@@ -75,24 +75,26 @@ namespace AyaNova.Api.Controllers
///
///
///
+ ///
/// A search result excerpt of object
[HttpGet("Info/{ayaType}/{id}")]
- public async Task GetInfo([FromRoute] AyaType ayaType, [FromRoute] long id, [FromQuery] string phrase)
+ public async Task GetInfo([FromRoute] AyaType ayaType, [FromRoute] long id, [FromQuery] string phrase, [FromQuery] int max = 80)
{
if (serverState.IsClosed)
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
-
+
if (!Authorized.HasReadFullRole(HttpContext.Items, ayaType))
return StatusCode(403, new ApiNotAuthorizedResponse());
if (!ModelState.IsValid)
return BadRequest(new ApiErrorResponse(ModelState));
- if(id==0){
- return NotFound();
+ if (id == 0)
+ {
+ return NotFound();
}
-
- var res = await Search.GetInfoAsync(ct, UserTranslationIdFromContext.Id(HttpContext.Items),
- UserRolesFromContext.Roles(HttpContext.Items),UserIdFromContext.Id(HttpContext.Items), phrase, ayaType, id);
+
+ var res = await Search.GetInfoAsync(ct, UserTranslationIdFromContext.Id(HttpContext.Items),
+ UserRolesFromContext.Roles(HttpContext.Items), UserIdFromContext.Id(HttpContext.Items), phrase, max, ayaType, id);
return Ok(ApiOkResponse.Response(res, true));
}
diff --git a/server/AyaNova/biz/Search.cs b/server/AyaNova/biz/Search.cs
index 6a219902..0e41f316 100644
--- a/server/AyaNova/biz/Search.cs
+++ b/server/AyaNova/biz/Search.cs
@@ -273,7 +273,7 @@ namespace AyaNova.Biz
#region Get info (excerpt)
public static async Task GetInfoAsync(AyContext ct, long translationId,
- AuthorizationRoles currentUserRoles, long userId, string phrase, AyaType ayaType, long id)
+ AuthorizationRoles currentUserRoles, long userId, string phrase, int max, AyaType ayaType, long id)
{
//escape literal percentage signs first just in case they are searching for 50% off or something
//https://www.postgresql.org/docs/current/functions-matching.html#FUNCTIONS-LIKE
@@ -295,7 +295,7 @@ namespace AyaNova.Biz
//extract and rank here
ExtractAndRank er = new ExtractAndRank();
- er.Process(searchParams, PhraseItems.ToArray());
+ er.Process(searchParams, PhraseItems.ToArray(), max);
// sr.Extract = er.Extract;
// sr.Rank = er.Ranking;
@@ -426,11 +426,10 @@ namespace AyaNova.Biz
#region public methods
///
/// Do the extraction and ranking
- ///
- ///
- ///
- public void Process(SearchIndexProcessObjectParameters searchObjectParams, string[] searchTerms)
+ ///
+ public void Process(SearchIndexProcessObjectParameters searchObjectParams, string[] searchTerms, int max)
{
+ this.maximumCharactersToExtract = max;
ranking = 0;
extract = "";