looqs/USAGE.md

176 lines
7.6 KiB
Markdown
Raw Normal View History

2022-04-25 23:12:39 +02:00
# looqs - User guide
This document is still work in progress.
# General points
Please consult the [README](README.md) for a description of what looqs is and on how to obtain it.
2022-05-31 18:42:35 +02:00
# Current Limitations and things to know
You should be aware of the following:
2022-04-25 23:12:39 +02:00
2022-05-31 18:42:35 +02:00
- It may seem naturally, but the GUI and CLI operate on the same database, so if you add files using the CLI, the GUI will search them too.
2022-04-25 23:12:39 +02:00
2022-06-05 14:01:38 +02:00
- If a file is listed in the "Search results" tab, it does not imply that a preview will be available in the "Previews" tab, as looqs can search more file formats than it can generate previews for currently.
2022-04-25 23:12:39 +02:00
2022-05-31 18:42:35 +02:00
- Database paths are stored inefficiently, not deduplicated to simplify queries. This may add up quickly. Also, each PDF text is stored twice. Each page separately + the whole document to simplify queries.
2022-04-25 23:12:39 +02:00
2022-06-05 14:01:38 +02:00
At the time this section was written, 167874 files were in my index. A FTS index was built for 14280 of those, of which 4146 were PDF documents. The PDFs take around 10GB storage space on the filesystem. All files for which an FTS has been built are around 7GB in size on the filesystem. The looqs database has a size of 1.6 GB.
2022-04-25 23:12:39 +02:00
2022-06-05 14:01:38 +02:00
- Existing files are considered modified when the mtime has changed. looqs currently does not check whether the content
has changed.
2022-04-25 23:12:39 +02:00
## Config
It's in `$HOME/.config/quitesimple.org/looqs.conf`. It will be created on first execution of the CLI or GUI
2022-06-05 14:01:38 +02:00
interface. The GUI has a menu entry to quickly open this config file. This is to be considered temporary and will be removed once the GUI itself can edit all settings.
2022-04-25 23:12:39 +02:00
Database default path: `$HOME/.local/share/quitesimple.org/looqs/looqs.sqlite`. If this does not work for
2022-05-31 18:42:35 +02:00
you, move it and adjust adjust the path in the config file.
2022-04-25 23:12:39 +02:00
## GUI
It's minimal at this point, therefore some settings must be performed by editing the config file.
### First run
You will be presented with an empty list. Go to the "Index" tab, add some directories and click "Start indexing".
For large directories the progress bar is essentially just decoration. As long as you see the counters
increase, everything is fine even if it seems the progress bar is stuck.
The indexing can be stopped. If you run it again you do not start from scratch, because looqs knows
which files have been modified or not since they have been added to the index. Thus, files will
only be reprocedded when necessary.
2022-06-05 14:01:38 +02:00
### Search
The text field at the top is where you type your query. It can be selected quickly using CTRL + L. Filters are avalable,
see the document below. By default, both the full path and the content are searched. Path names take precedence.
2022-04-25 23:12:39 +02:00
### Configuring PDF viewer
It's most convenient if, when you click on a preview, the PDF reader opens the page you clicked. For that, looqs needs to know which viewer you want to launch.
2022-06-05 14:01:38 +02:00
It tries to auto detect some common viewers. You must set the value of the ' pdfviewer=' config entry yourself if it doesn't do something you
2022-05-31 18:42:35 +02:00
like, such as not opening your favorite viewer. In the command line options, "%f" represents the filepath, "%p" the page number.
2022-04-25 23:12:39 +02:00
### Preview tab
2022-06-05 14:01:38 +02:00
The preview tab shows previews. It marks your search keywords too. Click on a preview to open the file.
A right click on a preview allows you to copy the file path, or to open the containing folder. Hovering tells you which file the preview originates from.
### Syncing index
Over time, files get deleted or their content changes. Go to 'looqs' -> 'Sync index'. looqs will reindex the content of files which have been changed.
Files that cannot be found anymore will be removed from the index.
Reindexing a path using the "Index" tab will index new files and update existing ones. Currently however, this does not deal with deleted files.
I recommend doing a sync from time to time.
2022-04-25 23:12:39 +02:00
## CLI
2022-06-05 14:01:38 +02:00
The CLI command "looqs" comes with helptext. This documentation is incomplete at the moment.
2022-04-25 23:12:39 +02:00
### First run
2022-06-05 14:01:38 +02:00
There is no point in using the "search" command on the first run. Add some files if not done so already.
2022-04-25 23:12:39 +02:00
### Adding files
To add files to the index, run ``looqs add [path]```, where 'path' can be a directory or a single file.
If the path is a directory, the directory will be recursively descended, and all files in there added.
2022-06-05 14:01:38 +02:00
"Skipped" implies the file has not been changed since it has been added to the index. If it has changed, the index content will be updated.
2022-04-25 23:12:39 +02:00
### Searching files
Of course the CLI will not render any previews, but it can show you the paths where search results
have been found.
```
looqs search [terms...]
```
There is an implicit "AND" condition, meaning if you search for "photo" and "mountain", only paths
will be shown containing both terms, but not either alone.
### Deletion and Fixing Out of sync index
2022-06-05 14:01:38 +02:00
You sometimes delete files, to get rid of those from the index too, run:
2022-04-25 23:12:39 +02:00
```
looqs delete --deleted --dry-run
```
This commands lists all files which are indexed, but which cannot be found anymore.
Remove them using:
```
looqs delete --deleted --verbose
```
You can also delete by pattern:
```
looqs delete --pattern '*.java'
```
Delete never removes anything from the file system, it only operates on the database.
2022-06-05 14:01:38 +02:00
The equivalent of the GUI sync command is probably something like:
```
looks update -v --continue --delete
```
2022-04-25 23:12:39 +02:00
### Updating files
The content and metadata index for files can be updated:
```
looqs update -n
```
Those files still exist, but the content that has been indexed it out of date. This can be corrected with
```
looqs update
```
This will not add new files, you must run `looqs add` for this. For this reason, most users
will probably seldomly use the 'update' command alone.
2022-06-05 14:01:38 +02:00
## Tips
### Keeping index up to date
The most obvious way is to use the GUI and add your favorite paths in the "Index" tab. Then occasionally, just rescan. This works for me personally, looqs quickly picks up new files. This however may not be good enough for some users.
Some users may prefer setting up cronjobs or wire up the CLI interface with file system monitoring tools such as [adhocify](https://github.com/quitesimpleorg/adhocify).
### lh shell alias
If you are in a shell and you know your file is somewhere in your current directory or its subdirs, and those
are indexed by looqs, you may find the lh (look here) alias useful:
```
alias lh='looqs search $(pwd)'
```
So typing "lh recipes" searchs the current dir and its subdirs for a file containing 'recipes'.
## Query syntax / Search filters
A number of search filters are available.
The most important ones are:
- path.contains:(term), short: p:(term) - Pretty much a SQL LIKE '%term%' conditions, just searches the path string
- path.ends:(term), short: pe:(term) - Filters path ending with the specified term, e. g.: pe:(.ogg)
- path.begins:(term), short: pb:(term) - Filters path beginning with the specified term.
- contains:(terms), short: c:(terms) - Full-text search, also understands quotes.
Filters can be combined. The booleans AND and OR are supported. Negations can be applied too, except for c:().
The AND boolean is implicit and thus entering it strictly optional.
Examples:
pe:(.ogg) p:(marley) - Finds files that end with .ogg and contain 'marley'. May be a reasonable attempt to find songs by Bob Marley in your musics collection.
p:(slides) support vector machine - Performs a content search for 'support vector machine' in all paths containing 'slides'
p:(notes) (pe:(odt) OR pe:(docx)) - Finds files such as notes.docx, notes.odt but also any .docs and .odt when the path contains the string 'notes'.
memcpy !(pe:(.c) OR pe:(.cpp))- Performs a FTS search for 'memcpy' but excludes .cpp and .c files.
c:("I think, therefore") - Performs a FTS search for the phrase "I think, therefore".
2022-04-25 23:12:39 +02:00