You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/source/semantic_indexes.rst
+49-17Lines changed: 49 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,20 +1,20 @@
1
-
.. _Semantic Indexes:
1
+
.. _Semantic Indexes:
2
2
3
3
==================================
4
4
Semantic Indexes
5
5
==================================
6
6
7
7
Full Text Index
8
8
----------------
9
-
From version x.x (version number tbc) neomodel provides a way to interact with neo4j `Full Text indexing <https://neo4j.com/docs/cypher-manual/current/indexes/semantic-indexes/full-text-indexes/>`_.
10
-
The Full Text Index can be be created for both node and relationship properties. Only available for Neo4j version 5.16 or higher.
9
+
From version 6.0.0 neomodel provides a way to interact with neo4j `Full Text indexing <https://neo4j.com/docs/cypher-manual/current/indexes/semantic-indexes/full-text-indexes/>`_.
10
+
The Full Text Index can be created for both node and relationship properties. Only available for Neo4j version 5.16 or higher.
11
11
12
12
Defining a Full Text Index on a Property
13
13
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
14
14
Within neomodel, indexing is a decision that is made at class definition time as the index needs to be built. A Full Text index is defined using :class:`~neomodel.properties.FulltextIndex`
15
-
To define a property with a full text index we use the following symantics::
15
+
To define a property with a full text index we use the following syntax::
- ``analyzer``: The analyzer to use. The default is ``standard-no-stop-words``.
@@ -27,34 +27,67 @@ Please refer to the `Neo4j documentation <https://neo4j.com/docs/cypher-manual/c
27
27
Querying a Full Text Index on a Property
28
28
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
29
29
30
-
This is not currently implemented as a native neomodel query type. If you would like this please submit a github issue highlighting your useage pattern
Can be queried using :class:`~neomodel.semantic_filters.FulltextFilter`. Such as::
43
+
44
+
from neomodel.semantic_filters import FulltextFilter
45
+
result = Product.nodes.filter(
46
+
fulltext_filter=FulltextFilter(
47
+
topk=10,
48
+
fulltext_attribute_name="description",
49
+
query_string="product")).all()
50
+
51
+
Where the result will be a list of length topk of nodes with the form (ProductNode, score).
52
+
53
+
The :class:`~neomodel.semantic_filters.FulltextFilter` can be used in conjunction with the normal filter types.
54
+
55
+
.. attention::
56
+
If you use FulltextFilter in conjunction with normal filter types, only nodes that fit the filters will return thus, you may get less than the topk specified.
57
+
Furthermore, all node filters **should** work with FulltextFilter, relationship filters will also work but WILL NOT return the fulltext similarity score alongside the relationship filter, instead the topk nodes and their appropriate relationships will be returned.
58
+
59
+
RelationshipProperty
60
+
^^^^^^^^^^^^^^^^^^^^
31
61
32
-
Alternatively, whilst this has not bbeen implemetned yet you can still leverage `db.cypher_query` with the correct syntax to perform your required query.
62
+
Currently neomodel has not implemented an OGM method for querying full text indexes on relationships.
63
+
If this is something that you would like, please submit a GitHub issue with requirements highlighting your usage pattern.
64
+
65
+
Alternatively, whilst this has not been implemented yet you can still leverage `db.cypher_query` with the correct syntax to perform your required query.
33
66
34
67
Vector Index
35
68
------------
36
-
From version x.x (version number tbc) neomodel provides a way to interact with neo4j `vector indexing <https://neo4j.com/docs/cypher-manual/current/indexes/semantic-indexes/vector-indexes/>`_.
69
+
From version 5.5.0 neomodel provides a way to interact with neo4j `vector indexing <https://neo4j.com/docs/cypher-manual/current/indexes/semantic-indexes/vector-indexes/>`_.
37
70
38
71
The Vector Index can be created on both node and relationship properties. Only available for Neo4j version 5.15 (node) and 5.18 (relationship) or higher.
39
72
40
73
Defining a Vector Index on a Property
41
74
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
42
75
43
76
Within neomodel, indexing is a decision that is made at class definition time as the index needs to be built. A vector index is defined using :class:`~neomodel.properties.VectorIndex`.
44
-
To define a property with a vector index we use the following symantics::
77
+
To define a property with a vector index we use the following syntax::
Can be queried using :class:`~neomodel.sematic_filters.VectorFilter`. Such as::
103
+
Can be queried using :class:`~neomodel.semantic_filters.VectorFilter`. Such as::
71
104
72
105
from neomodel.semantic_filters import VectorFilter
73
106
result = someNode.nodes.filter(vector_filter=VectorFilter(topk=3, vector_attribute_name="vector")).all()
@@ -78,12 +111,11 @@ The :class:`~neomodel.semantic_filters.VectorFilter` can be used in conjunction
78
111
79
112
.. attention::
80
113
If you use VectorFilter in conjunction with normal filter types, only nodes that fit the filters will return thus, you may get less than the topk specified.
81
-
Furthermore, all node filters **should** work with VectorFilter, relationship filters will also work but WILL NOT return the vector similiarty score alongside the relationship filter, instead the topk nodes and their appropriate relationships will be returned.
114
+
Furthermore, all node filters **should** work with VectorFilter, relationship filters will also work but WILL NOT return the vector similarity score alongside the relationship filter, instead the topk nodes and their appropriate relationships will be returned.
82
115
83
116
RelationshipProperty
84
117
^^^^^^^^^^^^^^^^^^^^
85
118
Currently neomodel has not implemented an OGM method for querying vector indexes on relationships.
86
-
If this is something that you like please submit a github issue requirements highlighting your usage pattern.
119
+
If this is something that you would like, please submit a GitHub issue with requirements highlighting your usage pattern.
87
120
88
121
Alternatively, whilst this has not been implemented yet you can still leverage `db.cypher_query` with the correct syntax to perform your required query.
0 commit comments