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

Add search string parsing #1982

Merged
merged 5 commits into from
Nov 22, 2021
Merged

Conversation

WithoutPants
Copy link
Collaborator

Resolves #1210

Changes the query string parsing behaviour to the following:

  • all words are required by default, this means that for a query foo bar, the results must include both foo and bar. Previously, the results would include either foo or bar.
  • the keyword or (case-insenstive) can be used to allow for either terms. For example: foo or bar would return results with foo or bar, like the previous behaviour.
  • the - prefix can be added to exclude terms. For example: foo -bar would return results with foo and exclude any results with bar.

Phrase parsing is unchanged and can be used in combination with the or and not modifiers. Quotes can also be used to escape the or and - keywords.

The or keyword cannot be used directly in combination with the - symbol. What this means is that the search -foo or bar will return results with -foo or bar - it does not exclude foo or include bar.

or sets are anded together. This means that foo or bar baz or qux will return results that must include one of foo and bar, and one of baz and qux.

This hasn't been performance tuned yet. We should also consider reducing the columns on which these queries are run, since they may cause unexpected results. For example, string queries on scenes uses title, details, path, oshash, checksum and (weirdly) scene_marker.title. The first three make sense, the next two have some limited utility and have been convenient for me personally in the past, and I don't think scene markers belong there at all.

The other remaining task is documentation. The browsing page in general probably needs a manual page. I also considered a mouseover tooltip that documents the query syntax, but I felt this might be overly obtrusive.

@WithoutPants WithoutPants added feature Pull requests that add a new feature bounty This issue has a bounty on it in the OpenCollective labels Nov 9, 2021
@WithoutPants WithoutPants added this to the Version 0.12.0 milestone Nov 9, 2021
@kermieisinthehouse
Copy link
Collaborator

Huge! Perhaps a replacement for search by hash is creating a new path for scenes, like scene/hash/{HASH}/. That way if you want a specific scene by hash, you can still locate it in the UI - or just get rid of it. I can't think of a usecase for finding a specific oshash in your library

@WithoutPants
Copy link
Collaborator Author

Huge! Perhaps a replacement for search by hash is creating a new path for scenes, like scene/hash/{HASH}/. That way if you want a specific scene by hash, you can still locate it in the UI - or just get rid of it. I can't think of a usecase for finding a specific oshash in your library

Mostly maintenance tasks. Finding a scene from it's preview file for example. The old scene duplicate finder plugin also output the hashes. We can already filter on checksum and hash, so it would still be possible, just a little more onerous.

@kermieisinthehouse
Copy link
Collaborator

kermieisinthehouse commented Nov 10, 2021

Did some testing. Wow, search is useful now.

Failing tests:

  • I cannot get the NOT operator to work by itself, e.g. -X, I suspect a performance issue.
  • -X or -Y returns the results for X or Y
  • Any 1-2 character term times out the search (>2 minutes)

PASS:

  • X or Y or Z works correctly
  • -X X returns no results
  • X -Y works
  • The _ and % operators still work
  • Have not found any operator order issues

Copy link
Contributor

@SmallCoccinelle SmallCoccinelle left a comment

Choose a reason for hiding this comment

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

From a quick glance, this seems like solid work.

@bnkai
Copy link
Collaborator

bnkai commented Nov 14, 2021

From a quick test everything seems to work fine.

@kermieisinthehouse 1 and 3 from your failing work fine with me so it must be performance related as you suspect
the -X or -Y returns the results for X or Y is supposed to work like "-X" or "-Y" according to the first post and it does work fine for me

@stg-annon
Copy link
Collaborator

I would think that there would be an issue when someone goes to search for something with the or keyword in it. To avoid that I would suggest only accepting OR or | as keywords for the or operation

@WithoutPants
Copy link
Collaborator Author

Failing tests:

  • I cannot get the NOT operator to work by itself, e.g. -X, I suspect a performance issue.
  • Any 1-2 character term times out the search (>2 minutes)

I haven't been able to reproduce this, even with my contrived generated database.

@bnkai
Copy link
Collaborator

bnkai commented Nov 21, 2021

Update: After using for a week i dont think i have noticed anything wrong or a performance related issue. The only thing missing i guess is the help/instructions section

@WithoutPants WithoutPants merged commit 2277d0a into stashapp:develop Nov 22, 2021
@silembir
Copy link

Woo!! Thanks everyone for the great work! I'm glad my bounty has gone to good use :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bounty This issue has a bounty on it in the OpenCollective feature Pull requests that add a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] Improved Search Functionality
6 participants