Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

search: fix negated suggestions not working in some cases #9477

Closed
wants to merge 5 commits into from

Conversation

shubham-padia
Copy link
Member

fixes #9461.
fixes #9313.

negated special filter operator suggestions
selection_127

negated special filter operand suggestions
selection_128

negated stream suggestions:
selection_129

negated sent_by_me suggestions:
selection_130

previously sent by me suggestion was not occurring in the below query:
selection_131

Partially fixes zulip#9461.
Negated suggestion for both operand and operators are handle in
get_special_filter_suggestions. A bug is get_operator_suggestions
causing the removal of `-` symbol from the operand was also fixed.
`get_containing_suggestions` was used to get the operand suggestions
for the `has` operator. `get_special_filter_suggestions` is now used
to get both the operand and operator suggestions for `has`.
@zulipbot
Copy link
Member

Hello @zulip/server-search members, this pull request was labeled with the "area: search" label, so you may want to check it out!

query = 'hel';
suggestions = search.get_suggestions(query);
expected = [
"hel",
"stream:dev+help",
];
assert.deepEqual(suggestions.strings, expected);
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this was accidentally removed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@timabbott updated, thanks for the review.

attach_suggestions(result, base, suggestions);

suggestions = get_person_suggestions(persons, last, base_operators, 'sender');
suggestions = get_person_suggestions(persons, last, base_operators, 'pm-with');
attach_suggestions(result, base, suggestions);

suggestions = get_person_suggestions(persons, last, base_operators, 'from');
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Structurally, we want to remove below from: as well, right, since that's just another spelling for "sender:"?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, as for the case of not suggesting from queries below when we are suggesting sender queries, this has been taken by the following line of code here.

    // Be especially strict about the less common "from" operator.
    if (autocomplete_operator === 'from' && last.operator !== 'from') {
        return [];
    }

The above ensures that from suggestions are shown only when from has been decide as an operator. i.e query starts with from:. But removing the fromsuggestions from below would mean that we will not show afromsuggestion even when the user typesfrom:` in the query bar which we don't want I think.

@timabbott
Copy link
Sponsor Member

Merged, after marking the last commit to fix #9313. Thanks @shubham-padia!

@timabbott timabbott closed this May 22, 2018
@shubham-padia shubham-padia deleted the negated1 branch September 8, 2018 19:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

search: negated suggestions not working in some cases search: Rank "messages sent by" above "PMs with".
3 participants