Package com.codename1.backend.search


package com.codename1.backend.search

Full-text search behind one interface, over Elasticsearch, OpenSearch or the application's own SQL database.

SearchEngines.current() opens the engine cn1.search.url names:

URL Engine
https://user:pass@host:9200 Elasticsearch or OpenSearch over its REST API
aws://search-domain.us-east-1.es.amazonaws.com Amazon OpenSearch Service, signed with SigV4
aoss://id.us-east-1.aoss.amazonaws.com Amazon OpenSearch Serverless, signed with SigV4
database: (the default) the configured SQL database: PostgreSQL text search, MySQL FULLTEXT, or a scan on SQLite

Code written against SearchEngine runs unchanged on each, so a project can start on its database and move to a search cluster by changing one setting. What differs is relevance: each engine ranks by its own scoring, and the SQL engine applies filters, sorting and facets in memory over at most SqlSearchEngine.MAX_CANDIDATES matches, which is right for a catalogue of thousands and wrong for one of millions.

  • Class
    Description
    Elasticsearch (7 and 8) and OpenSearch over their REST API.
    A full-text search engine: documents in named indexes, found by text.
    Opens the SearchEngine a configuration names, and finds the one of the calling thread's server.
    One matching document.
    Keeps the index of each @Searchable entity in step with what a session committed.
    What to search for: text, exact filters, an order, a page, and the fields to count facet values of.
    One page of hits, the total and the facet counts.
    Full-text search in the application's own SQL database, for a project that does not run a search cluster.