-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
check if document exists before elasticsearch get #388
base: dev
Are you sure you want to change the base?
Changes from 3 commits
41e22df
95b9c9e
77942fa
ba70fe3
3206c82
05dc9f1
b1b98ab
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -395,31 +395,32 @@ class BaseModel extends FinEsDataModel { | |
* @returns {Promise} resolves to elasticsearch result | ||
*/ | ||
async get(id, opts={}, index) { | ||
let _source_excludes = true; | ||
let _source_excludes = 'roles'; | ||
if( opts.admin ) _source_excludes = false; | ||
else if( opts.compact ) _source_excludes = 'compact'; | ||
|
||
let identifier = id.replace(/^\//, '').split('/'); | ||
identifier.shift(); | ||
identifier = identifier.join('/'); | ||
//console.log(`FinEsNestedModel.get(${identifier}) on ${this.readIndexAlias}`); | ||
|
||
let result= await this.client.get( | ||
let result = await this.client.exists({ | ||
index: this.readIndexAlias, | ||
id: identifier | ||
}); | ||
|
||
if( !result ) return null; | ||
|
||
result = await this.client.get( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @UcDust this call is basically replicated in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @qjhart I refactored that code a bit in the last commit so that it uses that |
||
{ | ||
index: this.readIndexAlias, | ||
id: identifier, | ||
_source: true, | ||
_source_excludes: _source_excludes | ||
_source_excludes: _source_excludes | ||
} | ||
); | ||
|
||
if( result ) { | ||
result = result._source; | ||
//if( opts.compact ) this.utils.compactAllTypes(result); | ||
//if( opts.singleNode ) result['@graph'] = this.utils.singleNode(id, result['@graph']); | ||
} else { | ||
return null; | ||
} | ||
result = result._source; | ||
//if( opts.compact ) this.utils.compactAllTypes(result); | ||
//if( opts.singleNode ) result['@graph'] = this.utils.singleNode(id, result['@graph']); | ||
|
||
// Add fcrepo and dbsync data if admin, for the dashboard | ||
if( opts.admin === true ) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@UcDust this is not completed. Can you show me the jsonld passed here ?