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
Method details
index
public abstract void index(String index, String id, Map document)
throws IOExceptionAdds a document under
id, replacing any already there.Throws
delete
public abstract boolean delete(String index, String id)
throws IOExceptionRemoves a document; returns whether there was one.
Throws
get
public abstract Map get(String index, String id)
throws IOExceptionThe document stored under
id, or null.Throws
search
public abstract SearchResult search(String index, SearchQuery query)
throws IOExceptionRuns a query.
Throws
refresh
public abstract void refresh(String index)
throws IOExceptionMakes every write so far visible to
search. Search clusters publish
writes about once a second; tests and read-your-write flows call this.Throws
deleteIndex
public abstract void deleteIndex(String index)
throws IOExceptionRemoves an index and every document in it; a missing one is not an error.
Throws
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.