# DocstoreFn

> **Class** in `langchain_community`

📖 [View in docs](https://reference.langchain.com/python/langchain-community/docstore/arbitrary_fn/DocstoreFn)

Docstore via arbitrary lookup function.

## Signature

```python
DocstoreFn(
    self,
    lookup_fn: Callable[[str], Union[Document, str]],
)
```

## Description

**This is useful when:**

* it's expensive to construct an InMemoryDocstore/dict
* you retrieve documents from remote sources
* you just want to reuse existing objects

## Extends

- `Docstore`

## Constructors

```python
__init__(
    self,
    lookup_fn: Callable[[str], Union[Document, str]],
)
```

| Name | Type |
|------|------|
| `lookup_fn` | `Callable[[str], Union[Document, str]]` |


## Methods

- [`search()`](https://reference.langchain.com/python/langchain-community/docstore/arbitrary_fn/DocstoreFn/search)

---

[View source on GitHub](https://github.com/langchain-ai/langchain-community/blob/a6a6079511ac8a5c1293337f88096b8641562e77/libs/community/langchain_community/docstore/arbitrary_fn.py#L8)