Skip to content
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

Add identify-ids-by-es-query script #107

Merged
merged 3 commits into from
Feb 10, 2025
Merged

Conversation

nonword
Copy link
Member

@nonword nonword commented Jan 29, 2025

A script for building a CSV of bib ids for an arbitrary ES query. Useful for building a CSV of records for feeding into the RCI bulk-index script.

Copy link
Contributor

@charmingduchess charmingduchess left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good!
I had initially come to the scroll api when I was starting my own version of this script, but was diverted by this alert in the docs:

We no longer recommend using the scroll API for deep pagination. If you need to preserve the index state while paging through more than 10,000 hits, use the search_after parameter with a point in time (PIT).

I don't imagine that this is a problem for this script, but something to keep in mind for updates in the future. I have a feeling that the search_after might also help with the bug where duplicated results turn up. I can't link to this line, but this in the pagination api docs caught my eye:

Repeat this process by updating the search_after array every time you retrieve a new page of results. If a refresh occurs between these requests, the order of your results may change, causing inconsistent results across pages. To prevent this, you can create a point in time (PIT) to preserve the current index state over your searches.

I think this api is obviously useful for large searches, but I think we could also leverage it for our smaller range pagination on search results to avoid the duplicated search results.

}
})

castArgsToInts(argv, ['batchSize', 'limit', 'offset'])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this line shouldn't be here. These arguments are not specified in the preamble.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. We do want to support --limit, so keeping that one.

type: 'string',
default: '0'
},
outfile: { type: 'string' },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the preamble says this field has a default, but there is not one specified here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Fixed.

@charmingduchess
Copy link
Contributor

Can you update this script name to include ES?

@nonword nonword changed the title Add identify-ids-by-query script Add identify-ids-by-es-query script Feb 6, 2025
@nonword nonword merged commit 515ec7b into main Feb 10, 2025
3 checks passed
@nonword nonword deleted the NOREF-identify-ids-by-query-script branch February 10, 2025 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants