Full-Text + JSON Search¶
Uni supports full-text search over string properties and JSON documents, plus JSON path predicates for nested fields.
What It Provides¶
- Full-text indexes for string properties.
- JSON full-text search with path targeting.
CONTAINSpredicates on JSON documents.CALL uni.fts.query(...)for BM25-scored search with relevance ranking.
Example¶
use uni_db::Uni;
# async fn demo() -> Result<(), uni_db::UniError> {
let db = Uni::open("./my_db").build().await?;
db.execute("CREATE FULLTEXT INDEX doc_fts FOR (d:Doc) ON (d.title, d.body)")
.await?;
let rows = db.query(
"MATCH (d:Doc) WHERE d.body CONTAINS 'vector' RETURN d.title"
).await?;
println!("{:?}", rows);
# Ok(())
# }
FTS Query Procedure¶
For BM25-scored search with normalized relevance scores:
-- Create a fulltext index
CREATE FULLTEXT INDEX article_content FOR (a:Article) ON (a.content)
-- Query with relevance scoring
CALL uni.fts.query('Article', 'content', 'database optimization', 20)
YIELD node, score
RETURN node.title, score
ORDER BY score DESC
Parameters:
label- Node label to searchproperty- Text property with inverted indexsearch_term- Search query stringk- Number of resultsthreshold(optional) - Minimum score (0-1)
Yields:
vid- Vertex IDscore- Normalized BM25 score (0-1)node- Full node with properties
Use Cases¶
- Search across documents, notes, or product descriptions.
- JSON documents with nested fields.
- Hybrid filters that combine text search with graph structure.
When To Use¶
Use full-text or JSON search when keyword matching and relevance ranking matter more than exact equality on fields.
See also: Vector Search | Hybrid Search