A full-text index is a type of index specialized for efficient searching for string or text properties, especially in large text fields like descriptions, comments, or articles.
Full-text indexes work by breaking down the text into smaller segments called tokens. When a query is performed, the search engine matches specified keywords against these tokens instead of the original full text, allowing for faster retrieval of relevant results. Full-text indexes support both precise and fuzzy matches.
To retrieve information about full-text indexes in the current graphset:
UQL// Shows all full-text indexes show().fulltext() // Show all node full-text indexes show().node_fulltext() // Show all edge full-text indexes show().edge_fulltext()
The information about full-text indexes is organized into the _nodeFulltext or _edgeFulltext table. Each table provides essential details about each full-text index:
Field | Description |
|---|---|
name | Full-text index name. |
properties | The property of the full-text index. |
schema | The schema of the full-text index. |
status | Full-text index status, which can be DONE or CREATING. |
You can create a node or edge full-text index using the create().node_fulltext() or create().edge_fulltext() statement. Note that each property can only have one full-text index. The full-text index creation runs as a job, you may run show().job(<id?>) afterward to verify the success of the creation.
System properties in Ultipa are inherently optimized for query performance and include built-in efficiencies. They do not support full-text indexing.
Syntax// Creates a node full-text index create().node_fulltext(@<schema>.<property>, "<fulltextName>") // Creates an edge full-text index create().edge_fulltext(@<schema>.<property>, "<fulltextName>")
| Method | Param | Description |
|---|---|---|
node_fulltext() or edge_fulltext() | @<schema>.<property> | Specifies the string or text property and its schema. |
<fulltextName> | The name of the full-text index. Naming conventions are:
|
To create a full-text index named prodDesc for the property description of product nodes:
UQLcreate().node_fulltext(@product.description, "prodDesc")
To create a full-text index named review for the property content of review edges:
UQLcreate().edge_fulltext(@review.content, "review")
You can drop a node or edge full-text index using the drop().node_fulltext() or drop().edge_fulltext() statement. Dropping a full-text index does not affect the actual property values stored in shards.
NOTEA property with a full-text index cannot be dropped until the full-text index is deleted.
To drop the node full-text index prodDesc:
UQLdrop().node_fulltext("prodDesc")
To drop the edge full-text index review:
UQLdrop().edge_fulltext("review")
To use a full-text index in filters, use the syntax {~<fulltextName> contains "<keyword1> <keyword2> ..."}:
~ symbol marks the full-text index.contains checks if the segmented tokens in the full-text index include all the specified keywords.\) to escape.There are two search modes for full-text indexes:
*), matching tokens that begin with the keyword.To find nodes using the full-text index prodDesc where their tokens include "graph" and "database":
UQLfind().nodes({~prodDesc contains "graph database"}) as n return n
To find nodes using the full-text index prodDesc where their tokens include "graph" or "database":
UQLfind().nodes({~prodDesc contains "graph" || ~prodDesc contains "database"}) as n return n
To find edges using the full-text index review where their tokens include "graph" and those start with "ult":
UQLfind().edges({~review contains "graph ult*"}) as e return e
Using the ab() query to find paths within 5 steps, with the full-text index companyName applied to both the source and destination nodes:
UQLab().src({~companyName contains "Sequoia*"}).dest({~companyName contains "Hillhouse*"}).depth(:5) as p return p
Note: Full-text indexes only apply to the first node in a Path Template or a K-Hop Template when retrieving paths.
For example, this query is not supported:
UQL - Not supportedn().e().n({~prodDesc contains "graph"}) as p return p
You may revise the query as follows:
UQLfind().nodes({~prodDesc contains "graph"}) as dest n().e().n({_id == dest._id}) as p return p
This query is not supported either:
UQL - Not supportedn().e({~review contains "ult*"}).n() as p return p
You may revise the query as follows:
UQLfind().edges({~review contains "ult*"}) as e n().e({_uuid == e._uuid}).n() as p return p