Forum Discussion

PerBonomi's avatar
4 years ago

API v2 Search doesn't work

Reading this page, I quote:

 

 

"In v2, perform a one-or-more term search with a comma-separated list of terms wrapped in parentheses.

Use this when you want to return messages that have at least one of these terms in the defined fields.

WHERE subject MATCHES ('apples', 'bananas', 'cherries')"

 

This query returns 2 results:

 

select subject,body from messages where subject matches 'attachment'

 

 

 This query returns 0 results.

 

select subject,body from messages where subject matches ('attachment','android')

 

According to the documentation I should be getting results.

Fair to say that it's not WAI?

 

  • PerBonomi, Yes you are correct, there is an issue in API v2 for getting the results with matches.

    This issue is also there with other API's like labels and tags which have spaces between words.

  • I'm having issues with the v2 search API too. In fact, it looks like Khoros is suffering the same bad results. If you use the new "Help Center" search in community admin, you probably won't find what you're looking for. I searched for "custom tags" and didn't receive any relevant results.

    • SuzieH's avatar
      SuzieH
      Khoros Alumni (Retired)

      Thanks for raising the issue tealiumjustin and PerBonomi.  I'm going to follow up with the Search team on this. Some things seemed to have changed. I thought we'd made all the required updates in the documentation, but obviously not. I'll work with our engineers and report back.

  • SuzieH's avatar
    SuzieH
    Khoros Alumni (Retired)

    Hi PerBonomi tealiumjustin 

    There was indeed a change to the LiQL syntax that the Doc team didn't know about. I'm creating a ticket to get our Search API Overview updated.

     

    Here is the response from Engineering:

    When we want to return messages that have at least one of these terms in the field we need to enclose in double-quotes.

    This will list every post which has any of those terms in the subject field.

    select subject,body from messages where subject matches "('attachment','android')"


    This will list only those posts which have both terms in the subject field.

    select subject,body from messages where subject matches ('attachment','android')


    Please let me know if this solves your trouble.

    • tealiumjustin's avatar
      tealiumjustin
      Expert

      SuzieH Thanks for the quick response! That syntax is a bit unconventional, but it checks out on my end. I'll proceed with this approach.

  • And what if you want to add an exact match into the mix? for example adding to the above

    "('attachment','android','"apples oranges"')"

     

    Where you want to see results with "apples oranges" but not just "apples". No combination of quotation marks seems to be working for me and the documentation is still wrong.

     

    Thanks

    • Claudius's avatar
      Claudius
      Boss

      You need to escape the inner double quotes around the term, e.g.

      SELECT subject, body FROM messages WHERE subject MATCHES "('banana','potato','\"orange apples\"')"