Class ElasticsearchEngine
java.lang.Object
com.codename1.backend.search.ElasticsearchEngine
- All Implemented Interfaces:
SearchEngine, Closeable, AutoCloseable
Elasticsearch (7 and 8) and OpenSearch over their REST API.
The request bodies used are the subset both projects share: bool queries
with multi_match and term, terms aggregations,
highlight and track_total_hits. Basic authentication comes from the URL,
an API key from cn1.search.apiKey, and an Amazon OpenSearch domain is signed
with SigV4 instead.
-
Method Summary
Modifier and TypeMethodDescriptionstatic ElasticsearchEngineAn Amazon OpenSearch domain (service"es") or serverless collection ("aoss") athost, signed with credentials resolved the usual way.voidclose()Releases connections.static ElasticsearchEngineA cluster aturl(http://orhttps://, user and password in the URL when it needs them);apiKeyis the encoded key or null.booleanRemoves a document; returns whether there was one.voiddeleteIndex(String index) Removes an index and every document in it; a missing one is not an error.The document stored underid, or null.voidAdds a document underid, replacing any already there.voidMakes every write so far visible toSearchEngine.search(String, SearchQuery).search(String index, SearchQuery q) Runs a query.
-
Method Details
-
connect
A cluster aturl(http://orhttps://, user and password in the URL when it needs them);apiKeyis the encoded key or null.- Throws:
IOException
-
aws
public static ElasticsearchEngine aws(String host, String service, String region) throws IOException An Amazon OpenSearch domain (service"es") or serverless collection ("aoss") athost, signed with credentials resolved the usual way.- Throws:
IOException
-
index
Description copied from interface:SearchEngineAdds a document underid, replacing any already there.- Specified by:
indexin interfaceSearchEngine- Throws:
IOException
-
delete
Description copied from interface:SearchEngineRemoves a document; returns whether there was one.- Specified by:
deletein interfaceSearchEngine- Throws:
IOException
-
get
Description copied from interface:SearchEngineThe document stored underid, or null.- Specified by:
getin interfaceSearchEngine- Throws:
IOException
-
search
Description copied from interface:SearchEngineRuns a query.- Specified by:
searchin interfaceSearchEngine- Throws:
IOException
-
refresh
Description copied from interface:SearchEngineMakes every write so far visible toSearchEngine.search(String, SearchQuery). Search clusters publish writes about once a second; tests and read-your-write flows call this.- Specified by:
refreshin interfaceSearchEngine- Throws:
IOException
-
deleteIndex
Description copied from interface:SearchEngineRemoves an index and every document in it; a missing one is not an error.- Specified by:
deleteIndexin interfaceSearchEngine- Throws:
IOException
-
close
public void close()Description copied from interface:SearchEngineReleases connections. An engine fromSearchEngines.current()is closed by the server and must not be closed by the caller.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceSearchEngine
-