Commit fe569bcf authored by fabian serin's avatar fabian serin
Browse files

Search wellLogs in progress

parent 2290a139
Pipeline #59524 passed with stages
in 8 minutes and 3 seconds
......@@ -127,8 +127,8 @@ async def query_request_with_specific_attribute(query_type: str, attribute: str,
def update_query_with_names_based_search(names: str = None, user_query: str = None) -> str:
generated_query = f"data.FacilityName:{names}"
def update_query_with_names_based_search(names: str = None, user_query: str = None, name_field = "data.FacilityName") -> str:
generated_query = f"{name_field}:{names}"
return added_query(generated_query, user_query)
......
......@@ -20,6 +20,7 @@ from .search_v3 import (
DEFAULT_QUERYREQUEST,
OSDU_WELLBORE_KIND,
OSDU_WELLBORETRAJECTORY_KIND,
OSDU_WELLLOG_KIND,
escape_forbidden_characters_for_search,
update_query_with_names_based_search,
query_request,
......@@ -53,3 +54,17 @@ async def query_trajectories_bywellbore(wellboreId: str, body: SearchQueryReques
ctx: Context = Depends(get_ctx)):
body.query = added_relationships_query(wellboreId, WELLBORE_RELATIONSHIP, body.query)
return await query_request(query_type, OSDU_WELLBORETRAJECTORY_KIND, ctx, body)
@router.post('/query/welllogs/byname',
summary='Query with cursor, search WellLogs by name and optionally by wellbore ID',
description=f"""Get all WellLogs objects using its name and optionally relationship Wellbore ID.
<p>The WellLogs kind is {OSDU_WELLLOG_KIND} returns all records directly based on existing schemas. The query is done on data.Name field</p>{REQUIRED_ROLES_READ}""",
response_model=CursorQueryResponse)
async def query_trajectories_bywellbore(names: str, wellbore_id: str = None, body: SearchQueryRequest = DEFAULT_QUERYREQUEST,
ctx: Context = Depends(get_ctx)):
if wellbore_id is not None:
body.query = added_relationships_query(wellbore_id, WELLBORE_RELATIONSHIP, body.query)
names = escape_forbidden_characters_for_search(names)
body.query = update_query_with_names_based_search(names=names, user_query=body.query, name_field="data.Name")
return await query_request(query_type, OSDU_WELLLOG_KIND, ctx, body)
......@@ -48,7 +48,7 @@ from app.routers.ddms_v3 import (
from app.routers.bulk import bulk_routes
from app.routers.trajectory import trajectory_ddms_v2
from app.routers.dipset import dipset_ddms_v2, dip_ddms_v2
from app.routers.search import search, fast_search, search_v3, fast_search_v3, search_v3_wellbore
from app.routers.search import search, fast_search, search_v3, fast_search_v3, search_v3_alpha
from app.clients import StorageRecordServiceClient, SearchServiceClient
from app.utils import (
get_http_client_session,
......@@ -206,7 +206,7 @@ wdms_app.include_router(fast_search.router, prefix='/ddms', tags=['fast-search']
wdms_app.include_router(search_v3.router, prefix=DDMS_V3_PATH, tags=['search v3'], dependencies=basic_dependencies)
wdms_app.include_router(fast_search_v3.router, prefix=DDMS_V3_PATH, tags=['fast-search v3'],
dependencies=basic_dependencies)
wdms_app.include_router(search_v3_wellbore.router, prefix=ALPHA_APIS_PREFIX+DDMS_V3_PATH, tags=['ALPHA feature: search v3'],
wdms_app.include_router(search_v3_alpha.router, prefix=ALPHA_APIS_PREFIX + DDMS_V3_PATH, tags=['ALPHA feature: search v3'],
dependencies=basic_dependencies)
......
......@@ -9354,6 +9354,90 @@
]
}
},
"/alpha/ddms/v3/query/welllogs/byname": {
"post": {
"description": "Get all WellLogs objects using its name and optionally relationship Wellbore ID. \n <p>The WellLogs kind is *:wks:work-product-component--WellLog:* returns all records directly based on existing schemas. The query is done on data.Name field</p>\n<p>Required roles: 'users.datalake.viewers' or 'users.datalake.editors' or 'users.datalake.admins'.\n\"In addition, users must be a member of data groups to access the data.</p>\n",
"operationId": "query_trajectories_bywellbore_alpha_ddms_v3_query_welllogs_byname_post",
"parameters": [
{
"in": "query",
"name": "names",
"required": true,
"schema": {
"title": "Names",
"type": "string"
}
},
{
"in": "query",
"name": "wellbore_id",
"required": false,
"schema": {
"title": "Wellbore Id",
"type": "string"
}
},
{
"description": "identifier of the data partition to query",
"in": "header",
"name": "data-partition-id",
"required": false,
"schema": {
"description": "identifier of the data partition to query",
"minLength": 1,
"title": "data partition id",
"type": "string"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"allOf": [
{
"$ref": "#/components/schemas/SearchQueryRequest"
}
],
"default": {},
"title": "Body"
}
}
}
},
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CursorQueryResponse"
}
}
},
"description": "Successful Response"
},
"422": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HTTPValidationError"
}
}
},
"description": "Validation Error"
}
},
"security": [
{
"HTTPBearer": []
}
],
"summary": "Query with cursor, search WellLogs by name and optionally by wellbore ID",
"tags": [
"ALPHA feature: search v3"
]
}
},
"/ddms/fastquery/logs": {
"post": {
"description": "Get all Logs object. <p>The Logs kind is\n *:wks:log:* returns all records IDs directly based on existing schemas</p>\n<p>Required roles: 'users.datalake.viewers' or 'users.datalake.editors' or 'users.datalake.admins'.\n\"In addition, users must be a member of data groups to access the data.</p>\n",
......
......@@ -379,3 +379,37 @@ def build_request_search_trajectory_by_wellbore_id() -> RequestRunner:
payload='{}'
)
return RequestRunner(rq_proto)
def build_request_search_welllog_by_name() -> RequestRunner:
rq_proto = Request(
name='search wellbore by name',
method='POST',
url='{{base_url}}/alpha/ddms/v3/{{search_query_type}}/welllogs/byname?names=wdms_e2e_search_record_%2A',
headers={
'accept': 'application/json',
'data-partition-id': '{{data_partition}}',
'Connection': '{{header_connection}}',
'Authorization': 'Bearer {{token}}',
},
payload='{}'
)
return RequestRunner(rq_proto)
def build_request_search_welllog_by_name_and_wellbore() -> RequestRunner:
rq_proto = Request(
name='search wellbore by name',
method='POST',
url='{{base_url}}/alpha/ddms/v3/{{search_query_type}}/welllogs/byname?names=wdms_e2e_search_record_%2A'
'&wellbore_id={{setup_search_osdu_wellbore_id}}',
headers={
'accept': 'application/json',
'data-partition-id': '{{data_partition}}',
'Connection': '{{header_connection}}',
'Authorization': 'Bearer {{token}}',
},
payload='{}'
)
return RequestRunner(rq_proto)
......@@ -114,3 +114,23 @@ def test_search_trajectory_by_wellbore_id(with_wdms_env):
env.set('search_query_type', 'query')
resobj = build_request_search_trajectory_by_wellbore_id().call(with_wdms_env, assert_status=200).get_response_obj()
assert resobj.totalCount >= 1
@pytest.mark.tag('search')
@pytest.mark.dependency(depends=["test_setup_for_search"])
def test_search_wellLog_by_name(with_wdms_env):
#Only search and no fast search
env = with_wdms_env
env.set('search_query_type', 'query')
resobj = build_request_search_welllog_by_name().call(with_wdms_env, assert_status=200).get_response_obj()
assert resobj.totalCount >= 1
@pytest.mark.tag('search')
@pytest.mark.dependency(depends=["test_setup_for_search"])
def test_search_wellLog_by_name_and_wellbore(with_wdms_env):
#Only search and no fast search
env = with_wdms_env
env.set('search_query_type', 'query')
resobj = build_request_search_welllog_by_name_and_wellbore().call(with_wdms_env, assert_status=200).get_response_obj()
assert resobj.totalCount >= 1
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment