Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
N
NACSOS Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MCC APSIS
NACSOS
NACSOS Core
Commits
b68b4031
Commit
b68b4031
authored
1 year ago
by
Tim Repke
Browse files
Options
Downloads
Patches
Plain Diff
add oa search route
parent
08b81999
No related branches found
No related tags found
1 merge request
!53
OpenAlex Search and pydantic v2 migration
Pipeline
#1852
failed
1 year ago
Stage: build
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
.gitlab-ci.yml
+1
-1
1 addition, 1 deletion
.gitlab-ci.yml
server/api/routes/search.py
+23
-7
23 additions, 7 deletions
server/api/routes/search.py
with
24 additions
and
8 deletions
.gitlab-ci.yml
+
1
−
1
View file @
b68b4031
...
...
@@ -52,7 +52,7 @@ test-job2:
-
source venv/bin/activate
-
which python
-
pip freeze
-
python -m mypy --config-file=pyproject.toml server
-
python -m mypy --config-file=pyproject.toml server
--show-traceback --no-incremental
deploy-to-production
:
stage
:
deploy
...
...
This diff is collapsed.
Click to expand it.
server/api/routes/search.py
+
23
−
7
View file @
b68b4031
from
fastapi
import
APIRouter
,
Depends
from
pydantic
import
BaseModel
from
typing
import
Literal
import
httpx
from
pydantic
import
BaseModel
from
fastapi
import
APIRouter
,
Depends
from
nacsos_data.util.academic.openalex
import
query_async
,
SearchResult
from
server.util.security
import
UserPermissionChecker
,
UserPermissions
from
server.util.logging
import
get_logger
...
...
@@ -18,11 +22,23 @@ class TermStats(BaseModel):
ttf
:
int
@router.get
(
'
/openalex
'
,
response_model
=
str
)
async
def
search_openalex
(
import_id
:
str
,
permissions
:
UserPermissions
=
Depends
(
UserPermissionChecker
(
'
search_oa
'
))):
# u = settings.OA_SOLR
pass
@router.get
(
'
/openalex
'
,
response_model
=
SearchResult
)
async
def
search_openalex
(
query
:
str
,
limit
:
int
=
20
,
field
:
Literal
[
'
title
'
,
'
abstract
'
,
'
title_abstract
'
]
=
'
title_abstract
'
,
histogram
:
bool
=
False
,
op
:
Literal
[
'
OR
'
,
'
AND
'
]
=
'
AND
'
,
histogram_from
:
int
=
1990
,
histogram_to
:
int
=
2024
,
permissions
:
UserPermissions
=
Depends
(
UserPermissionChecker
(
'
search_oa
'
)))
->
SearchResult
:
return
await
query_async
(
query
=
query
,
openalex_endpoint
=
f
'
{
settings
.
OA_SOLR
}
/select
'
,
histogram
=
histogram
,
histogram_to
=
histogram_to
,
histogram_from
=
histogram_from
,
op
=
op
,
field
=
field
,
limit
=
limit
)
@router.post
(
'
/terms
'
,
response_model
=
list
[
TermStats
])
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment