Added Elastic PIT features and tested.

This commit is contained in:
danny-mhlv 2022-08-11 20:02:53 +03:00
parent bbc85b3caf
commit 0fae87c4c8
23 changed files with 1230 additions and 212 deletions

@ -0,0 +1,396 @@
<!doctype html>
<html class="no-js" lang="">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>hometask documentation</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="../images/favicon.ico">
<link rel="stylesheet" href="../styles/style.css">
<link rel="stylesheet" href="../styles/dark.css">
<link rel="stylesheet" href="../styles/readthedocs.css">
</head>
<body>
<div class="navbar navbar-default navbar-fixed-top visible-xs">
<a href="../" class="navbar-brand">hometask documentation</a>
<button type="button" class="btn btn-default btn-menu ion-ios-menu" id="btn-menu"></button>
</div>
<div class="xs-menu menu" id="mobile-menu">
<div id="book-search-input" role="search"><input type="text" placeholder="Type to search"></div> <compodoc-menu></compodoc-menu>
</div>
<div class="container-fluid main">
<div class="row main">
<div class="hidden-xs menu">
<compodoc-menu mode="normal"></compodoc-menu>
</div>
<!-- START CONTENT -->
<div class="content class">
<div class="content-data">
<ol class="breadcrumb">
<li>Classes</li>
<li >EsQueryDto</li>
</ol>
<ul class="nav nav-tabs" role="tablist">
<li class="active">
<a href="#info" role="tab" id="info-tab" data-toggle="tab" data-link="info">Info</a>
</li>
<li >
<a href="#source" role="tab" id="source-tab" data-toggle="tab" data-link="source">Source</a>
</li>
</ul>
<div class="tab-content">
<div class="tab-pane fade active in" id="c-info">
<p class="comment">
<h3>File</h3>
</p>
<p class="comment">
<code>src/core/domain/dtos/es-query.dto.ts</code>
</p>
<p class="comment">
<h3>Description</h3>
</p>
<p class="comment">
<p>Elasticsearch query DTO</p>
</p>
<section>
<h3 id="index">Index</h3>
<table class="table table-sm table-bordered index-table">
<tbody>
<tr>
<td class="col-md-4">
<h6><b>Properties</b></h6>
</td>
</tr>
<tr>
<td class="col-md-4">
<ul class="index-list">
<li>
<a href="#pit" >pit</a>
</li>
<li>
<a href="#query" >query</a>
</li>
<li>
<a href="#size" >size</a>
</li>
<li>
<a href="#sort" >sort</a>
</li>
</ul>
</td>
</tr>
</tbody>
</table>
</section>
<section>
<h3 id="inputs">
Properties
</h3>
<table class="table table-sm table-bordered">
<tbody>
<tr>
<td class="col-md-4">
<a name="pit"></a>
<span class="name">
<span ><b>pit</b></span>
<a href="#pit"><span class="icon ion-ios-link"></span></a>
</span>
</td>
</tr>
<tr>
<td class="col-md-4">
<i>Type : </i> <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/object" target="_blank" >object</a></code>
</td>
</tr>
<tr>
<td class="col-md-4">
<div class="io-line">Defined in <a href="" data-line="39" class="link-to-prism">src/core/domain/dtos/es-query.dto.ts:39</a></div>
</td>
</tr>
<tr>
<td class="col-md-4">
<div class="io-description"><p>Object, that stores Point-In-Time ID and time alive</p>
</div>
</td>
</tr>
</tbody>
</table>
<table class="table table-sm table-bordered">
<tbody>
<tr>
<td class="col-md-4">
<a name="query"></a>
<span class="name">
<span ><b>query</b></span>
<a href="#query"><span class="icon ion-ios-link"></span></a>
</span>
</td>
</tr>
<tr>
<td class="col-md-4">
<i>Type : </i> <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/object" target="_blank" >object</a></code>
</td>
</tr>
<tr>
<td class="col-md-4">
<b>Decorators : </b>
<br />
<code>
@IsDefined()<br />@IsObject()<br />@ApiProperty({description: &#x27;Search query object passed to Elasticsearch&#x27;, example: false})<br />
</code>
</td>
</tr>
<tr>
<td class="col-md-4">
<div class="io-line">Defined in <a href="" data-line="34" class="link-to-prism">src/core/domain/dtos/es-query.dto.ts:34</a></div>
</td>
</tr>
<tr>
<td class="col-md-4">
<div class="io-description"><p>The search query object passed to Elasticsearch</p>
</div>
</td>
</tr>
</tbody>
</table>
<table class="table table-sm table-bordered">
<tbody>
<tr>
<td class="col-md-4">
<a name="size"></a>
<span class="name">
<span ><b>size</b></span>
<a href="#size"><span class="icon ion-ios-link"></span></a>
</span>
</td>
</tr>
<tr>
<td class="col-md-4">
<i>Type : </i> <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/number" target="_blank" >number</a></code>
</td>
</tr>
<tr>
<td class="col-md-4">
<b>Decorators : </b>
<br />
<code>
@IsDefined()<br />@IsNumber()<br />@IsInt()<br />@ApiProperty({description: &#x27;Maximum number of elements returned by Elasticsearch&#x27;, example: 30})<br />
</code>
</td>
</tr>
<tr>
<td class="col-md-4">
<div class="io-line">Defined in <a href="" data-line="23" class="link-to-prism">src/core/domain/dtos/es-query.dto.ts:23</a></div>
</td>
</tr>
<tr>
<td class="col-md-4">
<div class="io-description"><p>Maximum number of elements returned by Elasticsearch</p>
</div>
</td>
</tr>
</tbody>
</table>
<table class="table table-sm table-bordered">
<tbody>
<tr>
<td class="col-md-4">
<a name="sort"></a>
<span class="name">
<span ><b>sort</b></span>
<a href="#sort"><span class="icon ion-ios-link"></span></a>
</span>
</td>
</tr>
<tr>
<td class="col-md-4">
<i>Type : </i> <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/object" target="_blank" >object</a></code>
</td>
</tr>
<tr>
<td class="col-md-4">
<div class="io-line">Defined in <a href="" data-line="44" class="link-to-prism">src/core/domain/dtos/es-query.dto.ts:44</a></div>
</td>
</tr>
<tr>
<td class="col-md-4">
<div class="io-description"><p>Object, that stores</p>
</div>
</td>
</tr>
</tbody>
</table>
</section>
</div>
<div class="tab-pane fade tab-source-code" id="c-source">
<pre class="line-numbers compodoc-sourcecode"><code class="language-typescript">import { ApiProperty } from &quot;@nestjs/swagger&quot;;
import { IsDefined, IsInt, IsNotEmpty, IsNumber, IsObject } from &quot;class-validator&quot;;
/**
* List of allowed properties in this DTO
*/
const allowedProperties &#x3D; [&#x27;size&#x27;, &#x27;query&#x27;, &#x27;pit&#x27;, &#x27;sort&#x27;];
/**
* Elasticsearch query DTO
*/
export class EsQueryDto {
/**
* Maximum number of elements returned by Elasticsearch
*/
@IsDefined()
@IsNumber()
@IsInt()
@ApiProperty({
description: &#x27;Maximum number of elements returned by Elasticsearch&#x27;,
example: 30
})
size: number;
/**
* The search query object passed to Elasticsearch
*/
@IsDefined()
@IsObject()
@ApiProperty({
description: &#x27;Search query object passed to Elasticsearch&#x27;,
example: false,
})
query: object;
/**
* Object, that stores Point-In-Time ID and time alive
*/
pit: object;
/**
* Object, that stores
*/
sort: object;
}</code></pre>
</div>
</div>
</div><div class="search-results">
<div class="has-results">
<h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
<ul class="search-results-list"></ul>
</div>
<div class="no-results">
<h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
</div>
</div>
</div>
<!-- END CONTENT -->
</div>
</div>
<label class="dark-mode-switch">
<input type="checkbox">
<span class="slider">
<svg class="slider-icon" viewBox="0 0 24 24" fill="none" height="20" stroke="#000" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" width="20" xmlns="http://www.w3.org/2000/svg">
<path d="M21 12.79A9 9 0 1111.21 3 7 7 0 0021 12.79z"></path>
</svg>
</span>
</label>
<script>
var COMPODOC_CURRENT_PAGE_DEPTH = 1;
var COMPODOC_CURRENT_PAGE_CONTEXT = 'class';
var COMPODOC_CURRENT_PAGE_URL = 'EsQueryDto.html';
var MAX_SEARCH_RESULTS = 15;
</script>
<script src="../js/libs/custom-elements.min.js"></script>
<script src="../js/libs/lit-html.js"></script>
<script src="../js/menu-wc.js" defer></script>
<script nomodule src="../js/menu-wc_es5.js" defer></script>
<script src="../js/libs/bootstrap-native.js"></script>
<script src="../js/libs/es6-shim.min.js"></script>
<script src="../js/libs/EventDispatcher.js"></script>
<script src="../js/libs/promise.min.js"></script>
<script src="../js/libs/zepto.min.js"></script>
<script src="../js/compodoc.js"></script>
<script src="../js/tabs.js"></script>
<script src="../js/menu.js"></script>
<script src="../js/libs/clipboard.min.js"></script>
<script src="../js/libs/prism.js"></script>
<script src="../js/sourceCode.js"></script>
<script src="../js/search/search.js"></script>
<script src="../js/search/lunr.min.js"></script>
<script src="../js/search/search-lunr.js"></script>
<script src="../js/search/search_index.js"></script>
<script src="../js/lazy-load-graphs.js"></script>
</body>
</html>

@ -115,6 +115,92 @@
</table>
</section>
<section>
<h3 id="constructor">Constructor</h3>
<table class="table table-sm table-bordered">
<tbody>
<tr>
<td class="col-md-4">
<code>constructor(query: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string" target="_blank">string</a>, page: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/number" target="_blank">number</a>, limit: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/number" target="_blank">number</a>, order: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string" target="_blank">string</a>)</code>
</td>
</tr>
<tr>
<td class="col-md-4">
<div class="io-line">Defined in <a href="" data-line="58" class="link-to-prism">src/core/domain/dtos/search-q.dto.ts:58</a></div>
</td>
</tr>
<tr>
<td class="col-md-4">
<div class="io-description"><p>Constructs an object with provided parameters</p>
</div>
<div>
<b>Parameters :</b>
<table class="params">
<thead>
<tr>
<td>Name</td>
<td>Type</td>
<td>Optional</td>
</tr>
</thead>
<tbody>
<tr>
<td>query</td>
<td>
<code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string" target="_blank" >string</a></code>
</td>
<td>
No
</td>
</tr>
<tr>
<td>page</td>
<td>
<code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/number" target="_blank" >number</a></code>
</td>
<td>
No
</td>
</tr>
<tr>
<td>limit</td>
<td>
<code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/number" target="_blank" >number</a></code>
</td>
<td>
No
</td>
</tr>
<tr>
<td>order</td>
<td>
<code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string" target="_blank" >string</a></code>
</td>
<td>
No
</td>
</tr>
</tbody>
</table>
</div>
</td>
</tr>
</tbody>
</table>
</section>
<section>
@ -356,6 +442,20 @@ export class SearchQueryDto {
example: &#x27;asc&#x27;,
})
order: string;
/**
* Constructs an object with provided parameters
* @param query
* @param page
* @param limit
* @param order
*/
constructor(query: string, page: number, limit: number, order: string) {
this.query &#x3D; query;
this.page &#x3D; page;
this.limit &#x3D; limit;
this.order &#x3D; order;
}
}</code></pre>
</div>
</div>

@ -94,7 +94,7 @@
<a href="#data" >data</a>
</li>
<li>
<a href="#status" >status</a>
<a href="#statusCode" >statusCode</a>
</li>
</ul>
</td>
@ -222,10 +222,10 @@
<tbody>
<tr>
<td class="col-md-4">
<a name="status"></a>
<a name="statusCode"></a>
<span class="name">
<span ><b>status</b></span>
<a href="#status"><span class="icon ion-ios-link"></span></a>
<span ><b>statusCode</b></span>
<a href="#statusCode"><span class="icon ion-ios-link"></span></a>
</span>
</td>
</tr>
@ -293,7 +293,7 @@ export class SearchResultDto {
description: &#x27;Status code&#x27;,
example: 200,
})
status: number;
statusCode: number;
/**
* All the data acquired.
@ -315,7 +315,7 @@ export class SearchResultDto {
* @param data
*/
constructor(code: number, data: object) {
this.status &#x3D; code;
this.statusCode &#x3D; code;
this.data &#x3D; data;
}
}</code></pre>

