Forum Discussion

phoneboy's avatar
phoneboy
Director
5 years ago

Anyone actually querying a TKB by Product Category Successfully?

In my staging environment, I am trying to write a component that processes the following LIQL query:

SELECT subject,view_href FROM messages WHERE board.id = 'MyBoard@tkb' AND product_category.id = 'MyCategory' AND products.includes = true ORDER by metrics.views DESC LIMIT 5

This example is directly from the documentation, with my goal to get the top viewed assets in a given product category.
This query, however, returns zero results.

If I query for messages for a specific product like the following, I get results:

SELECT subject,view_href FROM messages WHERE board.id = 'MyBoard@tkb' AND products.id = 'TheProduct' ORDER by metrics.views DESC LIMIT 5

If I query the products in the product category ID 'MyCategory' I get the expected list of products.

SELECT id FROM products WHERE product_categories.id = 'MyCategory'

Anyone else doing this successfully?
Unfortunately, I've had a support ticket on this open for a few months with no movement or resolution.

  • SuzieH's avatar
    SuzieH
    Khoros Alumni (Retired)

    Hi phoneboy. I'm checking with engineering on this. I have a feeling that the product_categories.id constraint was added for a feature that never made it out of EA and wasn't removed from the documentation. I'll verify and see if there is a workaround -- maybe something like using parent.id instead. (That's just a guess -- I hven't had time to test yet.)

    • phoneboy's avatar
      phoneboy
      Director

      parent.id didn't work and, from the docs, refers to a specific message.
      The product category wouldn't necessarily be used in a message.
      And, it didn't work when I tried it in the query.