# Search Query API Call Configuration for more than one conditions

**URL:** <https://discuss.elastic.co/t/search-query-api-call-configuration-for-more-than-one-conditions/351857>\
**Category:** Elastic Search\
**Tags:** elastic-app-search\
**Created:** [January 26, 2024, 7:26am UTC](https://discuss.elastic.co/t/search-query-api-call-configuration-for-more-than-one-conditions/351857 "2024-01-26T07:26:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![aisyaharifin](https://avatars.discourse-cdn.com/v4/letter/a/b9e5f3/32.png) [@aisyaharifin](https://discuss.elastic.co/u/aisyaharifin)\
**Post date:** [January 26, 2024, 7:26am UTC](https://discuss.elastic.co/t/search-query-api-call-configuration-for-more-than-one-conditions/351857/1 "2024-01-26T07:26:36Z")

</div>

Hello,

I've been trying the API call from the Search Applications \> Connect features. Can see the screenshot and below is the sample :

 ![Screenshot 2024-01-26 at 2.22.48 PM](https://us1.discourse-cdn.com/elastic/original/3X/5/7/57498f18660ed433c4d22b72be7913a4c47649d4.png)

```auto
POST /_application/search_application/search-my/_search
{
  "params": {
    "query": "pizza",
    "myCustomParameter": "example value"
  }
}

```

We would like to do API call direct to our search engine, rather than Elasticsearch.

We trying to set the params query according to below conditions :

**query condition:**

- match keyword in title, description, postfiles
- isprivate = false or (isprivate = true and users\_in\_channel = userId)
- published date in range date

To give you explanation, first condition, we need to set the params to read if match the search query with any field in the data field which is 'title', 'description', 'postfiles', then it will show the search result, this is the first condition.

Second condition, to check the query with the data in search engine, if its match where, if it (isprivate = true and users\_in\_channel = userId) or if it is not private (isprivate = false).

Lastly, to check the published\_date if its within the range date that user filter from the frontend ui, this parameter will be passed also through API to check the range date and filter the data based on this parameter.

Below is our API call that works :

```auto
GET /_application/search_application/search-my/_search
{
  "params": {
    "query_string": "(1234) OR (Testing)"
  }
}

```

```auto
GET /_search
{
    "query": {
        "multi_match": {
            "query": "(1234) OR (Testing)",
            "fields": ["users_in_channel","title"]
        }
    }
}

```

We've been testing around the API and not sure if this is the correct way to set the params for search query.

Need help to construct the API based on mentioned conditions.

---

<div class="post-metadata">

**Author:** ![Kathleen\_DeRusso](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kathleen_derusso/32/132039_2.png) [@Kathleen\_DeRusso](https://discuss.elastic.co/u/Kathleen_DeRusso)\
**Post date:** [January 26, 2024, 4:16pm UTC](https://discuss.elastic.co/t/search-query-api-call-configuration-for-more-than-one-conditions/351857/2 "2024-01-26T16:16:37Z")

</div>

Hi @aisyaharifin I'm happy to see that you're experimenting with search applications!

It looks like you've already started setting it up, but in case you haven't found it we have a pretty good [overview](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-application-overview.html) document on setting up search applications.

When you create a search application, you can pass in a search template to the search application. This template represents the query that you'd send into the search application when you use the `_application/<>/_search` endpoint. If you choose not to specify a search template, a [default template](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-application-api.html#search-application-api-default-template) will be applied and used in the search application. Currently the default template performs a simple [query\_string](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html) query over the indices in your search application. You'd send in parameters to change `query_string` to whatever value you wanted. You can check the template at any time using the [get](https://www.elastic.co/guide/en/elasticsearch/reference/current/get-search-application.html) API and update it at any time using the [put](https://www.elastic.co/guide/en/elasticsearch/reference/current/put-search-application.html) API.

Now, the good news is that when the search application is created, an alias is also created for that search application using the same name - so you can search over the same indices using the regular `_search` API call like you want, and it will search that alias. However, if you don't use the [search application search](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-application-search.html) API the template won't be used, so you have to modify the `_search` query to search for what you want.

Hope that helps.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 23, 2024, 4:17pm UTC](https://discuss.elastic.co/t/search-query-api-call-configuration-for-more-than-one-conditions/351857/3 "2024-02-23T16:17:33Z")

</div>

Closed on February 23, 2024, 4:17pm UTC

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
