Graph Phrase Search
Phrase Search is when the graph is queried using the phrase
argument. This argument uses a pre-calculated search index to find entities.
The index can be configured to contain related graphs, so that when you search for orders, but get a hit on an order’s delivery, the system will still return the order.
The GraphQL interface has a special phraseMatches
field that can be used in conjunction with phrase search to outline exactly where in the result graph the hits are.
Configuring and Managing Search Indexes
Before a phrase search can be successfully performed, the search index must be prepared. Hantera normally comes with a basic standard configuration, which can be adjusted for your needs.
To configure a search index for a given graph node, use the /system/graph/<node>/search
registry key.
Once the search index is configured and applied, you need to trigger an index update. This can be done using hantera-cli.
For example, to update the order search index:
The --rebuild
flag can be used to completely rebuild an index. This is only needed if you have removed fields from the index and wish to exclude them from the existing index.
If you want to see the status of an ongoing update, or just check the status of the search indexes in general, you can check Hantera’s signals:
Performing Phrase Search
When using the GraphQL API to query, you may use the phrase
argument to add phrase search filtering to the result.
Phrase filter is applied in combination with any filter
you might apply as well. orderBy
is not affected by phrase search.
When using phrase search, it’s important to remember that only fields that are selected in the query are taken into account. For example, given that order
has field orderNumber
and customerNumber
indexed, only orderNumber
will be searched given the below query:
This behavior can be overridden by setting the phraseFields
field to *
in the query. With the below change, both orderNumber
and customerNumber
will be matched.
Nested Search
If a node search index is configured to contain edges, it’s possible to make a search on one set that matches a navigation. To expand on our previous example, let’s say that order
search index has edge delivery
configured, and delivery
has field deliveryAddress.name
indexed, the following query will search both orderNumber
and deliveries.deliveryAddress.name
and only return orders where either match:
Phrase Matching Logic
Each separate word in a search must match a graph for it to be returned, for example, the words are AND
ed. Any word less than 3 characters are ignored.
Wildcard Matching
Wildcards (*
) can be used to match parts of words:
*phrase
- Matches any word that ends with “phrase”phrase*
- Matches any word that begins with “phrase”pra*se
- Matches any word that starts with “pra”, as “se” is ignoredhan*tera
- Matches any word that starts with “han” and ends with “tera”
Exact Matching
Single or multiple words can be quoted (single or double quotes) to search for exact phrases:
"phrase"
- Matches words that are exactly “phrase”"John Doe"
- Matches exactly “John Doe” appearing in exactly that order
Actor Extensions and Custom Nodes
When it comes to the dynamic nature of Actor Extensions, the generated nodes can not be configured separately in terms of search indexing. Instead, search indexing is always configured on the base node. When performing a phrase search, the base node’s index will be used whenever a Typed Node is searched. Of course, only Nodes that matches the current type will ever match.