Forum Discussion
9 Replies
- Akenefick3 years agoGenius
I think this should work.
SELECT count(*) FROM messages WHERE tags.text = 'wireless headphones'
See here messages (khoros.com) for more options.
So the full call would be something like this
[Community Domain]/api/2.0/search?q=SELECT%20count(*)%20FROM%20messages%20WHERE%20tags.text%20%3D%20%27wireless%20headphones%27
or with Freemarker
rest("2.0","/search?q=" + "SELECT count(*) FROM messages WHERE tags.text = 'wireless headphones'"?url)
You can grab a full export of posts and which tags they have via the CSV export to sanity check the results as well -> https://community.khoros.com/t5/Search-tools/Export-community-search-results-to-a-CSV-file/ta-p/37608
- adriana4u3 years agoMaven
Hello,
Hope to find you well.
I have tried to do this api call:
And it gave the error above... Maybe I'm not doing it well, since I've only made rest apis before.
- adriana4u3 years agoMaven
Hello StanGromer,
Thank you so much for your help!
Issue is this tag is currently not being read in the community because it has a % on it. That's essentially the main issue. I want to see which posts have this tag to make a new one and delete the current one.
- Akenefick3 years agoGenius
Hi,
Try doing it through your browser while you are logged into your community in the same browser.
Also if you want more than the count you can add other fields like id to get a list of message ids for messages with that tag or view_href to get links to the posts. SELECT id, view_href, count(*) FROM messages etc.. Just need to encode everything after the equals sign, but it looks like you have that covered.
- adriana4u3 years agoMaven
- Akenefick3 years agoGenius
Hi adriana4u
See this on accessing API v2 Getting started with API v2 (khoros.com)
In particular it says "On private communities where anonymous access is turned off, anonymous users cannot access the API."
I'm guessing that is the case for you. Make sure you are logged into the community and try again. I think it should work if you are logged in on the same browser.
Also I got I different error when I tried your query for my community. It looks like maybe your encoding is a little messed up. You mentioned you have a percent sign in your tag name. Is this the query you are trying?
SELECT count(*), view_href FROM messages WHERE tags.text= 'CPU 100%'
encoded that should be
SELECT%20count(*)%2C%20view_href%20FROM%20messages%20WHERE%20tags.text%3D%20%27CPU%20100%25%27
This is a useful site for encoding URL Decoder/Encoder (meyerweb.com)
- adriana4u3 years agoMaven
Hello !! It worked!!!!! Thank you so much Akenefick
I just have an additional question! How do I add something to know which posts are these?
- Akenefick3 years agoGenius
So it looks like including the count(*) field prevents individual info about the messages from showing. So remove that and just use view_href if you want a link to each message.
So:
SELECT view_href FROM messages WHERE tags.text= 'CPU 100%'
or encoded
SELECT%20view_href%20FROM%20messages%20WHERE%20tags.text%3D%20%27CPU%20100%25%27
The results you get will be a little hard to read. I use this site Json Parser Online.
Is that what you were looking for?
Related Content
- 9 months ago
- 5 months ago
- 10 months ago