Add type to the highlight in the elasticsearch and three types are HIGHLIGHTS, REDACTION and NOTE
This commit is contained in:
@ -71,6 +71,12 @@ export enum ArticleSavingRequestStatus {
|
||||
Deleted = 'DELETED',
|
||||
}
|
||||
|
||||
export enum HighlightType {
|
||||
Highlight = 'HIGHLIGHT',
|
||||
Redaction = 'REDACTION', // allowing people to remove text from the page
|
||||
Note = 'NOTE', // allowing people to add a note at the document level
|
||||
}
|
||||
|
||||
export interface Label {
|
||||
id: string
|
||||
name: string
|
||||
@ -94,6 +100,7 @@ export interface Highlight {
|
||||
labels?: Label[]
|
||||
highlightPositionPercent?: number | null
|
||||
highlightPositionAnchorIndex?: number | null
|
||||
type: HighlightType
|
||||
html?: string | null
|
||||
}
|
||||
|
||||
|
||||
@ -84,6 +84,10 @@
|
||||
"userId": {
|
||||
"type": "keyword"
|
||||
},
|
||||
"type": {
|
||||
"type": "keyword",
|
||||
"null_value": "HIGHLIGHT"
|
||||
},
|
||||
"quote": {
|
||||
"type": "text",
|
||||
"analyzer": "strip_html_analyzer"
|
||||
|
||||
@ -148,41 +148,8 @@ const elasticMigration = esClient.indices
|
||||
log('Elastic index mappings updated.')
|
||||
})
|
||||
})
|
||||
.then(() => {
|
||||
log('Adding default state to pages in elastic...')
|
||||
return esClient
|
||||
.update_by_query({
|
||||
index: INDEX_ALIAS,
|
||||
requests_per_second: 250,
|
||||
scroll_size: 500,
|
||||
timeout: '30m',
|
||||
body: {
|
||||
script: {
|
||||
source: 'ctx._source.state = params.state',
|
||||
lang: 'painless',
|
||||
params: {
|
||||
state: 'SUCCEEDED',
|
||||
},
|
||||
},
|
||||
query: {
|
||||
bool: {
|
||||
must_not: [
|
||||
{
|
||||
exists: {
|
||||
field: 'state',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
.then(() => log('Default state added.'))
|
||||
})
|
||||
.catch((error) => {
|
||||
log(`${chalk.red('Elastic migration failed: ')}${error.message}`, chalk.red)
|
||||
const { appliedMigrations } = error
|
||||
logAppliedMigrations(appliedMigrations)
|
||||
process.exit(1)
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user