# Neo4jVector

> **Class** in `langchain_neo4j`

📖 [View in docs](https://reference.langchain.com/python/langchain-neo4j/vectorstores/neo4j_vector/Neo4jVector)

Neo4j vector index.

To use, you should have the `neo4j` python package installed.

## Signature

```python
Neo4jVector(
    self,
    embedding: Embeddings,
    *,
    search_type: SearchType = SearchType.VECTOR,
    username: Optional[str] = None,
    password: Optional[str] = None,
    url: Optional[str] = None,
    keyword_index_name: Optional[str] = 'keyword',
    database: Optional[str] = None,
    index_name: str = 'vector',
    node_label: str = 'Chunk',
    embedding_node_property: str = 'embedding',
    text_node_property: str = 'text',
    distance_strategy: DistanceStrategy = DEFAULT_DISTANCE_STRATEGY,
    logger: Optional[logging.Logger] = None,
    pre_delete_collection: bool = False,
    retrieval_query: str = '',
    relevance_score_fn: Optional[Callable[[float], float]] = None,
    index_type: IndexType = DEFAULT_INDEX_TYPE,
    graph: Optional[Neo4jGraph] = None,
    embedding_dimension: Optional[int] = None,
    user_agent: str = 'LangChain-Vector',
)
```

## Description

**Example:**

```python
from langchain_neo4j import Neo4jVector
from langchain_openai import OpenAIEmbeddings

url="bolt://localhost:7687"
username="neo4j"
password="password"
embeddings = OpenAIEmbeddings()
vector_store = Neo4jVector.from_documents(
    embedding=embeddings,
    documents=docs,
    url=url,
    username=username,
    password=password,
)
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `url` | `Optional[str]` | No | Neo4j connection url (default: `None`) |
| `username` | `Optional[str]` | No | Neo4j username. (default: `None`) |
| `password` | `Optional[str]` | No | Neo4j password (default: `None`) |
| `database` | `Optional[str]` | No | Optionally provide Neo4j database Defaults to `'neo4j'` (default: `None`) |
| `embedding` | `Embeddings` | Yes | Any embedding function implementing `langchain.embeddings.base.Embeddings` interface. |
| `distance_strategy` | `DistanceStrategy` | No | The distance strategy to use. (default: `COSINE`) (default: `DEFAULT_DISTANCE_STRATEGY`) |
| `search_type` | `SearchType` | No | The type of search to be performed, either `'vector'` or `'hybrid'` (default: `SearchType.VECTOR`) |
| `node_label` | `str` | No | The label used for nodes in the Neo4j database. (default: `'Chunk'`) |
| `embedding_node_property` | `str` | No | The property name in Neo4j to store embeddings. (default: `'embedding'`) |
| `text_node_property` | `str` | No | The property name in Neo4j to store the text. (default: `'text'`) |
| `retrieval_query` | `str` | No | The Cypher query to be used for customizing retrieval. If empty, a default query will be used. (default: `''`) |
| `index_type` | `IndexType` | No | The type of index to be used, either `'NODE'` or `'RELATIONSHIP'` (default: `DEFAULT_INDEX_TYPE`) |
| `pre_delete_collection` | `bool` | No | If `True`, will delete existing data if it exists. Useful for testing. (default: `False`) |
| `embedding_dimension` | `Optional[int]` | No | The dimension of the embeddings. If not provided, will query the embedding model to calculate the dimension. (default: `None`) |

## Extends

- `VectorStore`

## Constructors

```python
__init__(
    self,
    embedding: Embeddings,
    *,
    search_type: SearchType = SearchType.VECTOR,
    username: Optional[str] = None,
    password: Optional[str] = None,
    url: Optional[str] = None,
    keyword_index_name: Optional[str] = 'keyword',
    database: Optional[str] = None,
    index_name: str = 'vector',
    node_label: str = 'Chunk',
    embedding_node_property: str = 'embedding',
    text_node_property: str = 'text',
    distance_strategy: DistanceStrategy = DEFAULT_DISTANCE_STRATEGY,
    logger: Optional[logging.Logger] = None,
    pre_delete_collection: bool = False,
    retrieval_query: str = '',
    relevance_score_fn: Optional[Callable[[float], float]] = None,
    index_type: IndexType = DEFAULT_INDEX_TYPE,
    graph: Optional[Neo4jGraph] = None,
    embedding_dimension: Optional[int] = None,
    user_agent: str = 'LangChain-Vector',
) -> None
```

| Name | Type |
|------|------|
| `embedding` | `Embeddings` |
| `search_type` | `SearchType` |
| `username` | `Optional[str]` |
| `password` | `Optional[str]` |
| `url` | `Optional[str]` |
| `keyword_index_name` | `Optional[str]` |
| `database` | `Optional[str]` |
| `index_name` | `str` |
| `node_label` | `str` |
| `embedding_node_property` | `str` |
| `text_node_property` | `str` |
| `distance_strategy` | `DistanceStrategy` |
| `logger` | `Optional[logging.Logger]` |
| `pre_delete_collection` | `bool` |
| `retrieval_query` | `str` |
| `relevance_score_fn` | `Optional[Callable[[float], float]]` |
| `index_type` | `IndexType` |
| `graph` | `Optional[Neo4jGraph]` |
| `embedding_dimension` | `Optional[int]` |
| `user_agent` | `str` |


## Properties

- `schema`
- `embedding`
- `index_name`
- `keyword_index_name`
- `node_label`
- `embedding_node_property`
- `text_node_property`
- `logger`
- `override_relevance_score_fn`
- `retrieval_query`
- `search_type`
- `embedding_dimension`
- `embeddings`

## Methods

- [`query()`](https://reference.langchain.com/python/langchain-neo4j/vectorstores/neo4j_vector/Neo4jVector/query)
- [`verify_version()`](https://reference.langchain.com/python/langchain-neo4j/vectorstores/neo4j_vector/Neo4jVector/verify_version)
- [`retrieve_existing_index()`](https://reference.langchain.com/python/langchain-neo4j/vectorstores/neo4j_vector/Neo4jVector/retrieve_existing_index)
- [`retrieve_existing_fts_index()`](https://reference.langchain.com/python/langchain-neo4j/vectorstores/neo4j_vector/Neo4jVector/retrieve_existing_fts_index)
- [`create_new_index()`](https://reference.langchain.com/python/langchain-neo4j/vectorstores/neo4j_vector/Neo4jVector/create_new_index)
- [`create_new_keyword_index()`](https://reference.langchain.com/python/langchain-neo4j/vectorstores/neo4j_vector/Neo4jVector/create_new_keyword_index)
- [`add_embeddings()`](https://reference.langchain.com/python/langchain-neo4j/vectorstores/neo4j_vector/Neo4jVector/add_embeddings)
- [`add_texts()`](https://reference.langchain.com/python/langchain-neo4j/vectorstores/neo4j_vector/Neo4jVector/add_texts)
- [`similarity_search()`](https://reference.langchain.com/python/langchain-neo4j/vectorstores/neo4j_vector/Neo4jVector/similarity_search)
- [`similarity_search_with_score()`](https://reference.langchain.com/python/langchain-neo4j/vectorstores/neo4j_vector/Neo4jVector/similarity_search_with_score)
- [`similarity_search_with_score_by_vector()`](https://reference.langchain.com/python/langchain-neo4j/vectorstores/neo4j_vector/Neo4jVector/similarity_search_with_score_by_vector)
- [`similarity_search_by_vector()`](https://reference.langchain.com/python/langchain-neo4j/vectorstores/neo4j_vector/Neo4jVector/similarity_search_by_vector)
- [`from_texts()`](https://reference.langchain.com/python/langchain-neo4j/vectorstores/neo4j_vector/Neo4jVector/from_texts)
- [`from_embeddings()`](https://reference.langchain.com/python/langchain-neo4j/vectorstores/neo4j_vector/Neo4jVector/from_embeddings)
- [`from_existing_index()`](https://reference.langchain.com/python/langchain-neo4j/vectorstores/neo4j_vector/Neo4jVector/from_existing_index)
- [`from_existing_relationship_index()`](https://reference.langchain.com/python/langchain-neo4j/vectorstores/neo4j_vector/Neo4jVector/from_existing_relationship_index)
- [`from_documents()`](https://reference.langchain.com/python/langchain-neo4j/vectorstores/neo4j_vector/Neo4jVector/from_documents)
- [`from_existing_graph()`](https://reference.langchain.com/python/langchain-neo4j/vectorstores/neo4j_vector/Neo4jVector/from_existing_graph)
- [`max_marginal_relevance_search()`](https://reference.langchain.com/python/langchain-neo4j/vectorstores/neo4j_vector/Neo4jVector/max_marginal_relevance_search)

---

[View source on GitHub](https://github.com/langchain-ai/langchain-neo4j/blob/9bfd947b3ce63ca58fe27c059f9db6c3cc90cf78/libs/neo4j/langchain_neo4j/vectorstores/neo4j_vector.py#L114)