Wiki

Clone wiki

WatchFox / API / searching

Efficiently searching

If you perform automated searches, especially those that may occur frequently. It's probably in your interest to structure your queries to be efficient and quick-running.

Indexes

The first thing to note is that WatchFox has three indexes. They cover players, coordinates (x, y, z), and time (millisecond precision).

Ideally, you should include at least one of these indexes (by using -l and/or -p and/or -t in your query).

Note: You should include as much detail as you can regardless. Queries are quite high-level compared to the actual search that is performed. Additional detail can make things much faster.

Additionally, avoid filtering data once you receive it. If you need the data on two players, use -p player1 player2 instead of searching for everyone and filtering them out.

Similarly, if you want to exclude a particular player, -p !player1 will do just that and without having to transfer as much data (and consume that much more RAM).

Of course, if you're compiling the most busy players in the last day, let's say, iterating through a single search's results is perfectly reasonable.

SearchN

The other mechanism WatchFox offers to keep search load down is searchN.

This search will start at the present, going backwards in time, and only match up to N number of events. If there simply wasn't enough hits, you'll get what was found, possibly nothing.

If you only need the last 10 events where someone said "bad word", searchN(10, "-e player_chat -s bad+word") would serve you well.

Or you could just as easily only need the last event. Use 1 for N and the search will complete the moment a match is found. Last time a player joined: searchN(1, "-p player1 -e player_join")

Again, using WatchFox's built-in tools is preferable to filtering the returned data on your own. Pulling off the last 5 events in an array 1000 long is much less efficient than only matching 5 to being with.


Updated

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.