infrastructure tier

infrastructure-search

Full-text search abstraction (Meilisearch, PostgreSQL FTS)

Full-text search abstraction (Meilisearch, PostgreSQL FTS)

Tierinfrastructure
Roleunclassified (baselined)
Pathcrates/infrastructure/search
Edition2021
Targetsinfrastructure_search
Public items73 across 1 module
Tests30

What it is for

Full-text search abstraction for Rust applications.

This crate provides a unified interface for full-text search across different backends (PostgreSQL FTS, Meilisearch, Elasticsearch).

Capabilities

AutocompleteConfig

Full-text search abstraction for Rust applications.

Item
pub struct AutocompleteConfig
AutocompleteConfig :: fn default() -> Self

FacetResult

Full-text search abstraction for Rust applications.

Item
pub struct FacetResult

FacetValue

Full-text search abstraction for Rust applications.

Item
pub struct FacetValue

FilterOperator

Full-text search abstraction for Rust applications.

Item
pub enum FilterOperator

InMemorySearchEngine

Full-text search abstraction for Rust applications.

Item
pub struct InMemorySearchEngine
InMemorySearchEngine :: fn new() -> Self
InMemorySearchEngine :: async fn create_index(& self, config : IndexConfig) -> Result <()>
InMemorySearchEngine :: async fn delete_index(& self, name : & str) -> Result <()>
InMemorySearchEngine :: async fn index_exists(& self, name : & str) -> Result <bool>
InMemorySearchEngine :: async fn index_document(& self, doc : SearchDocument) -> Result <()>
InMemorySearchEngine :: async fn index_documents(& self, docs : Vec <SearchDocument>) -> Result <()>
InMemorySearchEngine :: async fn delete_document(& self, index : & str, id : & str) -> Result <()>
InMemorySearchEngine :: async fn search(& self, query : SearchQuery) -> Result <SearchResults>
InMemorySearchEngine :: async fn get_document(& self, index : & str, id : & str) -> Result <Option <SearchDocument>>

IndexConfig

Full-text search abstraction for Rust applications.

Item
pub struct IndexConfig
IndexConfig :: fn new(name : impl Into <String>) -> Self
IndexConfig :: fn with_primary_key(mut self, key : impl Into <String>) -> Self
IndexConfig :: fn with_searchable_fields(mut self, fields : Vec <impl Into <String>>) -> Self
IndexConfig :: fn with_filterable_fields(mut self, fields : Vec <impl Into <String>>) -> Self
IndexConfig :: fn with_sortable_fields(mut self, fields : Vec <impl Into <String>>) -> Self

Result

Full-text search abstraction for Rust applications.

Item
pub type Result<T>: std::result::Result <T, SearchError>

SearchBackend

Full-text search abstraction for Rust applications.

Item
pub enum SearchBackend
SearchBackend :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result

SearchDocument

Full-text search abstraction for Rust applications.

Item
pub struct SearchDocument
SearchDocument :: fn new(id : impl Into <String>, index : impl Into <String>) -> Self
SearchDocument :: fn with_field(mut self, key : impl Into <String>, value : impl Serialize) -> Self
SearchDocument :: fn get_field <T : for <'de> Deserialize <'de>>(& self, key : & str) -> Option <T>
SearchDocument :: fn with_indexed_at(mut self, at : DateTime <Utc>) -> Self

SearchEngine

Full-text search abstraction for Rust applications.

Item
pub trait SearchEngine

SearchError

Full-text search abstraction for Rust applications.

Item
pub enum SearchError

SearchFilter

Full-text search abstraction for Rust applications.

Item
pub struct SearchFilter
SearchFilter :: fn eq(field : impl Into <String>, value : impl Serialize) -> Self
SearchFilter :: fn ne(field : impl Into <String>, value : impl Serialize) -> Self
SearchFilter :: fn gt(field : impl Into <String>, value : impl Serialize) -> Self
SearchFilter :: fn lt(field : impl Into <String>, value : impl Serialize) -> Self
SearchFilter :: fn in_values(field : impl Into <String>, values : Vec <impl Serialize>) -> Self
SearchFilter :: fn range(field : impl Into <String>, min : impl Serialize, max : impl Serialize) -> Self

SearchHit

Full-text search abstraction for Rust applications.

Item
pub struct SearchHit
SearchHit :: fn new(id : impl Into <String>, score : f64) -> Self
SearchHit :: fn with_field(mut self, key : impl Into <String>, value : impl Serialize) -> Self
SearchHit :: fn get_field <T : for <'de> Deserialize <'de>>(& self, key : & str) -> Option <T>

SearchQuery

Full-text search abstraction for Rust applications.

