Page 1 of 1

On well written searches...

Posted: 12 Mar 2012 23:01
by Marco
Today I entered the world Multi Field Search for the first time. I wanted to replicate (and extend) the action "Find All" and "In This Branch" of button "Find by Label" in a comfortable Catalog item.
The search performed via the button is extremely fast, since it just involves scanning a text file (on my system it takes 90 ms for 160 items).
In the Catalog I placed this line:

Code: Select all

?:lbl:?* and name:* /r
and everything worked as expected, thanks to the insight provided in the release notes ( http://www.xyplorer.com/xyfc/viewtopic. ... 220#p69366 ).

Now, what if I wanted to make it more general and consider tags and comments too, yet mantaining this speed performance?
I basically want to retrieve every object with a label OR a comment OR a tag in the current path and all the subfolders.
The following don't do the trick, since going to My Computer (so to catch everything) and running the search triggered the classical slow folder scan:

Code: Select all

?:lbl:?* and name:* or tags:?* or cmt:?* /r
?:(lbl:?* and name:*) or (tags:?* and name:*) or (cmt:?* and name:*) /r
Any ideas?

Re: On well written searches...

Posted: 13 Mar 2012 11:27
by admin
It's not easy to determine when a fast database search is possible. The current decision-making was lacking. The next version should work better. All these examples will then apply the fast database search:

Code: Select all

*?:lbl:?* /r
*?:lbl:?* or tags:?* or cmt:?* /r
*?:lbl:?* and name:a* or tags:?* and name:a* or cmt:?* and name:a* /r
*?:(lbl:?* or tags:?* or cmt:?*) and name:a* /r

Re: On well written searches...

Posted: 13 Mar 2012 13:16
by Marco
It comes to my mind that this (determine if a search can be "fast") is a propositional logic problem.
Can you tell me what boolean operators are supported? I have an idea...

Re: On well written searches...

Posted: 13 Mar 2012 13:32
by admin
Marco wrote:It comes to my mind that this (determine if a search can be "fast") is a propositional logic problem.
Can you tell me what boolean operators are supported? I have an idea...
Or, And, Not

Re: On well written searches...

Posted: 14 Mar 2012 22:24
by Marco
Well, I come (late) with a simple (I suppose) solution.

Search supports the fields lbl, tags, cmt (let's call them DB, from DataBase), name, len, lent, prop (let's call these FS, from FileSystem).
The behaviour should be the one in the image, e.g. combining a field of the DB group and a field from the FS with the AND operator should trigger a search which starts from the DB. The NOT operator doesn't change anything.
If you look closely and replace DB with 0 and FS with 1 you'll see that the two table are in fact the truth tables of their logical operator.

So to determine whether a search will be faster because will start from the tags database you just need to:
- strip the search terms leaving only the seven fields above;
- giving the DB fields value 0 and the FS fields value 1;
- evaluate the obtained expression: if the result is 0 then the search will be fast.

Anyway compliments to you because you found the solution way faster!

Re: On well written searches...

Posted: 15 Mar 2012 10:03
by admin
Thanks for the thinking!

But I don't really understand your tables. :|

Re: On well written searches...

Posted: 15 Mar 2012 12:42
by Marco
They are classic double entry tables. Maybe these are clearer...

Re: On well written searches...

Posted: 15 Mar 2012 13:09
by admin
Ah, got it, thanks. Never heard of "double entry tables" before. I'm just a guitarist that teached himself programming.