> ## Documentation Index
> Fetch the complete documentation index at: https://doc.lucidworks.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Image search

> Search images by example image with the Lucidworks AI siglip2-so400m-patch14-384 model.

Image search lets users find images by supplying an example image.
It uses the Lucidworks AI [siglip2-so400m-patch14-384](https://doc.lucidworks.com/docs/lw-platform/lw-ai/lw-ai-pre-trained-embedding-models.md#siglip2-so400m-patch14-384) model, which encodes images into vectors.
Image search works alongside [Neural Hybrid Search](https://doc.lucidworks.com/docs/lucidworks-search/11-vector-search/overview.md), which handles text search.

Image search suits catalogs and content where images are visually distinctive, such as fashion, home goods, marketplaces, and image libraries.
It also supports visually similar recommendations, and identifying parts from a photo when the part number isn't known.

## Before you begin

* Set up [Neural Hybrid Search](https://doc.lucidworks.com/docs/lucidworks-search/11-vector-search/overview.md).
* Use Lucidworks Search 5.9.14 or later.
* Set up the [Lucidworks AI Gateway](https://doc.lucidworks.com/docs/lw-platform/lw-ai/lw-ai-gateway.md) integration.
* Make sure each document has a publicly reachable image URL or the image as base64-encoded data.

## Set up image search

**1. Add a vector field type for 1152 dimensions**

The model returns 1152-dimensional vectors, a size the default schema doesn't include.
Go to **System > Solr Config**, open **managed-schema**, and add this field type and dynamic field:

```xml wrap theme={"dark"}
<fieldType class="solr.DenseVectorField" hnswBeamWidth="200" hnswMaxConnections="45" knnAlgorithm="hnsw" similarityFunction="cosine" name="knn_1152_vector" vectorDimension="1152"/>
<dynamicField docValues="false" stored="true" indexed="true" multiValued="false" name="*_1152v" type="knn_1152_vector"/>
```

**2. Vectorize images when indexing**

In the index pipeline, add an **LWAI Vectorize Field** or **LWAI Batch Vectorize** stage.
Configure the stage with the following settings:

* **Model**: `siglip2-so400m-patch14-384`.
* **Source**: the field that holds each document's image URL, such as `image_url_s`.
* **Destination**: a field that ends in `_1152v`, such as `image_1152v`.
* **Model Configuration**: a parameter named `imageData` with the value `URL`.
  If the source field holds base64-encoded images instead of URLs, use the value `base64`.

Lucidworks AI fetches each image itself, so image URLs must be publicly reachable.

**3. Vectorize query images**

In the query pipeline, add an **LWAI Vectorize Query** stage.
Configure the stage with the following settings:

* **Model**: `siglip2-so400m-patch14-384`.
* **Query Input**: `<request.params.q>`.
* **Output Context Variable**: `vector`.
* **Model Configuration**: a parameter named `imageData` with the value `URL` if queries send image URLs, or `base64` if they send base64-encoded images.

Base64-encoded images are large, so send them as form-encoded parameters in the body of a POST request, not in the URL.

**4. Search the image vectors**

After the **LWAI Vectorize Query** stage and before the **Solr Query** stage, add an **Additional Query Parameters** stage.
Add the following parameters, each with the policy `replace`:

| Parameter | Value |
| - | - |
| `q` | `{!knn f=image_1152v topK=48}<ctx.vector>` |
| `defType` | `lucene` |

Replace `image_1152v` with the destination field from the index stage, and set `topK` to the number of nearest images to return.

Set the stage's **Condition** so it runs only when the query contains an image:

```js wrap theme={"dark"}
request.hasParam("q") && request.getFirstParam("q").trim() != "" && request.getFirstParam("q") != "*" && request.getFirstParam("q") != "*:*"
```

## Limitations

* Products that look alike, or that share the same stock image, can't be told apart by their images.

For details about the model's behavior, see [Image model](https://doc.lucidworks.com/docs/lw-platform/lw-ai/lw-ai-apis/lw-ai-prediction-api/embedding-prediction.md#image-model).

## Learn more

* [LWAI Vectorize Field index stage](https://doc.lucidworks.com/docs/lucidworks-search/09-developer-documentation/config-specs/index-pipeline-stages/vectorize-field-via-lucidworks-ai-index-stage.md)
* [LWAI Batch Vectorize index stage](https://doc.lucidworks.com/docs/lucidworks-search/09-developer-documentation/config-specs/index-pipeline-stages/lwai-batch-vectorize.md)
* [LWAI Vectorize Query stage](https://doc.lucidworks.com/docs/lucidworks-search/09-developer-documentation/config-specs/query-pipeline-stages/vectorize-query-via-lucidworks-ai-query-stage.md)
* [Additional Query Parameters stage](https://doc.lucidworks.com/docs/lucidworks-search/09-developer-documentation/config-specs/query-pipeline-stages/additional-query-parameters.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.