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

[question] search filters #1

Open
MaKiPL opened this issue Mar 29, 2022 · 1 comment
Open

[question] search filters #1

MaKiPL opened this issue Mar 29, 2022 · 1 comment

Comments

@MaKiPL
Copy link

MaKiPL commented Mar 29, 2022

What filters can we use/are available?
I tried TAG1|TAG2 and it tried to find both, same as with space
However how do I make the search to filter only the packages that have in description BOTH of the tags?
Tried +, tried AND, tried &
Seems like there's no filtering included

@bitmeal
Copy link
Owner

bitmeal commented Apr 5, 2022

It is currently not possible, but would surely be advantageous.

Current behavior is as follows:

  1. search term gets split on whitespaces
  2. all substrings are interpreted as a regular expression
  3. all regular expressions are used build the database query with $or operation
  4. the query is evaluated against a prebuild "full text search" string

If you have any ideas for the implementation, especially regarding the user interface, you are welcome to give the implementation a shot or leave a comment. Searching the database for explicit fields is no problem in theory.

if(search && search != null && search != '') {
let query = {
$or: search
.toLowerCase()
.split(/\s+/)
.filter( token => token != '' )
.map( token => token.trim() )
.map((token) => {
return {
fts: (new RegExp(token))
}
})
};
// console.log(query);
// this.db.find({ fts: (new RegExp(search)) }, (err, docs) => {
this.db.find(query)
.sort({ name: 1 })
.exec((err, docs) => {
this.loading = false;
if(!err) {
this.items = docs;
}
else {
console.error(`error fetching packages for search term '${search}' from db!`);
}
}
);
}

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

2 participants