Item
pub struct SearchQuery
SearchQuery :: fn new(query : impl Into <String>, index : impl Into <String>) -> Self
SearchQuery :: fn with_fields(mut self, fields : Vec <String>) -> Self
SearchQuery :: fn with_filter(mut self, filter : SearchFilter) -> Self
SearchQuery :: fn with_sort(mut self, field : impl Into <String>, direction : SortDirection) -> Self
SearchQuery :: fn with_pagination(mut self, offset : usize, limit : usize) -> Self
SearchQuery :: fn with_highlight(mut self) -> Self
SearchQuery :: fn with_facets(mut self, facets : Vec <String>) -> Self

SearchResults

Full-text search abstraction for Rust applications.

Item
pub struct SearchResults
SearchResults :: fn empty(query : impl Into <String>) -> Self
SearchResults :: fn is_empty(& self) -> bool
SearchResults :: fn len(& self) -> usize

SortDirection

Full-text search abstraction for Rust applications.

Item
pub enum SortDirection

SortField

Full-text search abstraction for Rust applications.

Item
pub struct SortField

Suggestion

Full-text search abstraction for Rust applications.

Item
pub struct Suggestion

postgres (other)

PostgreSQL-backed search engine implementation.

Item
fn filter_to_sql(filter : & crate::SearchFilter, param_offset : usize) ->(String, Vec <String>)
fn text_search_sql(query : & str, fields : & & str, param_offset : usize) ->(String, String)
fn sort_to_sql(query : & SearchQuery, allowed_fields : & & str) -> String
fn build_facet(field : & str, values : Vec <(String, u64)>) -> FacetResult
fn build_hit(id : & str, fields : Vec <(& str, serde_json::Value)>) -> SearchHit

PostgresSearchEngine

PostgreSQL-backed search engine implementation.

Item
pub struct PostgresSearchEngine
PostgresSearchEngine :: fn new(pool : PgPool) -> Self
PostgresSearchEngine :: fn pool(& self) -> & PgPool
PostgresSearchEngine :: async fn create_index(& self, _config : IndexConfig) -> crate::Result <()>
PostgresSearchEngine :: async fn delete_index(& self, _name : & str) -> crate::Result <()>
PostgresSearchEngine :: async fn index_exists(& self, _name : & str) -> crate::Result <bool>
PostgresSearchEngine :: async fn index_document(& self, _doc : SearchDocument) -> crate::Result <()>
PostgresSearchEngine :: async fn index_documents(& self, _docs : Vec <SearchDocument>) -> crate::Result <()>
PostgresSearchEngine :: async fn delete_document(& self, _index : & str, _id : & str) -> crate::Result <()>
PostgresSearchEngine :: async fn get_document(& self, _index : & str, _id : & str) -> crate::Result <Option <SearchDocument>>
PostgresSearchEngine :: async fn search(& self, query : SearchQuery) -> crate::Result <SearchResults>

How to use it

No examples/ target and no doctest in this crate's rustdoc. The tests listed under Verification are the closest executable usage.

Module structure

infrastructure_search

Public surface

`crate root`

