Places query syntax

Discussion about official Mozilla Firefox builds
Locked
Oropher
Posts: 346
Joined: September 26th, 2007, 7:12 pm

Post by Oropher »

I filed Bug 420282 - After bug 385245, need RESULTS_AS_FOLDER_QUERY result type.

Max, as far as I can tell, these are the (currently!) correct queries for the Smart Bookmarks folder:
Most Visited - place:queryType=0&sort=8&maxResults=10
Recently Bookmarked - place:folder=2&folder=5&folder=3&queryType=1&sort=12&excludeItemIfParentHasAnnotation=livemark%2FfeedURI&maxResults=10&excludeQueries=1
Recent Tags (actually recently used tags) - place:type=6&sort=12&maxResults=10

Oh, and to regenerate your Smart Bookmarks folder, rename or delete the old one, go to about:config and set browser.places.createdSmartBookmarks to false, then restart. Easy :)

- Matthew
Last edited by Oropher on March 11th, 2008, 11:38 am, edited 1 time in total.
User avatar
Max Karl Ernst
Posts: 107
Joined: February 5th, 2008, 3:43 am

Post by Max Karl Ernst »

Thanks both Brablc and Matthew :)
As for my problem with smart bookmark folder, I should've stated more clearly that no setting in about:config, nor deleting places, bookmarks or even whole profile regenerates Smart Bookmarks in my latest nightly :)
Doesn't really matter, as your query info made latest changes obvious.
bomfog
Posts: 455
Joined: November 7th, 2002, 3:22 pm
Location: the palouse, SE. WA, USA

Post by bomfog »

Oropher wrote:set browser.places.createdSmartBookmarks to true, then restart
s/true/false ?
Oropher
Posts: 346
Joined: September 26th, 2007, 7:12 pm

Post by Oropher »

bomfog wrote:
Oropher wrote:set browser.places.createdSmartBookmarks to true, then restart
s/true/false ?

Oops - thanks for the catch!

- Matthew
User avatar
Laeb
Posts: 90
Joined: September 21st, 2003, 11:21 pm
Location: Montréal, CAN

How to build a query to find a bookmarks folder

Post by Laeb »

Does anyone has an example of a query to find a bookmarks folder by its name anywhere in Places ?
I tried this but it did not work:

var historyService = Components.classes["@mozilla.org/browser/nav-history-service;1"]
.getService(Components.interfaces.nsINavHistoryService);
var bookmarksService = Components.classes["@mozilla.org/browser/nav-bookmarks-service;1"]
.getService(Components.interfaces.nsINavBookmarksService);
var placesRoot = bookmarksService.placesRoot;

var options = historyService.getNewQueryOptions();
var query = historyService.getNewQuery();

query.setFolders([placesRoot ], 1);
query.searchTerms = "myFolderName";
var result = historyService.executeQuery(query, options);
Oropher
Posts: 346
Joined: September 26th, 2007, 7:12 pm

Post by Oropher »

Laeb, we've mostly been discussing the 'place:' URIs in this thread. Although I'm starting to take a look at the underlying query system for Bug 420282, I'm not really at the stage to be able to help you. Perhaps someone else can, though?
On second thoughts - if I was building a 'place:' URI to find a bookmark folder, I'd try setting 'excludeItems=1'.
User avatar
Sephirot
Posts: 247
Joined: June 15th, 2004, 7:56 am

Post by Sephirot »

brablc wrote:
Sephirot wrote:Hey thanks. :) DateQuery and DateSiteQuery helped me out, but I'd still like to see a "DateHostSiteQuery" (1st date, 2nd host, 3rd site; e.g. today > mozillazine.org > forums.mozillazine.org).
Ondrej, is it possible to add this query type?

best,
Ronny


This should be easy to implement and fast to execute. Please file a bug and try to get votes for it.

done - https://bugzilla.mozilla.org/show_bug.cgi?id=421953

Would be nice if you drop a message there or even providng a patch. :)
Author of Bookmarks Menu Button, Autoclose Bookmark&History Folders and more

Mozilla/5.0 (Windows; U; Windows NT 6.1; de; rv:1.9.2.19pre) Gecko/20110701 Firefox/3.6.19pre <-- build with MS VC++ 2010 SP1 and PGO on Win 7 x64
Canyonero
Posts: 1407
Joined: April 25th, 2003, 11:02 pm

Re: How to build a query to find a bookmarks folder

