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

# Developing Processors

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>;
};

[old doc.lw link]: https//doc.lucidworks.com/app-studio/4.2/3112

[localhost link]: http://localhost:3000/docs/5/app-studio/concepts/extending-appkit/developing-processors

[mintlify link]: https://doc.lucidworks.com/docs/5/app-studio/concepts/extending-appkit/developing-processors

The Appkit Workflow module can be used to apply custom business logic during the search/response/render lifecycle. Workflow Processors are designed to intercept any Appkit model object, and for example, modify a Query before it is submitted to a Platform or augment a Response before it is rendered.

<LwTemplate />

## Developing Processors

All processors implement the Processor interface, parameterized with the object they are designed to work with:

```java wrap  theme={"dark"}
public class AcmeProcessor implements Processor<Query> {
    public void init() {
        ...
    }
    public void process(Query query) {
        ...
    }
    public void done() {
        ...
    }
}
```

Or:

```java wrap  theme={"dark"}
public class AcmeProcessor implements Processor<Response> {
    public void process(Response response) {
        ...
    }
}
```

Processors also support the change(T obj) method which will let you substitute model objects:
`public Response change(Response response);`

<Note>
  If you extend an AbstractProcessor class then change() is automatically named by the process() method making it sufficient to implement the former.
</Note>

A number of abstract helper classes make it easier to implement processors for a given purpose, such as:

* `twigkit.processor.AbstractProcessor<T>`
  Provides abstract implementations of init() and done() and handles setting parameters.

* `twigkit.search.processors.AbstractResultProcessor`
  Makes it easy to implement processors for Results by taking care of the iterations\
  `public void processResult(int index, Result result) {…​}`

* `twigkit.search.processors.AbstractNamedFieldProcessor`
  Makes it easy to implement processors that target specific fields. Requires the `fields` parameter (use \* for all fields). Only the named fields will be passed on to the process method.\
  `public void process(Field field) {…​}`

* `twigkit.search.processors.AbstractNamedFieldValueProcessor<T>`
  Use this abstract class to implement a Processor that will pass the named field values (where the value is an instance of T). Requires the fields parameter (use \* for all fields). Validation of the field value being of the correct type is done by the abstract class.\
  `public Value<String> processValue(Value<String> value) {…​}`

* `twigkit.search.processors.AbstractNamedFacetProcessor`
  Use this abstract class to implement Processor that will process specific named facets. Requires the facetNames parameter (use \* for all facets).\
  `public void processFacet(Facet facet) {…​}`

* `twigkit.search.processors.AbstractNamedFacetFiltersProcessor`
  Use this abstract class to process all the FacetFilters in the named facets. Requires the facetNames parameter (use \* for all facets).\
  `public void processFilter(FacetFilter filter) {…​}`