ItemWhat it is
pub enum SearchErrorErrors that can occur during search operations.
pub type Result<T>: std::result::Result <T, SearchError>Result type for search operations.
pub enum SearchBackendSearch backend type.
SearchBackend :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result
pub struct SearchDocumentA searchable document.
SearchDocument :: fn new(id : impl Into <String>, index : impl Into <String>) -> SelfCreates a new search document.
SearchDocument :: fn with_field(mut self, key : impl Into <String>, value : impl Serialize) -> SelfAdds a field to the document.
SearchDocument :: fn get_field <T : for <'de> Deserialize <'de>>(& self, key : & str) -> Option <T>Gets a field value.
SearchDocument :: fn with_indexed_at(mut self, at : DateTime <Utc>) -> SelfSets the indexed timestamp.
pub struct SearchQuerySearch query configuration.
SearchQuery :: fn new(query : impl Into <String>, index : impl Into <String>) -> SelfCreates a new search query.
SearchQuery :: fn with_fields(mut self, fields : Vec <String>) -> SelfLimits search to specific fields.
SearchQuery :: fn with_filter(mut self, filter : SearchFilter) -> SelfAdds a filter.
SearchQuery :: fn with_sort(mut self, field : impl Into <String>, direction : SortDirection) -> SelfAdds sort configuration.
SearchQuery :: fn with_pagination(mut self, offset : usize, limit : usize) -> SelfSets pagination.
SearchQuery :: fn with_highlight(mut self) -> SelfEnables highlighting.
SearchQuery :: fn with_facets(mut self, facets : Vec <String>) -> SelfAdds facets to compute.
pub struct SearchFilterA search filter.
SearchFilter :: fn eq(field : impl Into <String>, value : impl Serialize) -> SelfCreates an equals filter.
SearchFilter :: fn ne(field : impl Into <String>, value : impl Serialize) -> SelfCreates a not equals filter.
SearchFilter :: fn gt(field : impl Into <String>, value : impl Serialize) -> SelfCreates a greater than filter.
SearchFilter :: fn lt(field : impl Into <String>, value : impl Serialize) -> SelfCreates a less than filter.
SearchFilter :: fn in_values(field : impl Into <String>, values : Vec <impl Serialize>) -> SelfCreates an "in" filter.
SearchFilter :: fn range(field : impl Into <String>, min : impl Serialize, max : impl Serialize) -> SelfCreates a range filter.
pub enum FilterOperatorFilter operators.
pub enum SortDirectionSort direction.
pub struct SortFieldSort field configuration.
pub struct SearchHitA search result hit.
SearchHit :: fn new(id : impl Into <String>, score : f64) -> SelfCreates a new search hit.
SearchHit :: fn with_field(mut self, key : impl Into <String>, value : impl Serialize) -> SelfAdds a field.
SearchHit :: fn get_field <T : for <'de> Deserialize <'de>>(& self, key : & str) -> Option <T>Gets a field value.
pub struct FacetResultFacet result.
pub struct FacetValueA single facet value with count.
pub struct SearchResultsSearch results.
SearchResults :: fn empty(query : impl Into <String>) -> SelfCreates empty search results.
SearchResults :: fn is_empty(& self) -> boolReturns true if there are no results.
SearchResults :: fn len(& self) -> usizeReturns the number of hits.
pub struct IndexConfigIndex configuration.
IndexConfig :: fn new(name : impl Into <String>) -> SelfCreates a new index configuration.
IndexConfig :: fn with_primary_key(mut self, key : impl Into <String>) -> SelfSets the primary key field.
IndexConfig :: fn with_searchable_fields(mut self, fields : Vec <impl Into <String>>) -> SelfSets searchable fields.
IndexConfig :: fn with_filterable_fields(mut self, fields : Vec <impl Into <String>>) -> SelfSets filterable fields.
IndexConfig :: fn with_sortable_fields(mut self, fields : Vec <impl Into <String>>) -> SelfSets sortable fields.
pub trait SearchEngineSearch engine trait.
pub struct InMemorySearchEngineIn-memory search engine for testing.
InMemorySearchEngine :: fn new() -> SelfCreates a new in-memory search engine.
InMemorySearchEngine :: async fn create_index(& self, config : IndexConfig) -> Result <()>
InMemorySearchEngine :: async fn delete_index(& self, name : & str) -> Result <()>
InMemorySearchEngine :: async fn index_exists(& self, name : & str) -> Result <bool>
InMemorySearchEngine :: async fn index_document(& self, doc : SearchDocument) -> Result <()>
InMemorySearchEngine :: async fn index_documents(& self, docs : Vec <SearchDocument>) -> Result <()>
InMemorySearchEngine :: async fn delete_document(& self, index : & str, id : & str) -> Result <()>
InMemorySearchEngine :: async fn search(& self, query : SearchQuery) -> Result <SearchResults>
InMemorySearchEngine :: async fn get_document(& self, index : & str, id : & str) -> Result <Option <SearchDocument>>
pub struct SuggestionSuggestion for autocomplete.
pub struct AutocompleteConfigAutocomplete configuration.
AutocompleteConfig :: fn default() -> Self

`postgres`

ItemWhat it is
pub struct PostgresSearchEnginePostgreSQL search engine
PostgresSearchEngine :: fn new(pool : PgPool) -> SelfCreate a new PostgreSQL search engine.
PostgresSearchEngine :: fn pool(& self) -> & PgPoolGet a reference to the connection pool.
PostgresSearchEngine :: async fn create_index(& self, _config : IndexConfig) -> crate::Result <()>
PostgresSearchEngine :: async fn delete_index(& self, _name : & str) -> crate::Result <()>
PostgresSearchEngine :: async fn index_exists(& self, _name : & str) -> crate::Result <bool>
PostgresSearchEngine :: async fn index_document(& self, _doc : SearchDocument) -> crate::Result <()>
PostgresSearchEngine :: async fn index_documents(& self, _docs : Vec <SearchDocument>) -> crate::Result <()>
PostgresSearchEngine :: async fn delete_document(& self, _index : & str, _id : & str) -> crate::Result <()>
PostgresSearchEngine :: async fn get_document(& self, _index : & str, _id : & str) -> crate::Result <Option <SearchDocument>>
PostgresSearchEngine :: async fn search(& self, query : SearchQuery) -> crate::Result <SearchResults>
fn filter_to_sql(filter : & crate::SearchFilter, param_offset : usize) ->(String, Vec <String>)Build a SQL WHERE condition from a single SearchFilter
fn text_search_sql(query : & str, fields : & & str, param_offset : usize) ->(String, String)Build a SQL text search condition for ILIKE across multiple fields
fn sort_to_sql(query : & SearchQuery, allowed_fields : & & str) -> StringBuild an ORDER BY clause from SearchQuery sort fields
fn build_facet(field : & str, values : Vec <(String, u64)>) -> FacetResultBuild a FacetResult from a list of (value, count) pairs.
fn build_hit(id : & str, fields : Vec <(& str, serde_json::Value)>) -> SearchHitBuild a SearchHit from an ID and key-value pairs.