Post by Canyonero »

Laeb wrote:Does anyone has an example of a query to find a bookmarks folder by its name anywhere in Places ?
I tried this but it did not work:

Seems like it should work, but I haven't played with any of that stuff for awhile. I assume you've looked at the result to see what it was. What exactly is it returning to you?
ktrix
Posts: 24
Joined: December 7th, 2004, 11:56 pm

Post by ktrix »

Does anyone know if the final release will have a user-friendly way to construct complex queries? In Beta 4 the search "rules" are very limited.

I'm also curious why the places query syntax needs to be reverse engineered like this? Don't the programmers who wrote the places code know exactly what the query syntax is?
User avatar
Max Karl Ernst
Posts: 107
Joined: February 5th, 2008, 3:43 am

Post by Max Karl Ernst »

Yes they know, but places are still under heavy construction and major changes are possible (and happening) so they don't need more nagging users :)
Plans probably don't include any expansion of functionality at this stage, in fact some bugs call for hiding place: uris altogether :)

Anyway, just for the record, few other default queries

History menu:

Code: Select all

place:type=0&sort=4&maxResults=10


Bookmarks menu:

Code: Select all

place:folder=BOOKMARKS_MENU&excludeItems=1&queryType=1
Last edited by Max Karl Ernst on April 21st, 2008, 9:22 am, edited 3 times in total.
ktrix
Posts: 24
Joined: December 7th, 2004, 11:56 pm

Post by ktrix »

Max Karl Ernst wrote:Plans probably don't include any expansion of functionality at this stage


So should we expect a "smart bookmark" extension to come from these efforts then? I hope so! :)
ernstblaauw
Posts: 11
Joined: September 21st, 2005, 5:32 am

Post by ernstblaauw »

Oropher wrote:I filed Bug 420282 - After bug 385245, need RESULTS_AS_FOLDER_QUERY result type.

Max, as far as I can tell, these are the (currently!) correct queries for the Smart Bookmarks folder:
Most Visited - place:queryType=0&sort=8&maxResults=10
Recently Bookmarked - place:folder=2&folder=5&folder=3&queryType=1&sort=12&excludeItemIfParentHasAnnotation=livemark%2FfeedURI&maxResults=10&excludeQueries=1
Recent Tags (actually recently used tags) - place:type=6&sort=12&maxResults=10

Oh, and to regenerate your Smart Bookmarks folder, rename or delete the old one, go to about:config and set browser.places.createdSmartBookmarks to false, then restart. Easy :)

- Matthew

I accidentally deleted the Smart Bookmarks. I recreated them using some other URL's posted for FF3b2, but as those were static (they were not update at all), I deleted them and I set the entry browser.places.createdSmartBookmarks to false. However, no Smart Bookmarks appears :-(. (I have other bookmarks in my Bookmarks Toolbar folder) Do you know a solution? I run FF3b4.

(I can also wait for the next version if that will solve the problem)
minotaur 11
Posts: 33
Joined: August 27th, 2005, 3:24 am

Post by minotaur 11 »

If you have a non relative profile location it's probably bug 381365.
User avatar
Max Karl Ernst
Posts: 107
Joined: February 5th, 2008, 3:43 am

Post by Max Karl Ernst »

ernstblaauw wrote:I accidentally deleted the Smart Bookmarks. I recreated them using some other URL's posted for FF3b2, but as those were static (they were not update at all), I deleted them and I set the entry browser.places.createdSmartBookmarks to false. However, no Smart Bookmarks appears :-(. (I have other bookmarks in my Bookmarks Toolbar folder) Do you know a solution? I run FF3b4.

(I can also wait for the next version if that will solve the problem)


If about:config change and restart don't work for you (it didn't work for me either couple of nightlies ago) just recreate folder manually, and add queries from the post you quoted, those are default Smart Bookmarks.
User avatar
Laeb
Posts: 90
Joined: September 21st, 2003, 11:21 pm
Location: Montréal, CAN

Re: How to build a query to find a bookmarks folder

Post by Laeb »

Canyonero wrote:
Laeb wrote:Does anyone has an example of a query to find a bookmarks folder by its name anywhere in Places ?
I tried this but it did not work:

Seems like it should work, but I haven't played with any of that stuff for awhile. I assume you've looked at the result to see what it was. What exactly is it returning to you?


It is returning a result object with no child but the searched bookmarks folder does exist.
Locked