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

Fulltext search does not work for users with special characters in the username #300

Closed
vbier opened this issue Sep 13, 2023 · 2 comments
Closed

Comments

@vbier
Copy link

vbier commented Sep 13, 2023

As soon as a username has some special character, no documents are found in the fulltext search. This effectively breaks fulltext search for all AD/LDAP users, which makes nextcloud unsuitable for use in corporate environments.

This is caused by the filter restricting documents by user permissions in

private function generateSearchQueryAccess(IDocumentAccess $access): array {

The term query on users or owner does not find usernames that do not only consist of characters and digits because the type of the users and owner fields are text:

        "users" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        }

When using the term query on text fields, the searched term is analyzed (see the big fat warning here: https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-term-query.html) and does not match. Either fix the filter to use the subfield users.keyword and owner.keyword:

                $query[] = ['term' => ['owner.keyword' => $access->getViewerId()]];
                $query[] = ['term' => ['users.keyword' => $access->getViewerId()]];

or change the field type to keyword.

@vbier
Copy link
Author

vbier commented Sep 13, 2023

@vbier
Copy link
Author

vbier commented Sep 27, 2023

Has been fixed with #237. I have just validated that searching now works with version 27.0.3.

@vbier vbier closed this as completed Sep 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant