Syntax
The syntax of an inverted query is similar to the query syntax of Elasticsearch.
You must write an inverted query in the JSON format. However, the braces ({}) in JSON conflict with the syntax of the iGraph engine. Therefore, you must escape the braces ({}) in the format of \{ \}.
Inverted queries support the following query methods: single term, and, or, and andnot.
Single term
"match": the node that is used to retrieve documents based on an index field.
"name": the name of the index field to be queried.
⚠️ Even if the index field is of a numeric type, the term must be enclosed in double quotation marks ("). Otherwise, the query fails.
⚠️ You must add the index configuration for the index field on the table configuration page. Otherwise, the query fails.
\{"match": \{ "name" : "Andy Lau"\} \}and
An "and" node must contain at least two child nodes.
A child node of an "and" node can be a "match" node, an "and" node, or an "or" node.
\{ "and" : [ \{ "match" : \{ "name" : "Andy Lau"\} \}, \{ "match" : \{ "id" : "102" \} \}, \{ "or" : \{ ...... \} \} ]\}or
An "or" node must contain at least two child nodes.
A child node of an "or" node can be a "match" node, an "and" node, or an "or" node.
\{ "or" : [ \{ "match" : \{ "name" : "Andy Lau"\} \}, \{ "match" : \{ "id" : "102" \} \}, \{ "and" : \{ ...... \} \} ]\}andnot
An "andnot" node must contain at least two child nodes.
T1 ADNNOT T2 ANDNOT ... ANDNOT Tnis equivalent toT1 ANDNOT (T2 OR T3 ... OR Tn).
\{ "andnot" : [ "match" : \{ "name" : "Andy Lau"\}, "match" : \{ ... \} ]\}Example
Gremlin syntax
Inverted queries must be submitted in indexQuery() steps.
If you use an indexQuery() step to modulate a V() step, you can leave the input parameters of the V() step empty.
Inverted queries cannot be performed on Key-Value (KV) or PKey-SKey-Value (KKV) tables.
g("graph_test").V().hasLabel("thinkerpop_modern_software_index").indexQuery("{\"match\":{\"lang\":\"java\"}}")==> {"label":"thinkerpop_modern_software_index","lang":"java","name":"ripple","pk":"5"}Usage notes
The real-time update frequency of an inverted table cannot exceed 5,000 queries per second (QPS). Otherwise, the query performance is severely affected.
By default, if the length of a single column in the returned results of an inverted query exceeds 3,000 bytes, the results are truncated and not all results can be sought. If excessive results are returned, the inverted index is modified during the query and the candidate set is affected.
Q: How do I combine the "or: and "match" nodes to query the f1 field that contains a or c if the field is f1 = "a,b,c,d"?
A: When you configure an index field for the f1 field, you need to configure a tokenizer. Then, the inverted index is created based on a, b, c, and d separately. For more information about tokenizers, see the topics related to index configuration. Then, you can combine the "match", "or", and "and" nodes to query the field.