Backend API. Server-side code: this runs in a Codename One backend, not in the app on the device.

public interface SearchEngine

ExtendsAutoCloseable, Closeable

Known subtypesElasticsearchEngine, SqlSearchEngine

A full-text search engine: documents in named indexes, found by text.

A document is a Map of strings, numbers, booleans, lists and nested maps; every string in it is searchable. Index names are lowercase letters, digits, - and _, the subset every engine accepts.

Methods

public abstract void index(String index, String id, Map document) throws IOExceptionAdds a document under id, replacing any already there.
public abstract boolean delete(String index, String id) throws IOExceptionRemoves a document; returns whether there was one.
public abstract Map get(String index, String id) throws IOExceptionThe document stored under id, or null.
public abstract SearchResult search(String index, SearchQuery query) throws IOExceptionRuns a query.
public abstract void refresh(String index) throws IOExceptionMakes every write so far visible to search.
public abstract void deleteIndex(String index) throws IOExceptionRemoves an index and every document in it; a missing one is not an error.
public abstract void close()Releases connections.

Method details

index

public abstract void index(String index, String id, Map document) throws IOException
Adds a document under id, replacing any already there.

delete

public abstract boolean delete(String index, String id) throws IOException
Removes a document; returns whether there was one.

get

public abstract Map get(String index, String id) throws IOException
The document stored under id, or null.

search

public abstract SearchResult search(String index, SearchQuery query) throws IOException
Runs a query.

refresh

public abstract void refresh(String index) throws IOException
Makes every write so far visible to search. Search clusters publish writes about once a second; tests and read-your-write flows call this.

deleteIndex

public abstract void deleteIndex(String index) throws IOException
Removes an index and every document in it; a missing one is not an error.

close

public abstract void close()
Releases connections. An engine from SearchEngines.current() is closed by the server and must not be closed by the caller.