Skip to content

By Author search pulls in keywords too #10139

@emixolydian

Description

@emixolydian

Describe the bug

When searching "By Author", the author type (type 1 in the submission_search_objects table) and the keyword type (type 17 in the submission_search_objects table) are both searched, which makes the search behavior pretty confusing (particularly obvious for journals where proper names appear both as author names and as keywords). "By Author" should only search authors.

To Reproduce

  1. Go to https://journalstest1.usask.ca/index.php/JDJ/search
  2. Click on By Author and type in a search query, e.g. "Donne"
  3. Notice that "Donne" which is a keyword returns many authors that are not named "Donne" (Donne is a very common keyword for this journal, along with many other author names)

What application are you using?

OJS 3.3.0.13

Additional information

The reason this happens appears to be a bug with how the keywords type is encoded that was introduced when keywords were added back to search in OJS 3.x
This issue is where the problem was introduced: #5388
Specifically this comment #5388 (comment)

In that issue, it was decided to use 17 (0x11) for keywords, suggesting that it was fine to use since bitmasking was never implemented for search. However, bitmasking does actually happen for search here: https://github.com/pkp/ojs/blob/43b3ad0ea124dc38ec88f9733e1a6f49dfd941a4/classes/search/ArticleSearchDAO.php#L67

    if (!empty($type)) {
        $sqlWhere .= ' AND (o.type & ?) != 0';
        $params[] = $type;
    }

Because of this, using 17 (0x11) for the keywords has the effect of making it look for author AND subject AND keywords because of how the type is handled here:

public const SUBMISSION_SEARCH_KEYWORD = 17;

author  =  1, aka 00001 
subject = 16, aka 10000
keyword = 17, aka 10001 

Searching for keyword also gets both authors and subjects because it includes both of those positions (shown above).

Metadata

Metadata

Assignees

Labels

Bug:1:MinorA bug found in uncommon paths, with low consequences, limited users or has an easy workaroundTry MeThis issue might be good for a new contributor. Can you help us?

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions