forked from the-library-code/dspace-rest-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsolr_example.py
More file actions
32 lines (25 loc) · 836 Bytes
/
solr_example.py
File metadata and controls
32 lines (25 loc) · 836 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import sys
import logging
from requests.auth import HTTPBasicAuth
from dspace_rest_client.client import DSpaceClient
url = "http://localhost:8080/server/api"
username = "username@domain.com"
password = "password"
# To auth solr do like this and pass it as the argument in DSpaceClient
solr_auth = HTTPBasicAuth("user", "pass")
# Instantiate DSpace client
d = DSpaceClient(
api_endpoint=url,
username=username,
password=password,
solr_endpoint="http://localhost:8983/solr/search",
solr_auth=None,
)
# Here's an example of a wildcard query with some filters to apply and some fields to return
results = d.solr_query(
"*:*",
filters=["search.resourcetype:Item", "search.entitytype:*"],
fields=["search.resourceid", "search.entitytype"],
)
for doc in results.docs:
logging.info.plogging.info(doc)