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: Concatenate multiple tags via OR #6343

Closed
JammingBen opened this issue May 17, 2023 · 4 comments
Closed

Search: Concatenate multiple tags via OR #6343

JammingBen opened this issue May 17, 2023 · 4 comments
Assignees
Labels

Comments

@JammingBen
Copy link
Contributor

Steps to reproduce

  1. Create two tags: tagA and tagB
  2. Add tagA to a resource
  3. Search for tagA and tagB via a concatenated search pattern Tags:"tagA,tagB"

Expected behavior

I expect the resource to show up in the results because the filter should have an OR behaviour.

Actual behavior

The resource does not show up in the search results. I know that I could use Tags:"tagA" Tags:"tagB", but according to #6305, this is a bug and should concatenate via AND in the future - so that doesn't help.

@kulmann kulmann added the Priority:p3-medium Normal priority label May 19, 2023
@kulmann kulmann moved this from Qualification to Prio 3 or less in Infinite Scale Team Board May 19, 2023
@aduffeck
Copy link
Contributor

Alright, let me try to explain how the search syntax works. I already talked to @kulmann about this in person and it looks like the current implementation supports everthing that's needed for web in the end.

First of all it has to be noted that there are two different 'modes' you can use with the search term, a simple and a complex one.

The simple syntax is used when you just submit a phrase (which can consist of one or more words). This is mapped to a substring query on the Name field by the search service, essentially transforming it to a Name:*<phrase>* query internally. Please note that this substring query searches for an exact match inside the Name field, so if you have a document named The 100 Best Targets for Astrophotography searching for 100 Best Targets will find the document while 100 Targets will not find it.

As soon as a field is specified in the query however (e.g. Content:foo) the search switches to the complex low-level mode. That means that the search term is passed to the search engine (almost) unchanged, effectively making this a bleve syntax query with the following effects:

  • All search "items" are considered optional by default
  • Required search items can be added by prefixing them with +, e.g. +Tags:foo
  • Exclude items can be specified using a - instead, e.g. -Tags:bar
  • Any item not prefixed with a field will be considered a match clause (not a substring one) for the composite _all field, which will be just the Name field once Do not include full-text and tag data in the composite field #6356 has been merged

Some examples:

Content of the space:

  • foo.txt (tagged: foo)
  • bar.txt (tagged: bar)
  • foobar.txt (tagged: foo, bar)
  • empty file.txt
Simple search: 'file' (substring search on the name)
Result: empty file.txt

Complex search: 'Tags:foo' (all tagged foo)
Result foo.txt, foobar.txt

Complex search: 'Tags:foo Tags:bar' (all tagged foo OR tagged bar)
Result foo.txt, bar.txt, foobar.txt

Complex search: 'Tags:foo +Tags:bar' (all tagged foo that are tagged bar)
Result bar.txt, foobar.txt

Complex search: '+Tags:foo +Tags:bar' (all tagged foo AND tagged bar)
Result foobar.txt

Complex search: 'Tags:foo -Tags:bar' (all tagged foo that are not tagged bar)
Result foo.txt

Complex search: 'Tags:bar file' (all tagged bar OR that match 'file')
Result bar.txt

Complex search 'Tags:bar Name:*file*' (all tagged bar OR that substring-match 'file')
Result bar.txt, empty file.txt

Complex search 'Tags:bar "empty file.txt"' (all tagged bar OR that match 'empty file.txt')
Result bar.txt, empty file.txt

I hope that makes sense and allows for everything you want to do.

@JammingBen
Copy link
Contributor Author

JammingBen commented May 22, 2023

@aduffeck Thanks for the clarification, I got most of the cases working!

However, there is still one edge case: Let's say I want to search all files named file.txt AND have either tag foo, OR tag bar. So something like Cond1 && (Cond2 || Cond3). Is this also possible?

@aduffeck
Copy link
Contributor

@JammingBen no, the boolean algebra kind of query you describe isn't possible with our current search interface.

It's possible on the index at a lower lower but would require us to design a new, more complex way of sending queries to the search service.

@JammingBen
Copy link
Contributor Author

Alright, we've adjusted the functionally in Web to work around this.

I think we can close here for now and create a new issue if the scenario becomes relevant in the future. Thanks again for the time to dig into it!

@github-project-automation github-project-automation bot moved this from Prio 3 or less to Done in Infinite Scale Team Board May 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

No branches or pull requests

3 participants