social-app icon indicating copy to clipboard operation
social-app copied to clipboard

Search for hashtags doesn't return any result

Open fenarinarsa opened this issue 1 year ago • 8 comments

Describe the bug

When searching for any hashtag, the search returns nothing.

To Reproduce

Steps to reproduce the behavior:

  1. Search for a hashtag for example #hazbinhotel

Expected behavior

The search should return posts containing this hashtag.

Details

  • Platform: web and iOS
  • App version: 1.63

Additional context

While still not supported as interactive elements, hashtags are widely used for people and feeds to tag and find contents (especially for fandoms, series, artists). Sometimes hashtags are the only way to find content since some shows/topics use everyday words that would otherwise return non-relevant content.

fenarinarsa avatar Jan 11 '24 08:01 fenarinarsa

I run into this a few days ago. Am quite sure that it broke somewhere along the way and used to work in earlier versions.

mschwendener avatar Jan 11 '24 08:01 mschwendener

Might be from the switch to the new search service, although it's not like the previous one actually searched by hashtag IIRC

mary-ext avatar Jan 11 '24 08:01 mary-ext

not like the previous one actually searched by hashtag IIRC

Yes, I seem to be mistaken. From June 2023: "Even in its simplest form (allow search for them ..."

mschwendener avatar Jan 11 '24 09:01 mschwendener

Another issue is that when a word is into a hashtag, you can't even look for it.

A post with #house won't show up in search results if you look for "house".

fenarinarsa avatar Jan 11 '24 18:01 fenarinarsa

This seems to have been somewhat improved — You can now search for "art", and bluesky will return posts containing both "art" and "#art". However, searching for "#art" results in the term being ignored.

The easiest way to see this in action: Searching "from:username.bsky.app #art" will unexpectedly return all posts by the user, whereas "from:username.bsky.app art" will act as expected and only return posts from the user containing the word "art".

HeyItsLollie avatar Feb 07 '24 02:02 HeyItsLollie

I think I know why hashtags aren't shown.

The search is performed in Search.tsx, via useActorSearch in actor-search.ts, which calls searchActors on the agent. The agent is defined by atproto/api; the searchActors method does an API call to app.bsky.actor.searchActors. The query eventually passes through the ParseQuery function in the backend.

That ParseQuery function splits the query using https://github.com/google/shlex, but shlex (as the name implies) splits the string as if it's shell syntax, throwing away shell comments* - everything after and including "#". This causes the query "#a_tag" to be equivalent to "" (empty string), and from:username.bsky.app #art to be equivalent to from:username.bsky.app.

*This behavior is easily reproduced on the Go Playground:

package main

import (
	"fmt"
	"github.com/google/shlex"
)

func main() {
	// [abc foo]
	fmt.Println(shlex.Split("abc foo #def ghi"))
}

Edit: filed as https://github.com/bluesky-social/indigo/issues/578.


Additionally, this:

https://github.com/bluesky-social/social-app/blob/b9301befb701e3562de81294048163c62349bcbe/src/state/queries/actor-search.ts#L14-L16

kisaragi-hiu avatar Feb 14 '24 08:02 kisaragi-hiu

A fix has been made as a PR at https://github.com/bluesky-social/indigo/pull/579.

Zero3K avatar Feb 15 '24 23:02 Zero3K

It has been merged. I think it'll take effect when a new version of Bluesky is uploaded to the servers.

EDIT: It just took a while to take effect. So, I think this issue should be closed.

Zero3K avatar Feb 16 '24 00:02 Zero3K

Yup, this has been fixed. Thank you for reporting!

gaearon avatar Feb 20 '24 22:02 gaearon