This commit is contained in:
@@ -75,9 +75,10 @@ namespace AyaNova.Api.Controllers
|
|||||||
/// <param name="ayaType"></param>
|
/// <param name="ayaType"></param>
|
||||||
/// <param name="id"></param>
|
/// <param name="id"></param>
|
||||||
/// <param name="phrase"></param>
|
/// <param name="phrase"></param>
|
||||||
|
/// <param name="max"></param>
|
||||||
/// <returns>A search result excerpt of object</returns>
|
/// <returns>A search result excerpt of object</returns>
|
||||||
[HttpGet("Info/{ayaType}/{id}")]
|
[HttpGet("Info/{ayaType}/{id}")]
|
||||||
public async Task<IActionResult> GetInfo([FromRoute] AyaType ayaType, [FromRoute] long id, [FromQuery] string phrase)
|
public async Task<IActionResult> GetInfo([FromRoute] AyaType ayaType, [FromRoute] long id, [FromQuery] string phrase, [FromQuery] int max = 80)
|
||||||
{
|
{
|
||||||
if (serverState.IsClosed)
|
if (serverState.IsClosed)
|
||||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||||
@@ -87,12 +88,13 @@ namespace AyaNova.Api.Controllers
|
|||||||
|
|
||||||
if (!ModelState.IsValid)
|
if (!ModelState.IsValid)
|
||||||
return BadRequest(new ApiErrorResponse(ModelState));
|
return BadRequest(new ApiErrorResponse(ModelState));
|
||||||
if(id==0){
|
if (id == 0)
|
||||||
return NotFound();
|
{
|
||||||
|
return NotFound();
|
||||||
}
|
}
|
||||||
|
|
||||||
var res = await Search.GetInfoAsync(ct, UserTranslationIdFromContext.Id(HttpContext.Items),
|
var res = await Search.GetInfoAsync(ct, UserTranslationIdFromContext.Id(HttpContext.Items),
|
||||||
UserRolesFromContext.Roles(HttpContext.Items),UserIdFromContext.Id(HttpContext.Items), phrase, ayaType, id);
|
UserRolesFromContext.Roles(HttpContext.Items), UserIdFromContext.Id(HttpContext.Items), phrase, max, ayaType, id);
|
||||||
|
|
||||||
return Ok(ApiOkResponse.Response(res, true));
|
return Ok(ApiOkResponse.Response(res, true));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -273,7 +273,7 @@ namespace AyaNova.Biz
|
|||||||
|
|
||||||
#region Get info (excerpt)
|
#region Get info (excerpt)
|
||||||
public static async Task<string> GetInfoAsync(AyContext ct, long translationId,
|
public static async Task<string> 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
|
//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
|
//https://www.postgresql.org/docs/current/functions-matching.html#FUNCTIONS-LIKE
|
||||||
@@ -295,7 +295,7 @@ namespace AyaNova.Biz
|
|||||||
|
|
||||||
//extract and rank here
|
//extract and rank here
|
||||||
ExtractAndRank er = new ExtractAndRank();
|
ExtractAndRank er = new ExtractAndRank();
|
||||||
er.Process(searchParams, PhraseItems.ToArray());
|
er.Process(searchParams, PhraseItems.ToArray(), max);
|
||||||
// sr.Extract = er.Extract;
|
// sr.Extract = er.Extract;
|
||||||
// sr.Rank = er.Ranking;
|
// sr.Rank = er.Ranking;
|
||||||
|
|
||||||
@@ -427,10 +427,9 @@ namespace AyaNova.Biz
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Do the extraction and ranking
|
/// Do the extraction and ranking
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="searchObjectParams"></param>
|
public void Process(SearchIndexProcessObjectParameters searchObjectParams, string[] searchTerms, int max)
|
||||||
/// <param name="searchTerms"></param>
|
|
||||||
public void Process(SearchIndexProcessObjectParameters searchObjectParams, string[] searchTerms)
|
|
||||||
{
|
{
|
||||||
|
this.maximumCharactersToExtract = max;
|
||||||
|
|
||||||
ranking = 0;
|
ranking = 0;
|
||||||
extract = "";
|
extract = "";
|
||||||
|
|||||||
Reference in New Issue
Block a user