@backstage/plugin-search-backend-node
Advanced tools
Comparing version 0.0.0-nightly-20217521743 to 0.0.0-nightly-202191622432
# @backstage/plugin-search-backend-node | ||
## 0.0.0-nightly-20217521743 | ||
## 0.4.2 | ||
### Patch Changes | ||
- a13f21cdc: Implement optional `pageCursor` based paging in search. | ||
To use paging in your app, add a `<SearchResultPager />` to your | ||
`SearchPage.tsx`. | ||
- Updated dependencies | ||
- @backstage/search-common@0.2.0 | ||
## 0.4.1 | ||
### Patch Changes | ||
- d9c13d535: Implements configuration and indexing functionality for ElasticSearch search engine. Adds indexing, searching and default translator for ElasticSearch and modifies default backend example-app to use ES if it is configured. | ||
@@ -75,3 +87,3 @@ | ||
- Updated dependencies | ||
- @backstage/search-common@0.0.0-nightly-20217521743 | ||
- @backstage/search-common@0.1.3 | ||
@@ -78,0 +90,0 @@ ## 0.4.0 |
@@ -137,2 +137,3 @@ 'use strict'; | ||
}) => { | ||
const pageSize = 25; | ||
return { | ||
@@ -177,3 +178,4 @@ lunrQueryBuilder: (q) => { | ||
}, | ||
documentTypes: types | ||
documentTypes: types, | ||
pageSize | ||
}; | ||
@@ -202,3 +204,3 @@ }; | ||
async query(query) { | ||
const {lunrQueryBuilder, documentTypes} = this.translator(query); | ||
const {lunrQueryBuilder, documentTypes, pageSize} = this.translator(query); | ||
const results = []; | ||
@@ -223,6 +225,14 @@ Object.keys(this.lunrIndices).filter((type) => !documentTypes || documentTypes.includes(type)).forEach((type) => { | ||
}); | ||
const {page} = decodePageCursor(query.pageCursor); | ||
const offset = page * pageSize; | ||
const hasPreviousPage = page > 0; | ||
const hasNextPage = results.length > offset + pageSize; | ||
const nextPageCursor = hasNextPage ? encodePageCursor({page: page + 1}) : void 0; | ||
const previousPageCursor = hasPreviousPage ? encodePageCursor({page: page - 1}) : void 0; | ||
const realResultSet = { | ||
results: results.map((d) => { | ||
results: results.slice(offset, offset + pageSize).map((d) => { | ||
return {type: d.type, document: this.docStore[d.result.ref]}; | ||
}) | ||
}), | ||
nextPageCursor, | ||
previousPageCursor | ||
}; | ||
@@ -232,2 +242,13 @@ return realResultSet; | ||
} | ||
function decodePageCursor(pageCursor) { | ||
if (!pageCursor) { | ||
return {page: 0}; | ||
} | ||
return { | ||
page: Number(Buffer.from(pageCursor, "base64").toString("utf-8")) | ||
}; | ||
} | ||
function encodePageCursor({page}) { | ||
return Buffer.from(`${page}`, "utf-8").toString("base64"); | ||
} | ||
@@ -234,0 +255,0 @@ exports.IndexBuilder = IndexBuilder; |
@@ -89,2 +89,3 @@ import { DocumentCollator, DocumentDecorator, SearchEngine, IndexableDocument, QueryTranslator, SearchQuery, SearchResultSet } from '@backstage/search-common'; | ||
documentTypes?: string[]; | ||
pageSize: number; | ||
}; | ||
@@ -91,0 +92,0 @@ declare type LunrQueryTranslator = (query: SearchQuery) => ConcreteLunrQuery; |
{ | ||
"name": "@backstage/plugin-search-backend-node", | ||
"version": "0.0.0-nightly-20217521743", | ||
"description": "A library for Backstage backend plugins that want to interact with the search backend plugin", | ||
"version": "0.0.0-nightly-202191622432", | ||
"main": "dist/index.cjs.js", | ||
@@ -22,3 +23,3 @@ "types": "dist/index.d.ts", | ||
"dependencies": { | ||
"@backstage/search-common": "^0.0.0-nightly-20217521743", | ||
"@backstage/search-common": "^0.0.0-nightly-202191622432", | ||
"winston": "^3.2.1", | ||
@@ -29,4 +30,4 @@ "lunr": "^2.3.9", | ||
"devDependencies": { | ||
"@backstage/backend-common": "^0.0.0-nightly-20217521743", | ||
"@backstage/cli": "^0.0.0-nightly-20217521743" | ||
"@backstage/backend-common": "^0.0.0-nightly-202191622432", | ||
"@backstage/cli": "^0.0.0-nightly-202191622432" | ||
}, | ||
@@ -33,0 +34,0 @@ "files": [ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
42169
344