New search operator "not"


(Katarzyna Bułat) #21

I added a commit with the proper change: Add search not operator by kasiabulat · Pull Request #5467 · discourse/discourse · GitHub

(Katarzyna Bułat) #22

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?

(Gerhard Schlager) #23

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

(Katarzyna Bułat) #24

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?

(Alan Tan) #30

@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?

(Mittineague) #31

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?

(Katarzyna Bułat) #32

@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.

(Alan Tan) #34

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

(Katarzyna Bułat) #35

OK, I’ll work on that.

(Katarzyna Bułat) #36

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: Add search not operator by kasiabulat · Pull Request #5467 · discourse/discourse · GitHub

(Katarzyna Bułat) #37

@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?

(Mittineague) #38

Postgres uses “dictionaries”:
PostgreSQL: Documentation: 9.1: Dictionaries

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.

(Jose C Gomez) #39

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

(Harry) #40

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

(cpradio) #41

Pull request is shown as open and tagged for 2.1

(Alan Tan) #42

This is merged in

(Sam Saffron) closed #43