> ## 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.

# Query Stage SDK

export const LwTemplate = ({title = "Key questions to get you started", icon = "sparkles", cta = "Powered by Agent Studio", linkHref = "https://lucidworks.com/demo/?utm_source=docs&utm_medium=referral&utm_campaign=docs_cta_ai"}) => {
  const [isLoaded, setIsLoaded] = useState(false);
  useEffect(() => {
    const timer = setTimeout(() => {
      setIsLoaded(true);
    }, 500);
    return () => clearTimeout(timer);
  }, []);
  return <div className="lw-template-container">
      <Card title={title} icon={icon}>
        {isLoaded && <span dangerouslySetInnerHTML={{
    __html: `<lw-template id="a029c1a9-28be-427e-b0e1-5d918920246a"></lw-template
            >`
  }} />}
        <Link href={linkHref} className="agent-studio-link text-left text-gray-600 gap-2 dark:text-gray-400 text-sm font-medium flex flex-row items-center hover:text-primary dark:hover:text-primary-light group-hover:text-primary group-hover:dark:text-primary-light">Powered by Lucidworks Agent Studio</Link>
      </Card>
    </div>;
};

[localhost link]: http://localhost:3000/docs/5/fusion/dev-portal/query-stage-sdk/overview

[mintlify link]: https://doc.lucidworks.com/docs/5/fusion/dev-portal/query-stage-sdk/overview

[old doc.lw link]: https://doc.lucidworks.com/fusion/5.9/hbu2ug

In addition to Fusion’s [built-in query stages](/docs/5/fusion/reference/config-ref/pipeline-stages/query-stages/overview), Lucidworks provides the Query Stage SDK for developing your own custom query stages with Java. All of the resources are provided in a [public GitHub repository](https://github.com/lucidworks/query-stage-sdk).

<LwTemplate />

## Get started

Clone the repository to get started:

```bash theme={"dark"}
git clone https://github.com/lucidworks/query-stage-sdk
```

Ensure you are using the correct SDK version for your Fusion version:

|      Fusion versions | Query Stage SDK version | Required JDK |
| -------------------: | :---------------------: | :----------: |
|    5.9.15 and higher |          2.0.0          |      11      |
| 5.4.0 through 5.9.14 |          1.0.0          |       8      |

See [Gradle quickstart](https://docs.gradle.org/current/userguide/tutorial_java_projects.html) documentation for more information on Java Projects.

<Note>
  Starting with Fusion 5.9.16, the Solrj HTTP2 client is not supported in Query Stage SDK plugins.
  When developing custom query stages, use `CloudSolrClient` instead of `CloudHttp2SolrClient` for Solr connections.
</Note>

<Warning>
  The Query Stage SDK requires use of the [Fusion Search DSL](/docs/5/fusion/getting-data-out/query-basics/domain-specific-language), which is deprecated as of Fusion 5.9.4.
</Warning>

## Query Stage SDK library

The Java SDK library contains the classes and interfaces for building new query plugin stages. It is located in the [`query-stage-plugin-sdk` directory](https://github.com/lucidworks/query-stage-sdk/tree/master/query-stage-plugin-sdk).

## Example plugin stage

The example query stage plugin contains an example of how a plugin can be implemented as well as information on how to build and deploy the plugin. It is located in the [`examples/sample-plugin-stage` directory](https://github.com/lucidworks/query-stage-sdk/tree/master/examples/sample-plugin-stage).

The sample plugin stage is an example project with two simple querying stages:

* `UpdateRequestStage.java` - Add a new query parameter with a specific value to each query request.
* `UpdateResponseStage.java` - Add a new field with a specific value to each query response.

This is also a demonstration of a basic Gradle project that assembles a Fusion query stage plugin ZIP file.

### 1. Build the plugin stage

From the main folder, call:

```bash theme={"dark"}
./gradlew -p examples/sample-plugin-stage assemblePlugin
```

Substitute the path to your project.

This creates a plugin `.zip` file (with required manifest file) inside the `build/libs` folder.

### 2. Deploy the stage

You can choose from several different ways to deploy the sample plugin stage:

* Upload it to the blob store.
* Use Gradle.
* Use the REST API.

After successful deployment, new stages should be visible in the `Stages` list in the Fusion Query Pipelines UI.

#### Upload it to the blob store

1. Navigate to **System > Blobs**.
2. Click **Add**.
3. Select **Query Stage Plugin**.
4. Click **Browse​** and select your plugin file.
5. Click **Upload**

#### Deploy from the CLI

<CodeGroup>
  ```bash Deploy using Gradle theme={"dark"}
  ./gradlew -p examples/sample-plugin-stage deploy -PfusionUser=[user] -PfusionPassword=[password]
  ```

  ```bash wrap Deploy with the REST API theme={"dark"}
  curl -u [user]:[password] -X PUT -H "Content-Type:application/zip" --data-binary @sample-plugin-stage-0.0.1.zip https://FUSION_HOST/api/query-stage-plugins
  ```
</CodeGroup>

## Query Stage SDK Javadocs

See the [Javadocs](https://javadoc.lucidworks.com/query-stage-sdk-javadocs/2.0.0/) for complete details about all packages and classes.
