-
Notifications
You must be signed in to change notification settings - Fork 10
query testing & split for sorting #99
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,3 +18,6 @@ coverage_report/ | |
|
|
||
| # Spec archives | ||
| spec.tar.gz | ||
|
|
||
| # Creds | ||
| arango_live_server_config.json | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| Flask==1.0.2 | ||
| itsdangerous==2.0.1 | ||
| greenlet==0.4.16 | ||
| gunicorn==19.9.0 | ||
| gevent==1.3.7 | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| # Search ncbi_taxon collection for species/strains by scientific name | ||
|
This conversation was marked as resolved.
|
||
| name: taxonomy_ncbi_species | ||
| params: | ||
| type: object | ||
| required: [search_text] | ||
| additionalProperties: false | ||
| properties: | ||
| search_text: | ||
| type: string | ||
| title: Search text | ||
| examples: [escherichia, es] | ||
| description: Text to search on the search attribute values | ||
| ts: | ||
| type: [integer, "null"] | ||
| title: Versioning timestamp | ||
| default: null | ||
| offset: | ||
| type: [integer, "null"] | ||
| title: Paging offset | ||
| maximum: 100000 | ||
| default: 0 | ||
| limit: | ||
| type: [integer, "null"] | ||
| title: Max results to return | ||
| default: 20 | ||
| maximum: 1000 | ||
| select: | ||
| type: [string, array, "null"] | ||
| items: | ||
| type: string | ||
| examples: [scientific_name, [scientific_name, id]] | ||
| default: null | ||
| description: Document attributes to keep in the results | ||
| query: | | ||
| LET search_text__norm = REGEX_REPLACE(LOWER(TRIM(@search_text)), "\\s+", " ") | ||
| LET search_text__first_exact_tok = REGEX_SPLIT(search_text__norm, " ")[0] | ||
| LET search_text__icu_toks = TOKENS(@search_text, "icu_tokenize") // analyzer | ||
| LET search_text__wordboundmod_icu_toks = ( | ||
| FOR tok IN search_text__icu_toks | ||
| RETURN REGEX_REPLACE(tok, ",.*", "") // commas cannot be escaped in fulltext search | ||
| ) | ||
| LET search_text__fulltext = CONCAT_SEPARATOR(", ", // comma delimit | ||
| FOR tok IN search_text__wordboundmod_icu_toks // prepend "prefix:" | ||
| RETURN CONCAT("prefix:", tok) | ||
| ) | ||
| FOR doc IN FULLTEXT(ncbi_taxon, "scientific_name", search_text__fulltext) | ||
| FILTER @ts ? doc.created <= @ts AND doc.expired >= @ts : true | ||
| FILTER doc.rank IN ["species", "strain"] OR doc.strain | ||
| LET doc_sciname__norm = REGEX_REPLACE(LOWER(TRIM(doc.scientific_name)), "\\s+", " ") // for exact matching | ||
| LET contains_ind = CONTAINS(doc_sciname__norm, search_text__norm, true) | ||
| SORT contains_ind == 0 DESC, // prefix match | ||
| doc_sciname__norm == search_text__norm DESC, // exact match | ||
| doc.scientific_name // lexical | ||
| LIMIT @offset ? @offset : 0, @limit ? @limit : 20 | ||
| RETURN @select ? KEEP(doc, @select) : doc | ||
50 changes: 50 additions & 0 deletions
50
spec/stored_queries/taxonomy/taxonomy_ncbi_species_no_sort.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| # Search ncbi_taxon collection for species/strains by scientific name | ||
|
This conversation was marked as resolved.
|
||
| # Except do not sort, just return the first however many documents | ||
| # Useful for short prefixes (e.g., "s") that would be expensive yet not meaningful to sort | ||
| name: taxonomy_ncbi_species_no_sort | ||
| params: | ||
| type: object | ||
| required: [search_text] | ||
| additionalProperties: false | ||
| properties: | ||
| search_text: | ||
| type: string | ||
| title: Search text | ||
| examples: [escherichia, es] | ||
| description: Text to search on the search attribute values | ||
| ts: | ||
| type: [integer, "null"] | ||
| title: Versioning timestamp | ||
| default: null | ||
| offset: | ||
| type: [integer, "null"] | ||
| title: Paging offset | ||
| maximum: 100000 | ||
| default: 0 | ||
| limit: | ||
| type: [integer, "null"] | ||
| title: Max results to return | ||
| default: 20 | ||
| maximum: 1000 | ||
| select: | ||
| type: [string, array, "null"] | ||
| items: | ||
| type: string | ||
| examples: [scientific_name, [scientific_name, id]] | ||
| default: null | ||
| description: Document attributes to keep in the results | ||
| query: | | ||
| LET search_text__icu_toks = TOKENS(@search_text, "icu_tokenize") // analyzer | ||
| LET search_text__wordboundmod_icu_toks = ( | ||
| FOR tok IN search_text__icu_toks | ||
| RETURN REGEX_REPLACE(tok, ",.*", "") // commas cannot be escaped in fulltext search | ||
| ) | ||
| LET search_text__fulltext = CONCAT_SEPARATOR(", ", // comma delimit | ||
| FOR tok IN search_text__wordboundmod_icu_toks // prepend "prefix:" | ||
| RETURN CONCAT("prefix:", tok) | ||
| ) | ||
| FOR doc IN FULLTEXT(ncbi_taxon, "scientific_name", search_text__fulltext) | ||
| FILTER @ts ? doc.created <= @ts AND doc.expired >= @ts : true | ||
| FILTER doc.rank IN ["species", "strain"] OR doc.strain | ||
| LIMIT @offset ? @offset : 0, @limit ? @limit : 20 | ||
| RETURN @select ? KEEP(doc, @select) : doc | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.