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

# search:conditional

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/4/app-studio/reference/tags/lightning.directive.searchConditional

[mintlify link]: https://doc.lucidworks.com/docs/4/app-studio/reference/tags/lightning.directive.searchConditional

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

<LwTemplate />

## Description

The search conditional directive

## Usage

as element:

```xml wrap  theme={"dark"}
<search:conditional
       [test="{string}"]
       [response="{object}"]>
</search:conditional>
```

### Directive info

* This directive creates new scope.

#### Parameters

| Param                  | Type       | Details                                                                                               |
| ---------------------- | ---------- | ----------------------------------------------------------------------------------------------------- |
| test  *(optional)*     | **string** | The expression to test conditional logic for. Only render the contents tag if this evaluates to true. |
| response  *(optional)* | **object** | A Response object to check, the tag will render the body if the Response is not null.                 |

## Example

#### Source

```xml wrap  expandable  theme={"dark"}
<h3 id="example_test-attribute">Test Attribute</h3>
<search:conditional test="test1 > 100">
    <p>False don't display</p>
</search:conditional>

<search:conditional test="test1 >= 100">
    <p>True! test1 is greater than or equal to 100</p>
</search:conditional>

<search:conditional test="test2">
    <p>True! test2 is true</p>
</search:conditional>

<search:conditional test="test3 == 'Foo'">
    <p>False don't display</p>
</search:conditional>

<search:conditional test="test3 == 'foo'">
    <p>True test3 does equal foo</p>
</search:conditional>

<hr/>

<h3 id="example_response-attribute">Response Attribute</h3>

<search:conditional response="response">
    <p>True! Response does exist.</p>
</search:conditional>

<search:conditional response="response2">
    <p>False! Response2 does not exist.</p>
</search:conditional>
```

```js wrap  theme={"dark"}
angular.module('lightning')
.controller('ExampleController', ['$scope','ResponseService', function($scope,ResponseService) {
            $scope.test1 = 100;
            $scope.test2 = true;
            $scope.test3 = 'foo'

            ResponseService.setResponse('response', {foo:'bar'});
        }]);
```

#### Result

<img src="https://mintcdn.com/lucidworks/ENcE8K39c0iEpL8J/assets/images/app-studio/as-examples/tags/searchConditional.png?fit=max&auto=format&n=ENcE8K39c0iEpL8J&q=85&s=8f4e1294b98871c1fd9b368f72f6b735" alt="Result" width="1024" height="369" data-path="assets/images/app-studio/as-examples/tags/searchConditional.png" />
