Search query with multiple condition | Community
Skip to main content

Search query with multiple condition

  • July 17, 2019
  • 7 replies
  • 0 views

Hi

I am developing an Zendesk app that requires to fetch the ticket data with multiple conditions using API call

1. <baseurl>/api/v2/search.json?query=784068495 (This will return all the tickets that contains the value 784068495)

I would like to add additional condition to search all the matching tickets

2. <baseurl>/api/v2/search.json?query=SunnyDayAND784068495 (This should return all the tickets that contains the values 'SunnyDay' AND '784068495'

 

Please let me know if this is possible, if not suggest alternate way of fetching the data.

 

Thanks

7 replies

ZZ55
  • July 17, 2019

Sudarshan

The API search should work like advanced search in support. So you can create the AND condition:

/api/v2/search.json?query=type:ticket+784068495%20sunnyday


  • July 18, 2019

Hello Sudarshan,

Keep in mind that the response of the Search API will change on the 15th of October.

https://develop.zendesk.com/hc/en-us/articles/360022563994--BREAKING-New-Search-API-Result-Limits

You will get 1000 results on a single page instead of 100 per page. So you can't paginate the results.

With kind regards,

Sebastiaan
Sparkly ⭐


ZZ55
  • July 18, 2019

Sebastiaan

That is a great catch. I am going to have to give that some thought.  Thank you. 


  • July 23, 2019

  • July 23, 2019

Hello Ravi,

As far as I know, there's no OR operator.

Just this:

If submitting multiple search terms, search has a default AND behavior, rather than an OR behavior. For example, searching for the following phrase returns results only if all of the words are present, in any order.
Please upgrade my account

However, when you use a data property keyword multiple times in a query, there is an OR search across the values you specified. The following phrase returns results that contain either the tag "silver" or the tag "bronze".

tags:silver tags:bronze

Source: https://support.zendesk.com/hc/en-us/articles/203663226-Zendesk-Support-search-reference

With kind regards,

Sebastiaan
Sparkly ⭐

 

  • December 26, 2019

Hi, is there any way of creating a logic with both AND & OR conditions? I have tried the following which doesn't work - this is looking for any ticket which has the comments "foobar" OR ("foo" AND "bar)

https://benjistone.zendesk.com/api/v2/search.json?query=comment%3Afoobar+”comment%3Afoo+comment%3Abar


  • December 30, 2019

Hi @Benji. The section Sebastiaan references above is still the best source of information. Search has somewhat limited flexibility in combining AND and OR conditions. All text phrases are ANDed, with no OR option.

If submitting multiple search terms, search has a default AND behavior, rather than an OR behavior. For example, searching for the following phrase returns results only if all of the words are present, in any order.
Please upgrade my account

However, when you use a data property keyword multiple times in a query, there is an OR search across the values you specified. The following phrase returns results that contain either the tag "silver" or the tag "bronze".

tags:silver tags:bronze

Source: https://support.zendesk.com/hc/en-us/articles/203663226-Zendesk-Support-search-reference