@ -141,8 +141,8 @@
<tr>
<td class="col-md-4">
<div class="io-line">Defined in <a href="" data-line="31"
class="link-to-prism">src/application/controller/papers.controller.ts:31</a></div>
<div class="io-line">Defined in <a href="" data-line="32"
class="link-to-prism">src/application/controller/papers.controller.ts:32</a></div>
</td>
</tr>
@ -210,14 +210,14 @@
<td class="col-md-4">
<b>Decorators : </b>
<br />
<code>@ApiOperation({summary: &#x27;Finds paper by its UUID.&#x27;})<br />@ApiResponse({status: 200, description: &#x27;Returns back acquired paper.&#x27;, type: SearchResultDto})<br />@Get(&#x27;:uuid&#x27;)<br /></code>
<code>@ApiOperation({summary: &#x27;Finds paper by its UUID.&#x27;})<br />@ApiResponse({status: 200, description: &#x27;Returns back acquired paper.&#x27;, type: SearchResultDto})<br />@Get(&#x27;:uuid&#x27;)<br />@UseInterceptors(PageInterceptor)<br />@HttpCode(200)<br /></code>
</td>
</tr>
<tr>
<td class="col-md-4">
<div class="io-line">Defined in <a href="" data-line="56"
class="link-to-prism">src/application/controller/papers.controller.ts:56</a></div>
<div class="io-line">Defined in <a href="" data-line="58"
class="link-to-prism">src/application/controller/papers.controller.ts:58</a></div>
</td>
</tr>
@ -279,6 +279,7 @@ import { PageInterceptor } from &quot;src/core/interceptors/page.interceptor&quo
import { LoggerInterceptor } from &quot;src/core/interceptors&quot;;
import { SearchResultDto } from &quot;src/core/domain/dtos/search-result.dto&quot;;
import { ApiOperation, ApiResponse } from &quot;@nestjs/swagger&quot;;
import { SearchQueryDto } from &quot;src/core/domain/dtos&quot;;
/**
* /papers/ route controller
@ -305,11 +306,10 @@ export class PapersController {
getByContext(@Query() query): object {
return this.searchService.findByContext(query.query).then(
(response: SearchResultDto) &#x3D;&gt; {
// console.log(JSON.stringify(response.data, null, 2));
return response.data;
},
(error: SearchResultDto) &#x3D;&gt; {
throw new HttpException(error.data, error.status);
throw new HttpException(error.data, error.statusCode);
}
);
}
@ -326,11 +326,12 @@ export class PapersController {
description: &#x27;Returns back acquired paper.&#x27;,
type: SearchResultDto,
})
@Get(&#x27;:uuid&#x27;)
@Get(&#x27;:uuid&#x27;)
@UseInterceptors(PageInterceptor)
@HttpCode(200)
getByID(@Param(&#x27;uuid&#x27;, ParseUUIDPipe) uuid: string): object {
return this.searchService.findByID(uuid).then(
(response) &#x3D;&gt; {
// console.log(JSON.stringify(response.data, null, 2));
return response.data;
},
(error) &#x3D;&gt; {

@ -140,6 +140,30 @@
<span class="coverage-count">(1/1)</span>
</td>
</tr>
<tr class="very-good">
<td>
<!-- miscellaneous -->
<a href="./classes/EsQueryDto.html">src/core/domain/dtos/es-query.dto.ts</a>
</td>
<td>class</td>
<td>EsQueryDto</td>
<td align="right" data-sort="100">
<span class="coverage-percent">100 %</span>
<span class="coverage-count">(5/5)</span>
</td>
</tr>
<tr class="very-good">
<td>
<!-- miscellaneous -->
<a href="./miscellaneous/variables.html#allowedProperties">src/core/domain/dtos/es-query.dto.ts</a>
</td>
<td>variable</td>
<td>allowedProperties</td>
<td align="right" data-sort="100">
<span class="coverage-percent">100 %</span>
<span class="coverage-count">(1/1)</span>
</td>
</tr>
<tr class="very-good">
<td>
<!-- miscellaneous -->
@ -197,7 +221,7 @@
<td>SearchQueryDto</td>
<td align="right" data-sort="100">
<span class="coverage-percent">100 %</span>
<span class="coverage-count">(5/5)</span>
<span class="coverage-count">(6/6)</span>
</td>
</tr>
<tr class="very-good">
@ -257,7 +281,7 @@
<td>PageMeta</td>
<td align="right" data-sort="100">
<span class="coverage-percent">100 %</span>
<span class="coverage-count">(6/6)</span>
<span class="coverage-count">(7/7)</span>
</td>
</tr>
<tr class="very-good">
@ -425,7 +449,7 @@
<td>SearchService</td>
<td align="right" data-sort="100">
<span class="coverage-percent">100 %</span>
<span class="coverage-count">(5/5)</span>
<span class="coverage-count">(7/7)</span>
</td>
</tr>
<tr class="very-good">

@ -4,217 +4,217 @@
<!-- Generated by graphviz version 5.0.0 (20220707.1540)
-->
<!-- Title: dependencies Pages: 1 -->
<svg width="1322pt" height="329pt"
viewBox="0.00 0.00 1322.00 328.80" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 324.8)">
<svg width="876pt" height="413pt"
viewBox="0.00 0.00 876.00 412.80" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 408.8)">
<title>dependencies</title>
<polygon fill="white" stroke="transparent" points="-4,4 -4,-324.8 1318,-324.8 1318,4 -4,4"/>
<text text-anchor="middle" x="657" y="-8.2" font-family="sans-serif" font-size="14.00">dependencies</text>
<g id="clust25" class="cluster">
<title>cluster_LoggerModule</title>
<polygon fill="none" stroke="black" stroke-dasharray="1,5" points="1138,-32.8 1138,-236.8 1306,-236.8 1306,-32.8 1138,-32.8"/>
</g>
<g id="clust28" class="cluster">
<title>cluster_LoggerModule_exports</title>
<polygon fill="none" stroke="black" points="1154,-176.8 1154,-228.8 1272,-228.8 1272,-176.8 1154,-176.8"/>
</g>
<g id="clust30" class="cluster">
<title>cluster_LoggerModule_providers</title>
<polygon fill="none" stroke="black" points="1146,-40.8 1146,-92.8 1298,-92.8 1298,-40.8 1146,-40.8"/>
</g>
<g id="clust7" class="cluster">
<title>cluster_CommonModule</title>
<polygon fill="none" stroke="black" stroke-dasharray="1,5" points="834,-100.8 834,-312.8 1130,-312.8 1130,-100.8 834,-100.8"/>
</g>
<g id="clust9" class="cluster">
<title>cluster_CommonModule_imports</title>
<polygon fill="none" stroke="black" points="842,-108.8 842,-160.8 996,-160.8 996,-108.8 842,-108.8"/>
</g>
<g id="clust10" class="cluster">
<title>cluster_CommonModule_exports</title>
<polygon fill="none" stroke="black" points="842,-252.8 842,-304.8 1122,-304.8 1122,-252.8 842,-252.8"/>
</g>
<polygon fill="white" stroke="transparent" points="-4,4 -4,-408.8 872,-408.8 872,4 -4,4"/>
<text text-anchor="middle" x="434" y="-8.2" font-family="sans-serif" font-size="14.00">dependencies</text>
<g id="clust1" class="cluster">
<title>cluster_AppModule</title>
<polygon fill="none" stroke="black" stroke-dasharray="1,5" points="304,-168.8 304,-304.8 434,-304.8 434,-168.8 304,-168.8"/>
<polygon fill="none" stroke="black" stroke-dasharray="1,5" points="100,-176.8 100,-312.8 360,-312.8 360,-176.8 100,-176.8"/>
</g>
<g id="clust3" class="cluster">
<title>cluster_AppModule_imports</title>
<polygon fill="none" stroke="black" points="312,-176.8 312,-228.8 426,-228.8 426,-176.8 312,-176.8"/>
<polygon fill="none" stroke="black" points="108,-184.8 108,-236.8 352,-236.8 352,-184.8 108,-184.8"/>
</g>
<g id="clust19" class="cluster">
<title>cluster_HttpResponseModule</title>
<polygon fill="none" stroke="black" stroke-dasharray="1,5" points="442,-168.8 442,-236.8 826,-236.8 826,-168.8 442,-168.8"/>
<polygon fill="none" stroke="black" stroke-dasharray="1,5" points="368,-32.8 368,-244.8 588,-244.8 588,-32.8 368,-32.8"/>
</g>
<g id="clust22" class="cluster">
<title>cluster_HttpResponseModule_exports</title>
<polygon fill="none" stroke="black" points="662,-176.8 662,-228.8 818,-228.8 818,-176.8 662,-176.8"/>
<polygon fill="none" stroke="black" points="388,-184.8 388,-236.8 544,-236.8 544,-184.8 388,-184.8"/>
</g>
<g id="clust24" class="cluster">
<title>cluster_HttpResponseModule_providers</title>
<polygon fill="none" stroke="black" points="450,-176.8 450,-228.8 654,-228.8 654,-176.8 450,-176.8"/>
<polygon fill="none" stroke="black" points="376,-40.8 376,-92.8 580,-92.8 580,-40.8 376,-40.8"/>
</g>
<g id="clust7" class="cluster">
<title>cluster_CommonModule</title>
<polygon fill="none" stroke="black" stroke-dasharray="1,5" points="368,-252.8 368,-320.8 788,-320.8 788,-252.8 368,-252.8"/>
</g>
<g id="clust9" class="cluster">
<title>cluster_CommonModule_imports</title>
<polygon fill="none" stroke="black" points="664,-260.8 664,-312.8 780,-312.8 780,-260.8 664,-260.8"/>
</g>
<g id="clust10" class="cluster">
<title>cluster_CommonModule_exports</title>
<polygon fill="none" stroke="black" points="376,-260.8 376,-312.8 656,-312.8 656,-260.8 376,-260.8"/>
</g>
<g id="clust25" class="cluster">
<title>cluster_LoggerModule</title>
<polygon fill="none" stroke="black" stroke-dasharray="1,5" points="566,-328.8 566,-396.8 860,-396.8 860,-328.8 566,-328.8"/>
</g>
<g id="clust28" class="cluster">
<title>cluster_LoggerModule_exports</title>
<polygon fill="none" stroke="black" points="734,-336.8 734,-388.8 852,-388.8 852,-336.8 734,-336.8"/>
</g>
<g id="clust30" class="cluster">
<title>cluster_LoggerModule_providers</title>
<polygon fill="none" stroke="black" points="574,-336.8 574,-388.8 726,-388.8 726,-336.8 574,-336.8"/>
</g>
<g id="clust31" class="cluster">
<title>cluster_SearchModule</title>
<polygon fill="none" stroke="black" stroke-dasharray="1,5" points="8,-244.8 8,-312.8 296,-312.8 296,-244.8 8,-244.8"/>
<polygon fill="none" stroke="black" stroke-dasharray="1,5" points="8,-100.8 8,-168.8 296,-168.8 296,-100.8 8,-100.8"/>
</g>
<g id="clust34" class="cluster">
<title>cluster_SearchModule_exports</title>
<polygon fill="none" stroke="black" points="172,-252.8 172,-304.8 288,-304.8 288,-252.8 172,-252.8"/>
<polygon fill="none" stroke="black" points="172,-108.8 172,-160.8 288,-160.8 288,-108.8 172,-108.8"/>
</g>
<g id="clust36" class="cluster">
<title>cluster_SearchModule_providers</title>
<polygon fill="none" stroke="black" points="16,-252.8 16,-304.8 164,-304.8 164,-252.8 16,-252.8"/>
<polygon fill="none" stroke="black" points="16,-108.8 16,-160.8 164,-160.8 164,-108.8 16,-108.8"/>
</g>
<!-- CommonModule -->
<g id="node1" class="node">
<title>CommonModule</title>
<polygon fill="#8dd3c7" stroke="black" points="974.67,-220.8 971.67,-224.8 950.67,-224.8 947.67,-220.8 863.33,-220.8 863.33,-184.8 974.67,-184.8 974.67,-220.8"/>
<text text-anchor="middle" x="919" y="-198.6" font-family="Times,serif" font-size="14.00">CommonModule</text>
<polygon fill="#8dd3c7" stroke="black" points="343.67,-228.8 340.67,-232.8 319.67,-232.8 316.67,-228.8 232.33,-228.8 232.33,-192.8 343.67,-192.8 343.67,-228.8"/>
<text text-anchor="middle" x="288" y="-206.6" font-family="Times,serif" font-size="14.00">CommonModule</text>
</g>
<!-- AppModule -->
<g id="node3" class="node">
<title>AppModule</title>
<polygon fill="#8dd3c7" stroke="black" points="417.66,-296.8 414.66,-300.8 393.66,-300.8 390.66,-296.8 334.34,-296.8 334.34,-260.8 417.66,-260.8 417.66,-296.8"/>
<text text-anchor="middle" x="376" y="-274.6" font-family="Times,serif" font-size="14.00">AppModule</text>
<polygon fill="#8dd3c7" stroke="black" points="267.66,-304.8 264.66,-308.8 243.66,-308.8 240.66,-304.8 184.34,-304.8 184.34,-268.8 267.66,-268.8 267.66,-304.8"/>
<text text-anchor="middle" x="226" y="-282.6" font-family="Times,serif" font-size="14.00">AppModule</text>
</g>
<!-- CommonModule&#45;&gt;AppModule -->
<g id="edge1" class="edge">
<title>CommonModule&#45;&gt;AppModule</title>
<path fill="none" stroke="black" d="M863.13,-208.8C845.24,-208.8 829.98,-208.8 829.98,-208.8 829.98,-208.8 829.98,-278.8 829.98,-278.8 829.98,-278.8 427.9,-278.8 427.9,-278.8"/>
<polygon fill="black" stroke="black" points="427.9,-275.3 417.9,-278.8 427.9,-282.3 427.9,-275.3"/>
<path fill="none" stroke="black" d="M250,-228.81C250,-228.81 250,-258.65 250,-258.65"/>
<polygon fill="black" stroke="black" points="246.5,-258.65 250,-268.65 253.5,-258.65 246.5,-258.65"/>
</g>
<!-- HttpResponseModule -->
<g id="node6" class="node">
<title>HttpResponseModule </title>
<polygon fill="#fb8072" stroke="black" points="1113.6,-296.8 972.4,-296.8 972.4,-260.8 1113.6,-260.8 1113.6,-296.8"/>
<text text-anchor="middle" x="1043" y="-274.6" font-family="Times,serif" font-size="14.00">HttpResponseModule </text>
<polygon fill="#fb8072" stroke="black" points="647.6,-304.8 506.4,-304.8 506.4,-268.8 647.6,-268.8 647.6,-304.8"/>
<text text-anchor="middle" x="577" y="-282.6" font-family="Times,serif" font-size="14.00">HttpResponseModule </text>
</g>
<!-- CommonModule&#45;&gt;HttpResponseModule -->
<g id="edge5" class="edge">
<title>CommonModule&#45;&gt;HttpResponseModule </title>
<path fill="none" stroke="black" stroke-dasharray="5,2" d="M974.76,-208.8C978.87,-208.8 981.44,-208.8 981.44,-208.8 981.44,-208.8 981.44,-250.77 981.44,-250.77"/>
<polygon fill="black" stroke="black" points="977.94,-250.77 981.44,-260.77 984.94,-250.77 977.94,-250.77"/>
<path fill="none" stroke="black" stroke-dasharray="5,2" d="M318.5,-228.84C318.5,-241.36 318.5,-255.8 318.5,-255.8 318.5,-255.8 521.11,-255.8 521.11,-255.8 521.11,-255.8 521.11,-258.77 521.11,-258.77"/>
<polygon fill="black" stroke="black" points="517.61,-258.77 521.11,-268.77 524.61,-258.77 517.61,-258.77"/>
</g>
<!-- LoggerModule -->
<g id="node7" class="node">
<title>LoggerModule </title>
<polygon fill="#fb8072" stroke="black" points="953.98,-296.8 850.02,-296.8 850.02,-260.8 953.98,-260.8 953.98,-296.8"/>
<text text-anchor="middle" x="902" y="-274.6" font-family="Times,serif" font-size="14.00">LoggerModule </text>
<polygon fill="#fb8072" stroke="black" points="487.98,-304.8 384.02,-304.8 384.02,-268.8 487.98,-268.8 487.98,-304.8"/>
<text text-anchor="middle" x="436" y="-282.6" font-family="Times,serif" font-size="14.00">LoggerModule </text>
</g>
<!-- CommonModule&#45;&gt;LoggerModule -->
<g id="edge6" class="edge">
<title>CommonModule&#45;&gt;LoggerModule </title>
<path fill="none" stroke="black" stroke-dasharray="5,2" d="M908.45,-220.81C908.45,-220.81 908.45,-250.65 908.45,-250.65"/>
<polygon fill="black" stroke="black" points="904.95,-250.65 908.45,-260.65 911.95,-250.65 904.95,-250.65"/>
<path fill="none" stroke="black" stroke-dasharray="5,2" d="M343.84,-210.8C367.68,-210.8 390.12,-210.8 390.12,-210.8 390.12,-210.8 390.12,-258.79 390.12,-258.79"/>
<polygon fill="black" stroke="black" points="386.62,-258.79 390.12,-268.79 393.62,-258.79 386.62,-258.79"/>
</g>
<!-- SearchModule -->
<g id="node2" class="node">
<title>SearchModule</title>
<polygon fill="#8dd3c7" stroke="black" points="417.64,-220.8 414.64,-224.8 393.64,-224.8 390.64,-220.8 320.36,-220.8 320.36,-184.8 417.64,-184.8 417.64,-220.8"/>
<text text-anchor="middle" x="369" y="-198.6" font-family="Times,serif" font-size="14.00">SearchModule</text>
<polygon fill="#8dd3c7" stroke="black" points="213.64,-228.8 210.64,-232.8 189.64,-232.8 186.64,-228.8 116.36,-228.8 116.36,-192.8 213.64,-192.8 213.64,-228.8"/>
<text text-anchor="middle" x="165" y="-206.6" font-family="Times,serif" font-size="14.00">SearchModule</text>
</g>
<!-- SearchModule&#45;&gt;AppModule -->
<g id="edge2" class="edge">
<title>SearchModule&#45;&gt;AppModule</title>
<path fill="none" stroke="black" d="M375.99,-220.81C375.99,-220.81 375.99,-250.65 375.99,-250.65"/>
<polygon fill="black" stroke="black" points="372.49,-250.65 375.99,-260.65 379.49,-250.65 372.49,-250.65"/>
<path fill="none" stroke="black" d="M198.99,-228.81C198.99,-228.81 198.99,-258.65 198.99,-258.65"/>
<polygon fill="black" stroke="black" points="195.49,-258.65 198.99,-268.65 202.49,-258.65 195.49,-258.65"/>
</g>
<!-- SearchService -->
<g id="node12" class="node">
<title>SearchService </title>
<polygon fill="#fb8072" stroke="black" points="279.57,-296.8 180.43,-296.8 180.43,-260.8 279.57,-260.8 279.57,-296.8"/>
<text text-anchor="middle" x="230" y="-274.6" font-family="Times,serif" font-size="14.00">SearchService </text>
<polygon fill="#fb8072" stroke="black" points="279.57,-152.8 180.43,-152.8 180.43,-116.8 279.57,-116.8 279.57,-152.8"/>
<text text-anchor="middle" x="230" y="-130.6" font-family="Times,serif" font-size="14.00">SearchService </text>
</g>
<!-- SearchModule&#45;&gt;SearchService -->
<g id="edge11" class="edge">
<title>SearchModule&#45;&gt;SearchService </title>
<path fill="none" stroke="black" stroke-dasharray="5,2" d="M327.17,-220.81C327.17,-243.29 327.17,-278.8 327.17,-278.8 327.17,-278.8 289.73,-278.8 289.73,-278.8"/>
<polygon fill="black" stroke="black" points="289.73,-275.3 279.73,-278.8 289.73,-282.3 289.73,-275.3"/>
<path fill="none" stroke="black" stroke-dasharray="5,2" d="M197.02,-192.79C197.02,-192.79 197.02,-162.95 197.02,-162.95"/>
<polygon fill="black" stroke="black" points="200.52,-162.95 197.02,-152.95 193.52,-162.95 200.52,-162.95"/>
</g>
<!-- HttpResponseModule -->
<g id="node4" class="node">
<title>HttpResponseModule</title>
<polygon fill="#8dd3c7" stroke="black" points="988.1,-152.8 985.1,-156.8 964.1,-156.8 961.1,-152.8 849.9,-152.8 849.9,-116.8 988.1,-116.8 988.1,-152.8"/>
<text text-anchor="middle" x="919" y="-130.6" font-family="Times,serif" font-size="14.00">HttpResponseModule</text>
<polygon fill="#8dd3c7" stroke="black" points="535.1,-152.8 532.1,-156.8 511.1,-156.8 508.1,-152.8 396.9,-152.8 396.9,-116.8 535.1,-116.8 535.1,-152.8"/>
<text text-anchor="middle" x="466" y="-130.6" font-family="Times,serif" font-size="14.00">HttpResponseModule</text>
</g>
<!-- HttpResponseModule&#45;&gt;CommonModule -->
<g id="edge3" class="edge">
<title>HttpResponseModule&#45;&gt;CommonModule</title>
<path fill="none" stroke="black" d="M919,-153.02C919,-153.02 919,-174.53 919,-174.53"/>
<polygon fill="black" stroke="black" points="915.5,-174.53 919,-184.53 922.5,-174.53 915.5,-174.53"/>
<path fill="none" stroke="black" d="M396.57,-134.8C355.65,-134.8 311.81,-134.8 311.81,-134.8 311.81,-134.8 311.81,-182.79 311.81,-182.79"/>
<polygon fill="black" stroke="black" points="308.31,-182.79 311.81,-192.79 315.31,-182.79 308.31,-182.79"/>
</g>
<!-- HttpResponseService -->
<g id="node8" class="node">
<title>HttpResponseService </title>
<polygon fill="#fb8072" stroke="black" points="810.03,-220.8 669.97,-220.8 669.97,-184.8 810.03,-184.8 810.03,-220.8"/>
<text text-anchor="middle" x="740" y="-198.6" font-family="Times,serif" font-size="14.00">HttpResponseService </text>
<polygon fill="#fb8072" stroke="black" points="536.03,-228.8 395.97,-228.8 395.97,-192.8 536.03,-192.8 536.03,-228.8"/>
<text text-anchor="middle" x="466" y="-206.6" font-family="Times,serif" font-size="14.00">HttpResponseService </text>
</g>
<!-- HttpResponseModule&#45;&gt;HttpResponseService -->
<g id="edge7" class="edge">
<title>HttpResponseModule&#45;&gt;HttpResponseService </title>
<path fill="none" stroke="black" stroke-dasharray="5,2" d="M856.71,-153.07C856.71,-171.36 856.71,-196.8 856.71,-196.8 856.71,-196.8 820.25,-196.8 820.25,-196.8"/>
<polygon fill="black" stroke="black" points="820.25,-193.3 810.25,-196.8 820.25,-200.3 820.25,-193.3"/>
<path fill="none" stroke="black" stroke-dasharray="5,2" d="M466,-152.81C466,-152.81 466,-182.65 466,-182.65"/>
<polygon fill="black" stroke="black" points="462.5,-182.65 466,-192.65 469.5,-182.65 462.5,-182.65"/>
</g>
<!-- LoggerModule -->
<g id="node5" class="node">
<title>LoggerModule</title>
<polygon fill="#8dd3c7" stroke="black" points="1262.98,-152.8 1259.98,-156.8 1238.98,-156.8 1235.98,-152.8 1163.02,-152.8 1163.02,-116.8 1262.98,-116.8 1262.98,-152.8"/>
<text text-anchor="middle" x="1213" y="-130.6" font-family="Times,serif" font-size="14.00">LoggerModule</text>
<polygon fill="#8dd3c7" stroke="black" points="771.98,-304.8 768.98,-308.8 747.98,-308.8 744.98,-304.8 672.02,-304.8 672.02,-268.8 771.98,-268.8 771.98,-304.8"/>
<text text-anchor="middle" x="722" y="-282.6" font-family="Times,serif" font-size="14.00">LoggerModule</text>
</g>
<!-- LoggerModule&#45;&gt;CommonModule -->
<g id="edge4" class="edge">
<title>LoggerModule&#45;&gt;CommonModule</title>
<path fill="none" stroke="black" d="M1162.77,-134.8C1159.86,-134.8 1158.08,-134.8 1158.08,-134.8 1158.08,-134.8 1158.08,-196.8 1158.08,-196.8 1158.08,-196.8 984.75,-196.8 984.75,-196.8"/>
<polygon fill="black" stroke="black" points="984.75,-193.3 974.75,-196.8 984.75,-200.3 984.75,-193.3"/>
<path fill="none" stroke="black" d="M722,-268.65C722,-256.53 722,-242.8 722,-242.8 722,-242.8 293.17,-242.8 293.17,-242.8 293.17,-242.8 293.17,-239.04 293.17,-239.04"/>
<polygon fill="black" stroke="black" points="296.67,-239.04 293.17,-229.04 289.67,-239.04 296.67,-239.04"/>
</g>
<!-- LoggerService -->
<g id="node10" class="node">
<title>LoggerService </title>
<polygon fill="#fb8072" stroke="black" points="1263.91,-220.8 1162.09,-220.8 1162.09,-184.8 1263.91,-184.8 1263.91,-220.8"/>
<text text-anchor="middle" x="1213" y="-198.6" font-family="Times,serif" font-size="14.00">LoggerService </text>
<polygon fill="#fb8072" stroke="black" points="843.91,-380.8 742.09,-380.8 742.09,-344.8 843.91,-344.8 843.91,-380.8"/>
<text text-anchor="middle" x="793" y="-358.6" font-family="Times,serif" font-size="14.00">LoggerService </text>
</g>
<!-- LoggerModule&#45;&gt;LoggerService -->
<g id="edge9" class="edge">
<title>LoggerModule&#45;&gt;LoggerService </title>
<path fill="none" stroke="black" stroke-dasharray="5,2" d="M1213,-153.02C1213,-153.02 1213,-174.53 1213,-174.53"/>
<polygon fill="black" stroke="black" points="1209.5,-174.53 1213,-184.53 1216.5,-174.53 1209.5,-174.53"/>
<path fill="none" stroke="black" stroke-dasharray="5,2" d="M757.02,-304.81C757.02,-304.81 757.02,-334.65 757.02,-334.65"/>
<polygon fill="black" stroke="black" points="753.52,-334.65 757.02,-344.65 760.52,-334.65 753.52,-334.65"/>
</g>
<!-- HttpResponseService -->
<g id="node9" class="node">
<title>HttpResponseService</title>
<ellipse fill="#fdb462" stroke="black" cx="552" cy="-202.8" rx="94.35" ry="18"/>
<text text-anchor="middle" x="552" y="-198.6" font-family="Times,serif" font-size="14.00">HttpResponseService</text>
<ellipse fill="#fdb462" stroke="black" cx="478" cy="-66.8" rx="94.35" ry="18"/>
<text text-anchor="middle" x="478" y="-62.6" font-family="Times,serif" font-size="14.00">HttpResponseService</text>
</g>
<!-- HttpResponseService&#45;&gt;HttpResponseModule -->
<g id="edge8" class="edge">
<title>HttpResponseService&#45;&gt;HttpResponseModule</title>
<path fill="none" stroke="black" d="M552,-184.58C552,-164.43 552,-134.8 552,-134.8 552,-134.8 839.54,-134.8 839.54,-134.8"/>
<polygon fill="black" stroke="black" points="839.54,-138.3 849.54,-134.8 839.54,-131.3 839.54,-138.3"/>
<path fill="none" stroke="black" d="M466,-84.67C466,-84.67 466,-106.34 466,-106.34"/>
<polygon fill="black" stroke="black" points="462.5,-106.34 466,-116.34 469.5,-106.34 462.5,-106.34"/>
</g>
<!-- LoggerService -->
<g id="node11" class="node">
<title>LoggerService</title>
<ellipse fill="#fdb462" stroke="black" cx="1222" cy="-66.8" rx="67.76" ry="18"/>
<text text-anchor="middle" x="1222" y="-62.6" font-family="Times,serif" font-size="14.00">LoggerService</text>
<ellipse fill="#fdb462" stroke="black" cx="650" cy="-362.8" rx="67.76" ry="18"/>
<text text-anchor="middle" x="650" y="-358.6" font-family="Times,serif" font-size="14.00">LoggerService</text>
</g>
<!-- LoggerService&#45;&gt;LoggerModule -->
<g id="edge10" class="edge">
<title>LoggerService&#45;&gt;LoggerModule</title>
<path fill="none" stroke="black" d="M1213,-84.67C1213,-84.67 1213,-106.34 1213,-106.34"/>
<polygon fill="black" stroke="black" points="1209.5,-106.34 1213,-116.34 1216.5,-106.34 1209.5,-106.34"/>
<path fill="none" stroke="black" d="M694.94,-349.21C694.94,-349.21 694.94,-314.84 694.94,-314.84"/>
<polygon fill="black" stroke="black" points="698.44,-314.84 694.94,-304.84 691.44,-314.84 698.44,-314.84"/>
</g>
<!-- SearchService -->
<g id="node13" class="node">
<title>SearchService</title>
<ellipse fill="#fdb462" stroke="black" cx="90" cy="-278.8" rx="66.03" ry="18"/>
<text text-anchor="middle" x="90" y="-274.6" font-family="Times,serif" font-size="14.00">SearchService</text>
<ellipse fill="#fdb462" stroke="black" cx="90" cy="-134.8" rx="66.03" ry="18"/>
<text text-anchor="middle" x="90" y="-130.6" font-family="Times,serif" font-size="14.00">SearchService</text>
</g>
<!-- SearchService&#45;&gt;SearchModule -->
<g id="edge12" class="edge">
<title>SearchService&#45;&gt;SearchModule</title>
<path fill="none" stroke="black" d="M90,-260.79C90,-238.31 90,-202.8 90,-202.8 90,-202.8 310.08,-202.8 310.08,-202.8"/>
<polygon fill="black" stroke="black" points="310.08,-206.3 320.08,-202.8 310.08,-199.3 310.08,-206.3"/>
<path fill="none" stroke="black" d="M136.22,-148.04C136.22,-148.04 136.22,-182.59 136.22,-182.59"/>
<polygon fill="black" stroke="black" points="132.72,-182.59 136.22,-192.59 139.72,-182.59 132.72,-182.59"/>
</g>
</g>
</svg>

Before

(image error) Size: 12 KiB

After

(image error) Size: 12 KiB

@ -127,8 +127,8 @@
<tr>
<td class="col-md-4">
<div class="io-line">Defined in <a href="" data-line="20"
class="link-to-prism">src/core/interceptors/page.interceptor.ts:20</a></div>
<div class="io-line">Defined in <a href="" data-line="21"
class="link-to-prism">src/core/interceptors/page.interceptor.ts:21</a></div>
</td>
</tr>
@ -180,7 +180,7 @@
<div>
</div>
<div class="io-description">
<b>Returns : </b> <code>Observable | Promise</code>
<b>Returns : </b> <code><a href="../classes/PageDto.html" target="_self" >Observable&lt;PageDto&lt;object&gt;&gt;</a></code>
</div>
<div class="io-description">
@ -202,6 +202,7 @@ import { MetadataScanner } from &quot;@nestjs/core&quot;;
import { Observable, map } from &quot;rxjs&quot;;
import { PageDto } from &quot;../domain/dtos&quot;;
import { SearchQueryDto } from &quot;../domain/dtos/search-q.dto&quot;;
import { SearchResultDto } from &quot;../domain/dtos/search-result.dto&quot;;
import { Order } from &quot;../domain/enums/page-order.enum&quot;;
import { PageMeta } from &quot;../domain/interfaces&quot;;
@ -216,20 +217,19 @@ export class PageInterceptor implements NestInterceptor {
* @param next
* @returns Page with content and metadata
*/
intercept(context: ExecutionContext, next: CallHandler&lt;any&gt;): Observable&lt;any&gt; | Promise&lt;Observable&lt;any&gt;&gt; {
intercept(context: ExecutionContext, next: CallHandler&lt;any&gt;): Observable&lt;PageDto&lt;object&gt;&gt; {
const request &#x3D; context.switchToHttp().getRequest();
const query: SearchQueryDto &#x3D; request.query;
return next.handle().pipe(
map((res) &#x3D;&gt; {
if (!res.hits) return res;
let meta: PageMeta &#x3D; {
pagenum: +query?.page,
total: res.total.value,
pagenum: !query?.page ? 1 : query.page,
order: query?.order?.toUpperCase() &#x3D;&#x3D;&#x3D; Order.ASC ? Order.ASC : Order.DESC,
hasNext: false,
hasPrev: false,
pagesize: !query?.limit ? 1 : query.limit,
pagesize: !query?.limit ? 10 : query.limit,
};
meta.hasNext &#x3D; res.hits[meta.pagenum * meta.pagesize] ? true : false;

@ -102,6 +102,10 @@
<tr>
<td class="col-md-4">
<ul class="index-list">
<li>
<span class="modifier">Async</span>
<a href="#deletePIT" >deletePIT</a>
</li>
<li>
<span class="modifier">Async</span>
<a href="#findByContext" >findByContext</a>
@ -110,6 +114,10 @@
<span class="modifier">Async</span>
<a href="#findByID" >findByID</a>
</li>
<li>
<span class="modifier">Async</span>
<a href="#getPIT" >getPIT</a>
</li>
</ul>
</td>
</tr>
@ -179,6 +187,85 @@ HTTPService instance</p>
<h3 id="methods">
Methods
</h3>
<table class="table table-sm table-bordered">
<tbody>
<tr>
<td class="col-md-4">
<a name="deletePIT"></a>
<span class="name">
<span class="modifier">Async</span>
<span ><b>deletePIT</b></span>
<a href="#deletePIT"><span class="icon ion-ios-link"></span></a>
</span>
</td>
</tr>
<tr>
<td class="col-md-4">
<span class="modifier-icon icon ion-ios-reset"></span>
<code>deletePIT(pitID: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string" target="_blank">string</a>)</code>
</td>
</tr>
<tr>
<td class="col-md-4">
<div class="io-line">Defined in <a href="" data-line="119"
class="link-to-prism">src/core/services/common/search.service.ts:119</a></div>
</td>
</tr>
<tr>
<td class="col-md-4">
<div class="io-description"><p>Deletes the PIT specified by provided ID</p>
</div>
<div class="io-description">
<b>Parameters :</b>
<table class="params">
<thead>
<tr>
<td>Name</td>
<td>Type</td>
<td>Optional</td>
<td>Description</td>
</tr>
</thead>
<tbody>
<tr>
<td>pitID</td>
<td>
<code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string" target="_blank" >string</a></code>
</td>
<td>
No
</td>
<td>
<p>, ID of the PIT, that would be deleted</p>
</td>
</tr>
</tbody>
</table>
</div>
<div>
</div>
<div class="io-description">
<b>Returns : </b> <code>Promise&lt;boolean&gt;</code>
</div>
<div class="io-description">
<p>true/false, depending on the result of deletion of the PIT</p>
</div>
</td>
</tr>
</tbody>
</table>
<table class="table table-sm table-bordered">
<tbody>
<tr>
@ -201,8 +288,8 @@ HTTPService instance</p>
<tr>
<td class="col-md-4">
<div class="io-line">Defined in <a href="" data-line="67"
class="link-to-prism">src/core/services/common/search.service.ts:67</a></div>
<div class="io-line">Defined in <a href="" data-line="63"
class="link-to-prism">src/core/services/common/search.service.ts:63</a></div>
</td>
</tr>
@ -327,6 +414,89 @@ HTTPService instance</p>
</tr>
</tbody>
</table>
<table class="table table-sm table-bordered">
<tbody>
<tr>
<td class="col-md-4">
<a name="getPIT"></a>
<span class="name">
<span class="modifier">Async</span>
<span ><b>getPIT</b></span>
<a href="#getPIT"><span class="icon ion-ios-link"></span></a>
</span>
</td>
</tr>
<tr>
<td class="col-md-4">
<span class="modifier-icon icon ion-ios-reset"></span>
<code>getPIT(alive: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/number" target="_blank">number</a>)</code>
</td>
</tr>
<tr>
<td class="col-md-4">
<div class="io-line">Defined in <a href="" data-line="100"
class="link-to-prism">src/core/services/common/search.service.ts:100</a></div>
</td>
</tr>
<tr>
<td class="col-md-4">
<div class="io-description"><p>Acquires a PIT ID from Elasticsearch, needed for a request</p>
</div>
<div class="io-description">
<b>Parameters :</b>
<table class="params">
<thead>
<tr>
<td>Name</td>
<td>Type</td>
<td>Optional</td>
<td>Default value</td>
<td>Description</td>
</tr>
</thead>
<tbody>
<tr>
<td>alive</td>
<td>
<code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/number" target="_blank" >number</a></code>
</td>
<td>
No
</td>
<td>
<code>1</code>
</td>
<td>
<p>, amount of time in minutes (defaults to 1)</p>
</td>
</tr>
</tbody>
</table>
</div>
<div>
</div>
<div class="io-description">
<b>Returns : </b> <code>Promise&lt;string&gt;</code>
</div>
<div class="io-description">
<p>Point-In-Time ID</p>
</div>
</td>
</tr>
</tbody>
</table>
</section>
<section>
@ -406,25 +576,21 @@ export class SearchService {
query_string: {
query: &#x27;id:&#x27; + uuid
}
}
},
}
return new Promise((resolve, reject) &#x3D;&gt; {
try {
(this.httpService.get&lt;EsResponseDto&gt;(&#x27;http://localhost:&#x27; + this.ES_PORT + &#x27;/_search&#x27;, {
(this.httpService.get&lt;EsResponseDto&gt;(&#x60;http://localhost:${this.ES_PORT}/_search&#x60;, {
data: es_query,
headers: {&#x27;Content-Type&#x27;: &#x27;application/json&#x27;},
}))
.pipe(take(1), map(axiosRes &#x3D;&gt; axiosRes.data))
.subscribe((res: any) &#x3D;&gt; {
.subscribe((res: EsResponseDto) &#x3D;&gt; {
if (res.timed_out) {
reject(new SearchResultDto(504, {message: &#x27;Timed Out&#x27;}));
}
if (!res.hits.hits.length) {
reject(new SearchResultDto(404, {message: &#x27;Not Found&#x27;}));
}
resolve(new SearchResultDto(200, res.hits));
});
} catch (error) {
@ -445,25 +611,23 @@ export class SearchService {
query: query_str,
default_field: &quot;content&quot;
}
}
},
}
let pitID &#x3D; this.getPIT(1);
return new Promise((resolve, reject) &#x3D;&gt; {
try {
(this.httpService.get&lt;EsResponseDto&gt;(&#x27;http://localhost:&#x27;+ this.ES_PORT + &#x27;/_search&#x27;, {
(this.httpService.get&lt;EsResponseDto&gt;(&#x60;http://localhost:${this.ES_PORT}/_search&#x60;, {
data: es_query,
headers: {&#x27;Content-Type&#x27;: &#x27;application/json&#x27;},
}))
.pipe(take(1), map(axiosRes &#x3D;&gt; axiosRes.data))
.subscribe((res: any) &#x3D;&gt; {
.subscribe((res: EsResponseDto) &#x3D;&gt; {
if (res.timed_out) {
reject(new SearchResultDto(504, {status: 504, message: &#x27;Timed Out&#x27;}));
}
if (!res.hits.hits.length) {
reject(new SearchResultDto(404, {status: 404, message: &#x27;Not Found&#x27;}));
}
}
resolve(new SearchResultDto(200, res.hits));
});
} catch (error) {
@ -471,6 +635,47 @@ export class SearchService {
}
});
}
/**
* Acquires a PIT ID from Elasticsearch, needed for a request
* @param alive, amount of time in minutes (defaults to 1)
* @returns Point-In-Time ID
*/
async getPIT(alive: number &#x3D; 1): Promise&lt;string&gt; {
return new Promise((resolve, reject) &#x3D;&gt; {
try {
(this.httpService.post(&#x60;http://localhost:${this.ES_PORT}/papers/_pit?keep_alive&#x3D;${alive}m&#x60;)
.pipe(take(1), map(axiosRes &#x3D;&gt; axiosRes.data))
.subscribe((res) &#x3D;&gt; {
resolve(res.id);
}));
} catch (error) {
reject(error);
}
});
}
/**
* Deletes the PIT specified by provided ID
* @param pitID, ID of the PIT, that would be deleted
* @returns true/false, depending on the result of deletion of the PIT
*/
async deletePIT(pitID: string): Promise&lt;boolean&gt; {
return new Promise((resolve, reject) &#x3D;&gt; {
try {
this.httpService.delete(&#x60;http://localhost:${this.ES_PORT}/papers/_pit&#x60;, {
data: { id: pitID },
headers: { &#x27;Content-Type&#x27;: &#x27;application/json&#x27; },
})
.pipe(take(1), map(axiosRes &#x3D;&gt; axiosRes.data))
.subscribe((res) &#x3D;&gt; {
resolve(res.succeeded);
});
} catch (error) {
reject(error);
}
})
}
}</code></pre>
</div>

@ -121,6 +121,12 @@
pagesize
</a>
</li>
<li>
<a href="#total"
>
total
</a>
</li>
</ul>
</td>
</tr>
@ -322,6 +328,45 @@
<tr>
<td class="col-md-4">
<div class="io-description"><p> Number of elements on the page</p>
</div>
</td>
</tr>
</tbody>
</table>
<table class="table table-sm table-bordered">
<tbody>
<tr>
<td class="col-md-4">
<a name="total"></a>
<span class="name "><b>total</b>
<a href="#total">
<span class="icon ion-ios-link"></span>
</a>
</span>
</td>
</tr>
<tr>
<td class="col-md-4">
<code>total: <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/number" target="_blank" >number</a></code>
</code>
</td>
</tr>
<tr>
<td class="col-md-4">
<i>Type : </i> <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/number" target="_blank" >number</a></code>
</td>
</tr>
<tr>
<td class="col-md-4">
<div class="io-description"><p>Total search results</p>
</div>
</td>
</tr>
@ -338,6 +383,11 @@
* Structure of page metadata
*/
export interface PageMeta {
/**
* Total search results
*/
total: number;
/**
* Number of the page
*/

@ -62,20 +62,6 @@ customElements.define('compodoc-menu', class extends HTMLElement {
<ul class="links collapse " ${ isNormalMode ? 'id="modules-links"' : 'id="xs-modules-links"' }>
<li class="link">
<a href="modules/AppModule.html" data-type="entity-link" >AppModule</a>
<li class="chapter inner">
<div class="simple menu-toggler" data-toggle="collapse" ${ isNormalMode ?
'data-target="#controllers-links-module-AppModule-84742a95d671e790860a7fa317fbea908a985643814cc33685350b5138f94282f7519ff7a64f13ba76d94ff438ef15c866c0eb295afe2e6466a6e928298b0875"' : 'data-target="#xs-controllers-links-module-AppModule-84742a95d671e790860a7fa317fbea908a985643814cc33685350b5138f94282f7519ff7a64f13ba76d94ff438ef15c866c0eb295afe2e6466a6e928298b0875"' }>
<span class="icon ion-md-swap"></span>
<span>Controllers</span>
<span class="icon ion-ios-arrow-down"></span>
</div>
<ul class="links collapse" ${ isNormalMode ? 'id="controllers-links-module-AppModule-84742a95d671e790860a7fa317fbea908a985643814cc33685350b5138f94282f7519ff7a64f13ba76d94ff438ef15c866c0eb295afe2e6466a6e928298b0875"' :
'id="xs-controllers-links-module-AppModule-84742a95d671e790860a7fa317fbea908a985643814cc33685350b5138f94282f7519ff7a64f13ba76d94ff438ef15c866c0eb295afe2e6466a6e928298b0875"' }>
<li class="link">
<a href="controllers/PapersController.html" data-type="entity-link" data-context="sub-entity" data-context-id="modules" >PapersController</a>
</li>
</ul>
</li>
</li>
<li class="link">
<a href="modules/CommonModule.html" data-type="entity-link" >CommonModule</a>
@ -133,15 +119,29 @@ customElements.define('compodoc-menu', class extends HTMLElement {
</li>
<li class="link">
<a href="modules/SearchModule.html" data-type="entity-link" >SearchModule</a>
<li class="chapter inner">
<div class="simple menu-toggler" data-toggle="collapse" ${ isNormalMode ?
'data-target="#controllers-links-module-SearchModule-4d6b5def969a39269d635bca6413568deaac5fdf860905918f45ad6efd54f8bcc196e457466f4e81c1575bf525bc7c6017cb905f4c7d3b6290150dee92624578"' : 'data-target="#xs-controllers-links-module-SearchModule-4d6b5def969a39269d635bca6413568deaac5fdf860905918f45ad6efd54f8bcc196e457466f4e81c1575bf525bc7c6017cb905f4c7d3b6290150dee92624578"' }>
<span class="icon ion-md-swap"></span>
<span>Controllers</span>
<span class="icon ion-ios-arrow-down"></span>
</div>
<ul class="links collapse" ${ isNormalMode ? 'id="controllers-links-module-SearchModule-4d6b5def969a39269d635bca6413568deaac5fdf860905918f45ad6efd54f8bcc196e457466f4e81c1575bf525bc7c6017cb905f4c7d3b6290150dee92624578"' :
'id="xs-controllers-links-module-SearchModule-4d6b5def969a39269d635bca6413568deaac5fdf860905918f45ad6efd54f8bcc196e457466f4e81c1575bf525bc7c6017cb905f4c7d3b6290150dee92624578"' }>
<li class="link">
<a href="controllers/PapersController.html" data-type="entity-link" data-context="sub-entity" data-context-id="modules" >PapersController</a>
</li>
</ul>
</li>
<li class="chapter inner">
<div class="simple menu-toggler" data-toggle="collapse" ${ isNormalMode ?
'data-target="#injectables-links-module-SearchModule-ff1e3f996168633d0052f0bb4c980380770fb9b91205152cb31cd4ab0247a84902938079173ea40485bd681153b1833900a69be29ae1addfda20c11b12951937"' : 'data-target="#xs-injectables-links-module-SearchModule-ff1e3f996168633d0052f0bb4c980380770fb9b91205152cb31cd4ab0247a84902938079173ea40485bd681153b1833900a69be29ae1addfda20c11b12951937"' }>
'data-target="#injectables-links-module-SearchModule-4d6b5def969a39269d635bca6413568deaac5fdf860905918f45ad6efd54f8bcc196e457466f4e81c1575bf525bc7c6017cb905f4c7d3b6290150dee92624578"' : 'data-target="#xs-injectables-links-module-SearchModule-4d6b5def969a39269d635bca6413568deaac5fdf860905918f45ad6efd54f8bcc196e457466f4e81c1575bf525bc7c6017cb905f4c7d3b6290150dee92624578"' }>
<span class="icon ion-md-arrow-round-down"></span>
<span>Injectables</span>
<span class="icon ion-ios-arrow-down"></span>
</div>
<ul class="links collapse" ${ isNormalMode ? 'id="injectables-links-module-SearchModule-ff1e3f996168633d0052f0bb4c980380770fb9b91205152cb31cd4ab0247a84902938079173ea40485bd681153b1833900a69be29ae1addfda20c11b12951937"' :
'id="xs-injectables-links-module-SearchModule-ff1e3f996168633d0052f0bb4c980380770fb9b91205152cb31cd4ab0247a84902938079173ea40485bd681153b1833900a69be29ae1addfda20c11b12951937"' }>
<ul class="links collapse" ${ isNormalMode ? 'id="injectables-links-module-SearchModule-4d6b5def969a39269d635bca6413568deaac5fdf860905918f45ad6efd54f8bcc196e457466f4e81c1575bf525bc7c6017cb905f4c7d3b6290150dee92624578"' :
'id="xs-injectables-links-module-SearchModule-4d6b5def969a39269d635bca6413568deaac5fdf860905918f45ad6efd54f8bcc196e457466f4e81c1575bf525bc7c6017cb905f4c7d3b6290150dee92624578"' }>
<li class="link">
<a href="injectables/SearchService.html" data-type="entity-link" data-context="sub-entity" data-context-id="modules" >SearchService</a>
</li>
@ -174,6 +174,9 @@ customElements.define('compodoc-menu', class extends HTMLElement {
<li class="link">
<a href="classes/EnvironmentVariables.html" data-type="entity-link" >EnvironmentVariables</a>
</li>
<li class="link">
<a href="classes/EsQueryDto.html" data-type="entity-link" >EsQueryDto</a>
</li>
<li class="link">
<a href="classes/EsResponseDto.html" data-type="entity-link" >EsResponseDto</a>
</li>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -61,14 +61,17 @@
<tr>
<td class="col-md-4">
<ul class="index-list">
<li>
<a href="#allowedProperties" title="src/core/domain/dtos/es-query.dto.ts" ><b>allowedProperties</b>&nbsp;&nbsp;&nbsp;(src/.../es-query.dto.ts)</a>
</li>
<li>
<a href="#allowedProperties" title="src/core/domain/dtos/es-response.dto.ts" ><b>allowedProperties</b>&nbsp;&nbsp;&nbsp;(src/.../es-response.dto.ts)</a>
</li>
<li>
<a href="#allowedProperties" title="src/core/domain/dtos/search-q.dto.ts" ><b>allowedProperties</b>&nbsp;&nbsp;&nbsp;(src/.../search-q.dto.ts)</a>
<a href="#allowedProperties" title="src/core/domain/dtos/page.dto.ts" ><b>allowedProperties</b>&nbsp;&nbsp;&nbsp;(src/.../page.dto.ts)</a>
</li>
<li>
<a href="#allowedProperties" title="src/core/domain/dtos/page.dto.ts" ><b>allowedProperties</b>&nbsp;&nbsp;&nbsp;(src/.../page.dto.ts)</a>
<a href="#allowedProperties" title="src/core/domain/dtos/search-q.dto.ts" ><b>allowedProperties</b>&nbsp;&nbsp;&nbsp;(src/.../search-q.dto.ts)</a>
</li>
<li>
<a href="#allowedProperties" title="src/core/domain/dtos/search-result.dto.ts" ><b>allowedProperties</b>&nbsp;&nbsp;&nbsp;(src/.../search-result.dto.ts)</a>
@ -98,6 +101,41 @@
</table>
</section>
<h3>src/core/domain/dtos/es-query.dto.ts</h3>
<section>
<h3></h3> <table class="table table-sm table-bordered">
<tbody>
<tr>
<td class="col-md-4">
<a name="allowedProperties"></a>
<span class="name">
<span ><b>allowedProperties</b></span>
<a href="#allowedProperties"><span class="icon ion-ios-link"></span></a>
</span>
</td>
</tr>
<tr>
<td class="col-md-4">
<i>Type : </i> <code>[]</code>
</td>
</tr>
<tr>
<td class="col-md-4">
<i>Default value : </i><code>[&#x27;size&#x27;, &#x27;query&#x27;, &#x27;pit&#x27;, &#x27;sort&#x27;]</code>
</td>
</tr>
<tr>
<td class="col-md-4">
<div class="io-description"><p>List of allowed properties in this DTO</p>
</div>
</td>
</tr>
</tbody>
</table>
</section>
<h3>src/core/domain/dtos/es-response.dto.ts</h3>
<section>
<h3></h3> <table class="table table-sm table-bordered">
@ -133,41 +171,6 @@
</tbody>
</table>
</section>
<h3>src/core/domain/dtos/search-q.dto.ts</h3>
<section>
<h3></h3> <table class="table table-sm table-bordered">
<tbody>
<tr>
<td class="col-md-4">
<a name="allowedProperties"></a>
<span class="name">
<span ><b>allowedProperties</b></span>
<a href="#allowedProperties"><span class="icon ion-ios-link"></span></a>
</span>
</td>
</tr>
<tr>
<td class="col-md-4">
<i>Type : </i> <code>[]</code>
</td>
</tr>
<tr>
<td class="col-md-4">
<i>Default value : </i><code>[&#x27;query&#x27;, &#x27;pagen&#x27;, &#x27;limit&#x27;, &#x27;order&#x27;]</code>
</td>
</tr>
<tr>
<td class="col-md-4">
<div class="io-description"><p>List of allowed properties in this DTO</p>
</div>
</td>
</tr>
</tbody>
</table>
</section>
<h3>src/core/domain/dtos/page.dto.ts</h3>
<section>
<h3></h3> <table class="table table-sm table-bordered">
@ -203,6 +206,41 @@
</tbody>
</table>
</section>
<h3>src/core/domain/dtos/search-q.dto.ts</h3>
<section>
<h3></h3> <table class="table table-sm table-bordered">
<tbody>
<tr>
<td class="col-md-4">
<a name="allowedProperties"></a>
<span class="name">
<span ><b>allowedProperties</b></span>
<a href="#allowedProperties"><span class="icon ion-ios-link"></span></a>
</span>
</td>
</tr>
<tr>
<td class="col-md-4">
<i>Type : </i> <code>[]</code>
</td>
</tr>
<tr>
<td class="col-md-4">
<i>Default value : </i><code>[&#x27;query&#x27;, &#x27;pagen&#x27;, &#x27;limit&#x27;, &#x27;order&#x27;]</code>
</td>
</tr>
<tr>
<td class="col-md-4">
<div class="io-description"><p>List of allowed properties in this DTO</p>
</div>
</td>
</tr>
</tbody>
</table>
</section>
<h3>src/core/domain/dtos/search-result.dto.ts</h3>
<section>
<h3></h3> <table class="table table-sm table-bordered">

@ -137,15 +137,6 @@
<div class="container-fluid module">
<div class="row">
<div class="col-sm-3">
<h3>Controllers<a href="https://docs.nestjs.com/controllers" target="_blank" title="Official documentation about module controllers"><span
class="icon ion-ios-information-circle-outline"></a></h3>
<ul class="list-group">
<li class="list-group-item">
<a href="../controllers/PapersController.html">PapersController</a>
</li>
</ul>
</div>
<div class="col-sm-3">
<h3>Imports<a href="https://angular.io/api/core/NgModule#imports" target="_blank" title="Official documentation about module imports"><span
class="icon ion-ios-information-circle-outline"></a></h3>
@ -175,7 +166,6 @@ import { LoggerInterceptor } from &#x27;../../core/interceptors&#x27;
import * as modules from &#x27;../../core/modules&#x27;
import { CommonModule } from &#x27;./common/common.module&#x27;;
import { PrometheusModule } from &#x27;@willsoto/nestjs-prometheus&#x27;;
import { PapersController } from &#x27;src/application/controller/papers.controller&#x27;;
import { SearchModule } from &#x27;./search.module&#x27;;
/**
@ -211,7 +201,7 @@ const modulesList &#x3D; Object.keys(modules).map(moduleIndex &#x3D;&gt; modules
useClass: LoggerInterceptor,
},
],
controllers: [PapersController],
controllers: [],
})
export class AppModule {}
</code></pre>

@ -14,14 +14,14 @@
<title>cluster_CommonModule</title>
<polygon fill="none" stroke="black" stroke-dasharray="1,5" points="8,-32.8 8,-230.8 304,-230.8 304,-32.8 8,-32.8"/>
</g>
<g id="clust3" class="cluster">
<title>cluster_CommonModule_imports</title>
<polygon fill="none" stroke="black" points="20,-40.8 20,-92.8 292,-92.8 292,-40.8 20,-40.8"/>
</g>
<g id="clust4" class="cluster">
<title>cluster_CommonModule_exports</title>
<polygon fill="none" stroke="black" points="16,-170.8 16,-222.8 296,-222.8 296,-170.8 16,-170.8"/>
</g>
<g id="clust3" class="cluster">
<title>cluster_CommonModule_imports</title>
<polygon fill="none" stroke="black" points="20,-40.8 20,-92.8 292,-92.8 292,-40.8 20,-40.8"/>
</g>
<!-- HttpResponseModule -->
<g id="node1" class="node">
<title>HttpResponseModule</title>

Before

(image error) Size: 4.3 KiB

After

(image error) Size: 4.3 KiB

@ -150,6 +150,15 @@
</li>
</ul>
</div>
<div class="col-sm-3">
<h3>Controllers<a href="https://docs.nestjs.com/controllers" target="_blank" title="Official documentation about module controllers"><span
class="icon ion-ios-information-circle-outline"></a></h3>
<ul class="list-group">
<li class="list-group-item">
<a href="../controllers/PapersController.html">PapersController</a>
</li>
</ul>
</div>
<div class="col-sm-3">
<h3>Exports<a href="https://angular.io/api/core/NgModule#exports" target="_blank" title="Official documentation about module exports"><span
class="icon ion-ios-information-circle-outline"></a></h3>
@ -170,16 +179,20 @@
<pre class="line-numbers compodoc-sourcecode"><code class="language-typescript">import { HttpModule } from &quot;@nestjs/axios&quot;;
import { Module } from &quot;@nestjs/common&quot;;
import { ConfigModule } from &quot;@nestjs/config&quot;;
import { PapersController } from &quot;src/application&quot;;
import { SearchService } from &quot;../../core/services/common/search.service&quot;;
import { configuration } from &quot;../config&quot;;
/**
* search module
*/
@Module({
imports: [HttpModule],
imports: [
HttpModule,
],
exports: [SearchService],
providers: [SearchService],
controllers: [],
controllers: [PapersController],
})
export class SearchModule {}</code></pre>
</div>

@ -301,7 +301,7 @@
<div class="card text-center">
<div class="card-block">
<h4 class="card-title"><span class="icon ion-ios-paper"></span></h4>
<p class="card-text">6 Classes</p>
<p class="card-text">7 Classes</p>
</div>
</div>
</div>

@ -0,0 +1,45 @@
import { ApiProperty } from "@nestjs/swagger";
import { IsDefined, IsInt, IsNotEmpty, IsNumber, IsObject } from "class-validator";
/**
* List of allowed properties in this DTO
*/
const allowedProperties = ['size', 'query', 'pit', 'sort'];
/**
* Elasticsearch query DTO
*/
export class EsQueryDto {
/**
* Maximum number of elements returned by Elasticsearch
*/
@IsDefined()
@IsNumber()
@IsInt()
@ApiProperty({
description: 'Maximum number of elements returned by Elasticsearch',
example: 30
})
size: number;
/**
* The search query object passed to Elasticsearch
*/
@IsDefined()
@IsObject()
@ApiProperty({
description: 'Search query object passed to Elasticsearch',
example: false,
})
query: object;
/**
* Object, that stores Point-In-Time ID and time alive
*/
pit: object;
/**
* Object, that stores
*/
sort: object;
}

@ -57,6 +57,13 @@ export class SearchQueryDto {
})
order: string;
/**
* Constructs an object with provided parameters
* @param query
* @param page
* @param limit
* @param order
*/
constructor(query: string, page: number, limit: number, order: string) {
this.query = query;
this.page = page;

@ -37,7 +37,7 @@ export class SearchService {
return new Promise((resolve, reject) => {
try {
(this.httpService.get<EsResponseDto>('http://localhost:' + this.ES_PORT + '/_search', {
(this.httpService.get<EsResponseDto>(`http://localhost:${this.ES_PORT}/_search`, {
data: es_query,
headers: {'Content-Type': 'application/json'},
}))
@ -70,9 +70,11 @@ export class SearchService {
},
}
let pitID = this.getPIT(1);
return new Promise((resolve, reject) => {
try {
(this.httpService.get<EsResponseDto>('http://localhost:'+ this.ES_PORT + '/_search', {
(this.httpService.get<EsResponseDto>(`http://localhost:${this.ES_PORT}/_search`, {
data: es_query,
headers: {'Content-Type': 'application/json'},
}))
@ -81,7 +83,7 @@ export class SearchService {
if (res.timed_out) {
reject(new SearchResultDto(504, {status: 504, message: 'Timed Out'}));
}
resolve(new SearchResultDto(200, res.hits));
});
} catch (error) {
@ -89,4 +91,45 @@ export class SearchService {
}
});
}
/**
* Acquires a PIT ID from Elasticsearch, needed for a request
* @param alive, amount of time in minutes (defaults to 1)
* @returns Point-In-Time ID
*/
async getPIT(alive: number = 1): Promise<string> {
return new Promise((resolve, reject) => {
try {
(this.httpService.post(`http://localhost:${this.ES_PORT}/papers/_pit?keep_alive=${alive}m`)
.pipe(take(1), map(axiosRes => axiosRes.data))
.subscribe((res) => {
resolve(res.id);
}));
} catch (error) {
reject(error);
}
});
}
/**
* Deletes the PIT specified by provided ID
* @param pitID, ID of the PIT, that would be deleted
* @returns true/false, depending on the result of deletion of the PIT
*/
async deletePIT(pitID: string): Promise<boolean> {
return new Promise((resolve, reject) => {
try {
this.httpService.delete(`http://localhost:${this.ES_PORT}/papers/_pit`, {
data: { id: pitID },
headers: { 'Content-Type': 'application/json' },
})
.pipe(take(1), map(axiosRes => axiosRes.data))
.subscribe((res) => {
resolve(res.succeeded);
});
} catch (error) {
reject(error);
}
})
}
}

@ -7,7 +7,6 @@ import { LoggerInterceptor } from '../../core/interceptors'
import * as modules from '../../core/modules'
import { CommonModule } from './common/common.module';
import { PrometheusModule } from '@willsoto/nestjs-prometheus';
import { PapersController } from 'src/application/controller/papers.controller';
import { SearchModule } from './search.module';
/**

@ -1,6 +1,5 @@
import { HttpModule } from "@nestjs/axios";
import { Module } from "@nestjs/common";
import { ConfigModule } from "@nestjs/config";
import { PapersController } from "src/application";
import { SearchService } from "../../core/services/common/search.service";
@ -8,7 +7,9 @@ import { SearchService } from "../../core/services/common/search.service";
* search module
*/
@Module({
imports: [HttpModule],
imports: [
HttpModule,
],
exports: [SearchService],
providers: [SearchService],
controllers: [PapersController],

@ -0,0 +1,103 @@
import { HttpService } from "@nestjs/axios";
import { ConfigModule } from "@nestjs/config";
import { Test } from "@nestjs/testing";
import { of } from "rxjs";
import { HttpResponseException } from "src/core/exceptions";
import { SearchService } from "src/core/services/common/search.service";
describe('Unit tests for SearchService', () => {
let searchService: SearchService;
let httpService: HttpService;
beforeAll(async () => {
const moduleRef = await Test.createTestingModule({
providers: [
SearchService,
{
provide: HttpService,
useValue: {
post: jest.fn(),
},
},
],
imports: [
ConfigModule.forRoot({
isGlobal: true,
cache: true,
expandVariables: true,
})
],
}).compile();
searchService = moduleRef.get(SearchService);
httpService = moduleRef.get(HttpService);
});
describe('getPIT()', () => {
it('Should touch HttpService.post() method', () => {
let postMock = jest.spyOn(httpService, 'post').mockReturnValue(of({
data: {id: '2567'},
status: 0,
statusText: '',
headers: {},
config: {},
}));
searchService.getPIT();
expect(postMock).toHaveBeenCalled();
});
it('Should contain correct port in the URI from .env', () => {
let postMock = jest.spyOn(httpService, 'post').mockReturnValue(of({
data: {id: '2567'},
status: 0,
statusText: '',
headers: {},
config: {},
}));
searchService.getPIT();
expect(postMock).toHaveBeenCalledWith(`http://localhost:${process.env.ES_PORT}/papers/_pit?keep_alive=1m`);
});
it('Should touch HttpService with correct URI when keep_alive is set as a parameter', () => {
let postMock = jest.spyOn(httpService, 'post').mockReturnValue(of({
data: {id: '2567'},
status: 0,
statusText: '',
headers: {},
config: {},
}));
let keep_alive = 2;
searchService.getPIT(keep_alive);
expect(postMock).toHaveBeenCalledWith(`http://localhost:${process.env.ES_PORT}/papers/_pit?keep_alive=${keep_alive}m`);
});
it('Should return error exeception when HttpService fails', () => {
jest.spyOn(httpService, 'post').mockImplementation(() => {
throw HttpResponseException;
});
expect(searchService.getPIT()).rejects.toEqual(HttpResponseException);
});
it('Should return a non-empty string when HttpService request succeedes', () => {
jest.spyOn(httpService, 'post').mockReturnValue(of({
data: {id: '2567'},
status: 0,
statusText: '',
headers: {},
config: {},
}));
expect(searchService.getPIT()).resolves.toBe('2567');
});
});
describe('deletePIT()', () => {
it.todo('Should fail to delete, because the requested PIT ID is invalid');
it.todo('Should call HttpService.delete() method with correct body');
});
});