No pub use re-exports: every item above is declared in this crate.

Boundary

Reaches into foundation.

Shares tier infrastructure with 82 other crates: infrastructure-acquire, infrastructure-adapters-google-calendar, infrastructure-adapters-google-gmail, infrastructure-adapters-google-places, infrastructure-adapters-google-trends, infrastructure-adapters-shodan, infrastructure-adapters-yelp, infrastructure-agent, … (82 total).

_What this crate deliberately does NOT own is a judgment. No committed registry records one for it, so none is stated here._

Where it sits

Tier (ontology)infrastructure
Architectural role (taxonomy)unclassified (baselined)
Locationcrates/infrastructure/search
Vocabulary in force (lexicon)current

Tier flow. Which tiers this crate's own edges cross.

flowchart LR
  n_infrastructure["infrastructure"] --> n_foundation["foundation"]

Dependencies

Runtime, in this workspace.

CrateTierOptionalOnly on
`foundation-basemodels`foundationnoalways

Runtime, from outside the workspace.

CrateRequirementFeaturesOptionalOnly on
async-trait^0.1noalways
chrono^0.4serdenoalways
meilisearch-sdk^0.27yesalways
serde^1derivenoalways
serde_json^1noalways
sqlx^0.8runtime-tokio, postgres, chrono, uuid, jsonnoalways
thiserror^2noalways
tokio^1fullnoalways
uuid^1v4, v7, serde, jsnoalways

Development, from outside the workspace.

CrateRequirementFeaturesOptionalOnly on
tokio-test^0.4noalways

Build. None.

Depended on by. 2 workspace crates.

Signal flow — what reaches this crate, and what it reaches.

flowchart LR
  n_application_search["application-search"] -->|uses| SELF
  n_platform_privacy_scan_api["platform-privacy-scan-api"] -->|uses| SELF
  SELF["infrastructure-search"]
  SELF -->|runtime| n_foundation_basemodels["foundation-basemodels"]
  classDef self fill:#1f883d,stroke:#1f883d,color:#fff;
  class SELF self;

Feature flags

FeatureEnablesOn by default
defaultyes
meilisearchmeilisearch-sdkno
meilisearch-sdkdep:meilisearch-sdkno
flowchart LR
  n_default["default"]
  n_meilisearch["meilisearch"] --> n_meilisearch_sdk["meilisearch-sdk"]
  n_meilisearch_sdk["meilisearch-sdk"] --> n_dep_meilisearch_sdk["dep:meilisearch-sdk"]

Targets

KindNameSource
libinfrastructure_search`src/lib.rs`

Error model

Error typeNamed by
SearchErrorResult

Operational characteristics

PropertyEvidence
async public surfaceyes
async runtimeyes
database accessyes
network I/Onone detected
unsafe codenone detected
environment variablesnone detected

No unsafe block, unsafe fn, unsafe impl or unsafe trait was found by the parser anywhere in this crate's source.

Configuration

No environment variable is read with a literal name anywhere in this crate. A variable whose key is computed at run time cannot be listed here, and is not claimed to be absent.

2 workspace crates depend on this one: application-search, platform-privacy-scan-api.

Verification

KindCount
Unit tests30
Integration tests0
Examples0
Doctests0

Evidence by module. How often each public module is named by something executable.

ModuleTestsExamplesConsumers
crate root1802
postgres600

What the tests establish, by name:

Documentation coverage

MeasureDocumentedTotal
Public items with rustdoc5573
Public modules with a //! block11
pie showData
    title Public items with rustdoc
    "Documented" : 55
    "No rustdoc detected" : 18

Metrics

MetricValue
Rust source files2
Source lines1224
Code lines907
Public API items73
Public modules1
Tests30
Examples0
Cargo features3
Direct runtime dependencies10
Workspace reverse dependencies2
pie showData
    title Public API by kind
    "enum" : 4
    "function" : 5
    "method" : 49
    "struct" : 13
    "trait" : 1
    "type alias" : 1
pie showData
    title Rust source composition
    "Code" : 907
    "Blank or comment" : 317

Generation

Rendered by tools-corpus corpus readme from repository evidence alone, renderer schema 2, lexicon current. No model, network service or database was consulted. Regenerate with tools-corpus corpus readme --write; verify with --check.

All infrastructure · Manual