-
Notifications
You must be signed in to change notification settings - Fork 5
Elastic search Query
Blair Learn edited this page Nov 8, 2021
·
50 revisions
When expanding a letter, use this query, substituting:
- For
language, either "en" (English) or "es" (Spanish). - For
audience, either "Patient" or "HealthProfessional". - For
dictionary, either "Cancer.gov" for the Dictionary of Cancer Terms or "Genetics" for the Dictionary of Genetics Terms - For
first_letter, the letter to expand. To expand non-alphabetic first letters, specify"#". - For
from, the zero-based offset into the list of results for the first one to return. - For
size, the maximum number of results to return (default is 9999). - For
_source, a list of field names to be returned.- NOTE: Any fields that are enumerations MUST be returned as enumerations are not NULLABLE
curl -XPOST http://SERVER_NAME/glossaryv1/_search -H 'Content-Type: application/x-ndjson' -d '{
"query": {
"bool": {
"must":
[
{"term": { "language": "en"}},
{"term": { "audience": "Patient"}},
{"term": { "dictionary": "Cancer.gov"}},
{"term": { "first_letter": "m"}}
]
}}
,"sort": ["term_name"]
, "from": 0
, "size": 9999
, "_source": ["term_id", "language", "dictionary", "audience", "term_name", "definition", "pretty_url_name", "first_letter", "pronunciation"]
}'
Use this query for autosuggest "Begins with", substituting
- For
language, either "en" (English) or "es" (Spanish). - For
audience, either "Patient" or "HealthProfessional". - For
dictionary, either "Cancer.gov" for the Dictionary of Cancer Terms or "Genetics" for the Dictionary of Genetics Terms - For
term_name, the text to be used for the suggestion. - For
from, the zero-based offset into the list of results for the first one to return. - For
size, the maximum number of results to return (default is 9999). - For
_source, a list of field names to be returned. (This will probably be the list shown.)
curl -XPOST http://SERVER_NAME/glossaryv1/_search -H 'Content-Type: application/x-ndjson' -d '{
"query": {
"bool" : {
"must" :
[{"term" : { "language" : "es" }},
{"term": { "audience": "Patient"}},
{"term": { "dictionary": "Cancer.gov"}},
{"prefix" : {"term_name" : "cutáneo"}}
]
}
}
,"sort": ["term_name"]
, "_source": ["term_id", "term_name"]
, "from": 0
, "size": 10
}'
Use this query for autosuggest "Contains", substituting
- For
language, either "en" (English) or "es" (Spanish). - For
audience, either "Patient" or "HealthProfessional". - For
dictionary, either "Cancer.gov" for the Dictionary of Cancer Terms or "Genetics" for the Dictionary of Genetics Terms - For
term_name, the text to be used for the suggestion. - For
from, the zero-based offset into the list of results for the first one to return. - For
size, the maximum number of results to return (default is 9999). - For
_source, a list of field names to be returned. (This will probably be the list shown.)
curl -XPOST http://SERVER_NAME/glossaryv1/_search -H 'Content-Type: application/x-ndjson' -d '{
"query": {
"bool" : {
"must" :
[{"term" : { "language" : "es" }},
{"term" : { "dictionary" : "Cancer.gov" }},
{"term": { "audience": "Patient"}},
{"match_phrase":{"term_name._autocomplete":"cutáneo"}}
],
"must_not" : {"prefix" : {"term_name" : "cutáneo"}}
}
}
,"sort": ["term_name"]
, "_source": ["term_id", "term_name"]
, "from": 0
, "size": 10
}'
Use this query for search "Begins with", substituting
- For
language, either "en" (English) or "es" (Spanish). - For
audience, either "Patient" or "HealthProfessional". - For
dictionary, either "Cancer.gov" for the Dictionary of Cancer Terms or "Genetics" for the Dictionary of Genetics Terms - For
term_name, the text to be searched for. - For
from, the zero-based offset into the list of results for the first one to return. - For
size, the maximum number of results to return (default is 9999). - For
_source, a list of field names to be returned.
curl -XPOST http://SERVER_NAME/glossaryv1/_search -H 'Content-Type: application/x-ndjson' -d '{
"query": {
"bool" : {
"must" :
[{"term" : { "language" : "es" }},
{"term" : { "dictionary" : "Cancer.gov" }},
{"term": { "audience": "Patient"}},
{"prefix" : {"term_name" : "cutáneo"}}
]
}
}
,"sort": ["term_name"]
, "_source": ["term_id", "language", "dictionary", "audience", "term_name", "definition", "pretty_url_name", "first_letter", "pronunciation"]
, "from": 40
, "size": 20
}'
Use this query for search "Contains", substituting
- For
language, either "en" (English) or "es" (Spanish). - For
audience, either "Patient" or "HealthProfessional". - For
dictionary, either "Cancer.gov" for the Dictionary of Cancer Terms or "Genetics" for the Dictionary of Genetics Terms - For
term_name, the text to be searched for. - For
from, the zero-based offset into the list of results for the first one to return. - For
size, the maximum number of results to return (default is 9999). - For
_source, a list of field names to be returned.
curl -XPOST http://SERVER_NAME/glossaryv1/_search -H 'Content-Type: application/x-ndjson' -d '{
"query": {
"bool" : {
"must" :
[{"term" : { "language" : "es" }},
{"term" : { "dictionary" : "Cancer.gov" }},
{"term": { "audience": "Patient"}},
{"match":{"term_name._contain":"cutáneo"}}
]
}
}
,"sort": ["term_name"]
, "_source": ["term_id", "language", "dictionary", "audience", "term_name", "definition", "pretty_url_name", "first_letter", "pronunciation"]
, "from": 40
, "size": 20
}'
Get a specific term by concatenating the values for
-
{term_id), the specific term ID to retrieve. -
{dictionary}, the name of the desired dictionary. -
{language}, the two digit language code. -
{audience}, either "Patient" or "healthprofessional".
The values are separated by underscores (_) and all characters are lowercase.
Get http request
curl /glossaryv1/_doc/43966_cancer.gov_en_patient
Use this query to get all definitions for a term regardless of target audience and dictionary, substituting
- For
language, either "en" (English) or "es" (Spanish). - For
term_id, the specific term ID to retrieve. - For
from, the zero-based offset into the list of results for the first one to return. - For
size, the maximum number of results to return (default is 9999).
curl -XPOST http://SERVER_NAME/glossaryv1/_search -H 'Content-Type: application/x-ndjson' -d '{
"query": {
"bool": {
"must":
[
{"term": { "language": "en"}},
{"term": { "term_id": "44238"}}
]
}}
, "from": 40
, "size": 20
}'
curl -XPOST http://SERVER_NAME/glossaryv1/_search -H 'Content-Type: application/x-ndjson' -d '{
"query": {
"bool" : {
"must" :
[{"term" : { "language" : "en" }},
{"term" : { "dictionary" : "Cancer.gov" }},
{"term": { "audience": "Patient"}}
]
}
}
,"sort": ["term_name"]
, "_source": ["term_name", "definition", "pretty_url_name", "related_resources", "media", "pronunciation"]
, "size": 9999
}'
Gets the total number of glossary terms matching the criteria, substituting
-
{dictionary}, the name of the desired dictionary. -
{language}, the two digit language code. -
{audience}, either "Patient" or "healthprofessional".
This uses _count API of ES instead of _search API
curl -XPOST http://SERVER_NAME/glossaryv1/_count -H 'Content-Type: application/x-ndjson' -d '{
"query": {
"bool" : {
"must" :
[{"term" : { "language" : "es" }},
{"term" : { "dictionary" : "Cancer.gov" }},
{"term": { "audience": "Patient"}}
]
}
}
}'
curl -XPOST http://SERVER_NAME/glossaryv1/_search -H 'Content-Type: application/x-ndjson' -d '{
"query": {
"bool": {
"must":
[
{"term": { "language": "en"}},
{"term": { "audience": "Patient"}},
{"term": { "dictionary": "Cancer.gov"}},
{"term": { "pretty_url_name": "stage-iv-lip-and-oral-cavity-cancer"}}
]
}}
,"sort": ["term_name"]
, "from": 0
, "size": 9999
, "_source": ["term_id", "language", "dictionary", "audience", "term_name", "definition", "pretty_url_name", "first_letter", "pronunciation"]
}'
curl -XPOST http://SERVER_NAME/glossaryv1/_search -H 'Content-Type: application/x-ndjson' -d '{
"query": {
"bool": {
"must":
[
{"term": { "language": "en"}},
{"term": { "audience": "Patient"}},
{"term": { "dictionary": "Cancer.gov"}},
{ "term": { "term_name": "mk-0646"}}
]
}}
}'