The Solr schema

Every field of a photo document, the analyzer, the vector field and the solrconfig.

The app uploads the files in solr/conf of its repository to the phone's index: schema.xml, solrconfig.xml, stopwords.txt, synonyms.txt and protwords.txt. The build zips that folder into the APK, so the app always uploads exactly what is in the repository.

01 · Fields of a photo document
id

md5 of the absolute path, lower-case hex

Type
string
path

Absolute path on the phone

Type
string
folder

MediaStore folder, e.g. DCIM/Camera/

Type
string
file_name

File name

Type
string
media_id

MediaStore id, used to open the photo

Type
long
mime, size_bytes

Type and file size

Type
string, long
width, height

Pixels as displayed, EXIF rotation applied

Type
int
orientation

landscape, portrait or square

Type
string
taken_at

EXIF date taken with its offset when present, otherwise MediaStore's date

Type
date
year, month

From taken_at, in the phone's time zone

Type
int
modified_at

File modification time

Type
date
camera_make, camera_model, lens

From EXIF

Type
string
iso, exposure, f_number, focal_length, flash

From EXIF; exposure as 1/250

Type
int, string, float, float, boolean
has_location, location, altitude

GPS as lat,lon when usable; location is a spatial field, so it answers radius searches

Type
boolean, location, float
city, region, province, community, country, country_code

The nearest named place to the position, in words, from Opensolr's nearby_places

Type
string
meaning

The CLIP words joined with commas

Type
text
labels

The CLIP words one by one

Type
string, multi
embeddings

1024 dimensions, cosine; the vector of meaning

Type
vector
clip_model, embed_model

What produced the words and the vector

Type
string
indexed_at

When the document was written

Type
date

Copy fields feed the search fields: text gathers meaning, file name, folder, camera, city, region and country; file_name_text, folder_text, camera_text and place_text hold each of those on its own. Two more copy fields serve typing: suggest (labels, camera make and model, city, region, province, country) is what autocomplete offers, and spell (the same plus the file name) is what Did you mean checks against. Dynamic fields (*_s, *_ss, *_i, *_l, *_f, *_b, *_dt, *_t) are there for anyone extending the app.

02 · Text analysis

All search fields use one analyzer: standard tokenizer, stop words, lower case, accent folding, English possessives, protected words, and KStem, so dogs matches dog. At query time a short synonym list adds photo, picture, image, pic, sea, ocean and a few more. The spell field and the suggester use a second, unstemmed analyzer (text_spell: tokenizer, lower case, accent folding), so corrections and completions come back as real words.

03 · The vector field
<fieldType name="knn_vector" class="solr.DenseVectorField" vectorDimension="1024" similarityFunction="cosine"/>

The vectors come from Opensolr's embedding service, the same one every Opensolr vector index uses. The dimension is fixed by that service.

04 · solrconfig.xml

Deliberately small: Lucene match version 9.0, the classic schema factory (so schema.xml is the schema), a soft commit every 10 seconds and a hard commit every 60, a /select handler answering JSON with 60 rows by default and carrying the spellcheck component (off unless the app asks for it), a /suggest handler with one suggester (AnalyzingInfixLookupFactory over the suggest field, rebuilt at every commit), and /update. Remote streaming and stream bodies are off. There are no <lib> directives, no script processors and no response writers that run templates.

When the configuration changes

The app tells an index on an older configuration apart by the newest field of the schema, uploads the current files, and writes every photo again from the phone's cache. Nothing is asked of you and nothing costs AI requests. See the phone's index.

Opensolr Photos is open source and MIT licensed. Questions about your Opensolr account, index or plan go to opensolr.com/contact; questions about the app itself belong on GitHub.

Opensolr Photos Documentation