Great!
"Create a custom source in Elastic Workplace Search with Python".
I found this article very helpful.
The following manual described several methods other than documentation, which I tried.
However, in my environment, some of them do not work.
Do you know why?
Am I misunderstanding the meaning of document ID?
The source code is shown below.
from elastic_enterprise_search import WorkplaceSearch
WORKPLACE_SEARCH_URL = [REDACTED]
HTTP_AUTH = [REDACTED]
CONTENT_SOURCE_ID = [REDACTED]
workplace_search = WorkplaceSearch(WORKPLACE_SEARCH_URL)
workplace_search.http_auth = HTTP_AUTH
Cases that work.
res = workplace_search.index_documents(
http_auth=HTTP_AUTH,
content_source_id=CONTENT_SOURCE_ID,
documents=[
{
# "_allow_permissions": ["permission1"], # require platinum license
# "_deny_permissions": [], # require platinum license
"id" : 1234,
"title" : "The Meaning of Time",
"body" : "Not much. It is a made up thing.",
"url" : "https://example.com/meaning/of/time",
# "created_at": "2019-06-01T12:00:00+00:00",
"type": "list"
},
{
# "_allow_permissions": [], # require platinum license
# "_deny_permissions": ["permission2"], # require platinum license
"id" : 1235,
"title" : "The Meaning of Sleep",
"body" : "Rest, recharge, and connect to the Ether.",
"url" : "https://example.com/meaning/of/sleep",
# "created_at": "2019-06-01T12:00:00+00:00",
"type": "list"
}
]
)
Cases where things go wrong.
res = workplace_search.get_document(
# http_auth=HTTP_AUTH,
content_source_id=CONTENT_SOURCE_ID,
# document_id="1234",#NG
document_id=1234,#NG
# document_id=[1234],#NG
)
res = workplace_search.get_content_source(
content_source_id=CONTENT_SOURCE_ID,
)
res = workplace_search.list_content_sources()
All have the following error message
raise HTTP_EXCEPTIONS.get(status, APIError)(
elastic_transport.exceptions.NotFoundError: [404] {'error': 'Routing Error. The path you have requested is invalid.'}