0Pricing
Neo4j Graph Database Fundamentals · درس

البحث بالنص الكامل والمتجهات في Neo4j

تجاوز عمليات البحث عن التطابق التام بإضافة فهارس النص الكامل والمتجهات إلى Neo4j، لتمكين البحث النصي التقريبي واستعلامات التشابه الدلالي التي توسّع قاعدة البيانات لتناسب أعباء البحث والذكاء الاصطناعي الحديثة.

البحث بالنص الكامل والمتجهات في Neo4j درس مجاني في Neo4j Graph Database Fundamentals على CoddyKit. هذا هو الدرس 4 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في Neo4j Graph Database Fundamentals، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة Neo4j Graph Database Fundamentals 4 دروس في المجموع.

بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.

Why Search Indexes Matter

Plain property lookups in Neo4j are great for exact matches, but real applications need more. Users misspell words, search across multiple fields, and increasingly expect semantic results.

Neo4j extends its capabilities with two specialized index types:

  • Full-text indexes for fuzzy, multi-field text search
  • Vector indexes for similarity search over embeddings

Both are first-class features you can manage with Cypher.

Creating a Full-Text Index

A full-text index is built over one or more node labels and properties. Once created, it powers tokenized, case-insensitive search.

The example creates an index named movieSearch over the title and plot properties of Movie nodes.

CREATE FULLTEXT INDEX movieSearch
FOR (m:Movie)
ON EACH [m.title, m.plot];

Querying a Full-Text Index

You query full-text indexes with the db.index.fulltext.queryNodes procedure. It returns matching nodes plus a relevance score.

This Lucene-style syntax supports wildcards, fuzzy matching with ~, and boolean operators.

CALL db.index.fulltext.queryNodes('movieSearch', 'matrix~')
YIELD node, score
RETURN node.title AS title, score
ORDER BY score DESC;

Fuzzy and Wildcard Matching

Full-text search shines with imperfect input. A few common operators:

  • star~ — fuzzy match, tolerates typos
  • star* — prefix wildcard
  • title:matrix — restrict to one field
  • matrix AND reloaded — boolean combination

These let one query handle the messy real-world queries users actually type.

CALL db.index.fulltext.queryNodes('movieSearch', 'title:matr*')
YIELD node, score
RETURN node.title, score;

What Are Vector Embeddings?

A vector embedding is a list of numbers that captures the meaning of text, an image, or other data. Items with similar meaning have vectors that point in similar directions.

By storing an embedding as a property on a node, Neo4j can answer questions like find the documents most semantically similar to this one — not just keyword matches.

Creating a Vector Index

Vector indexes require you to declare the dimension (length of the embedding) and the similarity function (cosine or euclidean).

The db.index.vector.createNodeIndex procedure creates one over a label and property. Here we index a 1536-dimension embedding stored on Document nodes.

CALL db.index.vector.createNodeIndex(
  'docEmbedding',
  'Document',
  'embedding',
  1536,
  'cosine'
);

Storing an Embedding on a Node

Embeddings are usually produced by an external model and written back to Neo4j. The db.create.setNodeVectorProperty procedure stores the float array efficiently.

In practice the array has hundreds or thousands of values; it is shortened here for readability.

MATCH (d:Document {id: 'doc-1'})
CALL db.create.setNodeVectorProperty(d, 'embedding', [0.12, -0.04, 0.88])
RETURN d.id;

Querying for Similar Nodes

To find the nearest neighbors, call db.index.vector.queryNodes with the index name, the number of results, and a query vector.

It returns nodes ordered by similarity along with a score between 0 and 1.

CALL db.index.vector.queryNodes('docEmbedding', 5, [0.10, -0.02, 0.90])
YIELD node, score
RETURN node.title AS title, score
ORDER BY score DESC;

Combining Search with the Graph

The real power of Neo4j is mixing search with traversal. You can find semantically similar documents, then follow relationships to enrich the results.

This query finds similar documents and returns their authors — something a pure vector database cannot do in one step.

CALL db.index.vector.queryNodes('docEmbedding', 3, [0.1, -0.02, 0.9])
YIELD node, score
MATCH (node)<-[:WROTE]-(a:Author)
RETURN node.title, a.name, score;

Managing Search Indexes

Like any index, full-text and vector indexes can be listed and dropped. Use SHOW INDEXES to inspect them and DROP INDEX to remove one.

Always check that an index is ONLINE before relying on it in production queries.

SHOW INDEXES
WHERE type IN ['FULLTEXT', 'VECTOR'];

// Remove one:
DROP INDEX docEmbedding IF EXISTS;

Best Practices

To get the most from search indexes:

  • Keep embedding dimensions consistent with your model output
  • Choose cosine similarity for most text embeddings
  • Re-embed and update vectors when source data changes
  • Limit result counts and post-filter with Cypher for relevance

These habits keep searches fast and accurate as data grows.

Quick Check

Test your understanding of Neo4j search indexes.

Recap

You extended Neo4j with two powerful search capabilities:

  • Full-text indexes — tokenized, fuzzy, multi-field keyword search via db.index.fulltext.queryNodes
  • Vector indexes — semantic similarity over embeddings via db.index.vector.queryNodes

Best of all, both integrate with graph traversals, letting you blend search relevance with relationship context in a single Cypher query.

الأسئلة الشائعة

هل درس «البحث بالنص الكامل والمتجهات في Neo4j» مجاني؟

نعم — نص درس «البحث بالنص الكامل والمتجهات في Neo4j» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Neo4j Graph Database Fundamentals، انتقل إلى CoddyKit PRO. تتضمن دورة Neo4j Graph Database Fundamentals 4 دروس في المجموع.

ماذا ستتعلم في «البحث بالنص الكامل والمتجهات في Neo4j»؟

تجاوز عمليات البحث عن التطابق التام بإضافة فهارس النص الكامل والمتجهات إلى Neo4j، لتمكين البحث النصي التقريبي واستعلامات التشابه الدلالي التي توسّع قاعدة البيانات لتناسب أعباء البحث والذكاء الاصطناعي… تتمرن على Neo4j Graph Database Fundamentals مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.

هل أحتاج إلى خبرة سابقة لأبدأ Neo4j Graph Database Fundamentals؟

لا تُشترط خبرة سابقة. Neo4j Graph Database Fundamentals على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 4 من أصل 4.

كم من الوقت يستغرق درس «البحث بالنص الكامل والمتجهات في Neo4j»؟

معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.

هل يمكنني كتابة وتشغيل أكواد في درس Neo4j Graph Database Fundamentals هذا؟

نعم. كل درس في Neo4j Graph Database Fundamentals يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.

جميع الدروس في هذه الدورة

  1. الإجراءات المخزنة وUDFs
  2. التكامل مع أدوات ذكاء الأعمال والتصور
  3. مسارات إدخال البيانات المتقدمة
  4. البحث بالنص الكامل والمتجهات في Neo4j
← العودة إلى Neo4j Graph Database Fundamentals