New search operator "not" for tags only

But it seems that after this change the code isn’t passing The Travis CI build (although it was passing it previously and I only changed the “~” symbol into “!” in few places)… Have I overlooked something? Had this job changed in the meantime maybe? Is “!” for sure a good symbol to use? Can pulling the repository change something as I haven’t updated it since the previous commit?

Thanks! Your changes look good to me.
We are having problems with Travis builds. The build failure is unrelated to your changes.

7 Likes

What do you suggest I could work on now? Some time ago I added comments on the performance of my change on github. I wondered whether I should try to replace “NOT IN” with “NOT EXIST” (it would be faster then, but I found it not easy to do with active records), choose a completely different way of implementing the feature or leave it as it is. There’s also the new issue connected with search: Include translated posts in search?, so maybe I could take a look at it in the meantime?

3 Likes

@kasiabulat Apologies for the lack of response from us as we’re trying to figure out internally what the search operator should look like. Do you think it’ll be hard to support sometime like tags:eggs -tags:lunch?

9 Likes

Do you know if there’s an easy way to swap the ispell / stemmer dictionaries used?

Even if so, would it not require more tables?

@tgxworld Do you mean splitting on -tags: instead of -? So for more complex example: tags:eggs+beacon -tags:lunch,sandwiches it would search for posts with eggs and beacon tags, but without lunch and without sandwiches tags? Then, I think it would be a quick change.

12 Likes

Yup we’ll like to support that syntax :slight_smile:

5 Likes

OK, I’ll work on that.

7 Likes

The needed change was a bit different than I expected as searched phrase is split on white characters at the beginning and then each part is processed with all matching advanced search functions. I divided searching tags into two short functions, but I think now it’s even more clear.

My commit: https://github.com/discourse/discourse/pull/5467/commits/93e993076ca08b9f94b7335e4fa3741a2a33dbf2

1 Like

@Mittineague I’m afraid I am not so deep in the topic to understand what you are exactly asking about. Could you give me some more details?

Postgres uses “dictionaries”:
https://www.postgresql.org/docs/9.1/static/textsearch-dictionaries.html

Ispell dictionaries try to reduce input words to a normalized form; stemmer dictionaries remove word endings

Postgres searches involve stop words (considered as insignicant / unhelpful) and lexemes (the “root” word).

For extreme examples if in one locale the text was

πάντες γὰρ οἱ λαβόντες μάχαιραν ἐν μαχαίρῃ ἀπολοῦνται

Or in another

Converte gladium tuum in locum suum. Omnes enim, qui acceperint gladium, gladio peribunt.

Search wouldn’t work so well looking for “sword”.

In other words, for searching to work with translations. I think the more things match up the better.

2 Likes

Hi, has this been implemented? If so which syntax was chosen

Yes, I have the same question. Has this “not” search implemented?

Pull request is shown as open and tagged for 2.1

2 Likes

This is merged in

https://github.com/discourse/discourse/commit/b71cf6d422b43a8b10079978e8649ef5e44ac742

18 Likes