Reading view

There are new articles available, click to refresh the page.

How to tell if Spotlight has indexed a file correctly

When you search but Spotlight doesn’t find what you’re looking for, you might wonder whether that’s because the file containing it hasn’t been indexed correctly. This article suggests some methods you can use to investigate this.

Spotlight relies on hidden indexes it maintains at the top level of each volume, in the .Spotlight-V100 folder. When an app or process creates a new file or changes the contents of an existing file, that’s recorded in the volume’s FSEvents database. If that file is in a location that isn’t excluded from Spotlight’s index, an mdworker process should then start adding its contents to the volume indexes. To do this, it first checks what type of file it is, by its UTI. Spotlight then looks up the correct mdimporter for that type, and uses that to generate data that Spotlight adds to that volume’s indexes as a set of attributes.

Recent versions of macOS can extract additional information from certain types of files such as images and PDFs. This includes text recognised within images using Live Text, and object recognition and classification, performed in the background by other services such as photoanalysisd. Those are slower and take significantly more processing, and are normally run after traditional mdimporter extraction.

mdimporter plugins

For many file types, these are provided as part of macOS and stored in the system, in /System/Library/Spotlight on the SSV. Importers for third-party apps may be in /Library/Spotlight or ~/Library/Spotlight, or in the /Library/Spotlight folder inside the app bundle. To discover all mdimporter plugins currently installed, use the command
mdimport -L
although that doesn’t inform you which file types they support.

To get more information, identify a file of the correct document type, normally with that type’s standard filename extension, and use mdimport to discover which mdimporter is used for that type, and what it can extract from that specific file, in a command of the form
mdimport -t -d3 [filepath]
where [filepath] is the path of that file. You can vary the digit used in the -d3 option from 1-3, with larger numbers delivering more detail. For -d3 you’ll first be given the file type and mdimporter used, following which all the data extracted is given according to its Spotlight attributes:
Imported '/Users/hoakley/Documents/SpotTestA.rtf' of type 'public.rtf' with plugIn /System/Library/Spotlight/RichText.mdimporter.
37 attributes returned

followed by a long list.

If you’re still in the dark, the nuclear option is to perform a diagnostic dump similar to sysdiagnose but concentrating on Spotlight, using the command
mddiagnose -f [path]
to write the diagnostic output to the specified path. Further details are given in man mddiagnose.

Mints

My free utility Mints has a whole section devoted to testing and observing Spotlight. This includes creation of a folder of nine test files in the user’s Home folder, carrying out a test search that should find those test files, custom log analysis, and cleaning up test files afterwards. This is all fully documented in the Spotlight check and test section of its Help book.

To start the test, click on the Create Test button at a known clock time, such as 12:30:00. Wait at least ten seconds, say until 12:30:10, then click the Check Search button. Give your Mac a good 20 seconds to complete that, then open the Log Window and view entries from 12:30:00 for a period of 30 seconds, to cover both the indexing of the test files and the search. Once you’re happy that all is well, you can delete the test files.

Test files include:

  • RTF rich text
  • PDF with embedded text
  • plain UTF-8 text
  • HTML
  • Microsoft Word DOCX
  • JPEG image with the search term in its EXIF metadata
  • Numbers spreadsheet
  • Pages document
  • plain UTF-8 text with the search term in a kMDItemKeywords extended attribute.

You can also customise the test files with other formats, provided that they contain the search text syzygy999 that Mints will look for.

Exclusions

Perhaps the most common reason for Spotlight not indexing a file’s contents is that it has been excluded from doing so. This is always worth checking before making the assumption the problem is in Spotlight.

There have been three general methods of excluding folders from indexing and search, although only two of them still work reliably:

  • appending the extension .noindex to the folder name (this previously worked using .no_index instead);
  • making the folder invisible to the Finder by prefixing a dot ‘.’ to its name;
  • putting an empty file named .metadata_never_index inside the folder; that no longer works in recent macOS.

System Settings offers Spotlight Privacy settings in two sections. Items listed under Search results won’t normally prevent indexing of those items, but will block them from appearing in search results. Spotlight’s indexing exclusion list is accessed from the Search Privacy… button, where listed items won’t be indexed at all.

Summary of useful commands

  • mdimport -L lists known Spotlight mdimporter plugins.
  • mdimport -t -d3 [filepath] reports the mdimporter used for a file, and data extracted from that file.
  • mddiagnose -f [path] runs full Spotlight diagnostics.

A brief history of Mac ports – low speed

Like most computers, Apple’s Macs have had five main types of port to allow them to be connected to external devices: low speed intended commonly for keyboards and other input devices, high speed often for connection to external storage, display, network, and audio. This brief history concentrates on the first of those.

The original 128K Macintosh launched in 1984 came with a good range of ports, including two RS-422 serial ports and a DB-19 supporting external floppy disk drives. It had separate mouse and keyboard ports, DE-8 and RJ-11 respectively. In 1986, Apple’s IIGS brought the first implementation of a new type of port, Apple Desktop Bus or ADB, that was introduced to the Mac SE and II the following year, replacing the original mouse and keyboard ports.

ADB

At the time, ADB was unique to Apple’s computers, although it was later adopted by NeXT. This uses a 4-pin mini-DIN connector to hook up a daisy-chain of peripherals. The theoretical maximum speed of ADB is 125 Kb/s, although around 62 Kb/s was closer to that experienced in practice. Among these ADB devices came dongles, used to enforce software copy-protection. Devices on an ADB chain each have an address, defaulting to $2 for keyboards, and $3 for mice.

adbparser

This is ADB Parser, analysing its traffic. Note both Keyboard and Ext. Keyboard initially shared the original address of 02, and the Mouse has 03.

Perhaps the greatest shortcoming of ADB was that it wasn’t intended to be hot-swappable, and the Mac was supposed to be shut down before any changes were made to its connected ADB devices. Although many of us ignored that, it was at our peril. Occasionally, hot-swapping ADB devices fried a fuse that was soldered into the motherboard; although there was a workaround, for most that required a trip to the local authorised Apple dealer and a replacement motherboard, at considerable expense.

ADB and serial ports underwent the transition from Motorola 68K processors to the PowerPC in 1994, and it was another four years before their replacement came, in USB 1.

USB

The first iMac, released in 1998, was also the first Mac without an ADB port, and came with two USB ports for its mouse, keyboard and other peripherals. The first version of USB had only been introduced in 1996, and brought with it new USB-A connectors, although those were initially complicated by a different USB-B format on printers.

The move to USB opened up many new possibilities for external devices including storage, and hubs quickly became needed to support the profusion. Performance was also greatly improved over ADB, leaping from 62 Kb/s to 12 Mb/s at what was appropriately known as Full Speed. That improved again when USB 2.0 (released in 2000) appeared in the 15-inch iMac, iBook and PowerBook G4, and Power Mac G5 of 2003. These reached 480 Mb/s in what was justifiably called High Speed.

asp3

Apple System Profiler here shows five USB devices, each with its own driver, connected to a hub. These include a third-party mouse, and a USB-to-serial adaptor.

msmouse

Third-party mice and other input devices thrived with USB, although driver support was variable. This is a Microsoft IntelliPoint mouse that was popular.

usbprober

USB was far more complex than ADB, as seen here in ADB Prober. This is a selection of the data in a basic powered USB hub. One of the lasting mysteries was why some peripherals worked more reliably when connected to powered hubs, while others didn’t work at all unless connected direct to a port on the Mac.

USB continued to develop, and with it a profusion of different plug and socket formats. Several different Mini and Micro versions came to fill our drawers and boxes with their cables and adaptors. By the time of USB 3.0 and its 5 Gb/s SuperSpeed and USB-C format, we were all hoping for a reprieve and the return of simplicity. Those hopes were dashed with USB 3.1 in 2013, and its Gen 1 and Gen 2 with their confusion of different terms.

Bluetooth

The last transition for input devices was to do away with cables (almost) altogether, and in 2017 Apple dropped its last models of wired mice and keyboards. At first their wireless replacements required USB-A ports for their charging cables, and have most recently switched to USB-C. Bluetooth had its origins in 1999-2001 in headsets and mobile phones, and by the time our input devices had gone wireless they were achieving data rates upwards of 1 Mb/s over a short range. Few of us now rely on ports and cables to support our keyboards, mice and trackpads.

Wikipedia

ADB
USB

当我跑完步,我谈些什么 – 5

突然发现,长跑时,到了跑得很累,大家都开始坚持的那个阶段,其中一些人,会产生很强烈的精神涣散 or 注意力减退。平时在操场跑道、路况很好、或者很熟悉的线路上,还不明显;到了陌生的、情况复杂的地方,就格外明显。他们会忽略路面上的凸起,甚至下台阶的时候都会数错,各种被绊到;在行人众多的地方,也不能及时地发现和躲避,出现在他们轨迹前方的行人,经常直直地撞上去。于是一起跑步的我,需要分出一缕心神,不时地提醒对方。

这些状况,在我身上很少出现。即使跑的很累了,我也在眼观六路耳听八方。——我觉得这不是什么先天基因差异,而是相对后天的因素吧。和那些习惯了心无旁骛、而不需要关注周围环境的人相比,我更常有的状态,是意识到自己走在各种陌生的路上,于是每一秒都在警惕有什么状况会发生,从而不允许自己有太多涣散。

也未必一定要用「警惕」这样的视角。通常我在路上,也能比别人更细微地观察着各种角落,发现更多有趣的东西。所以「不涣散」也可以从这种正向的角度去解释。——当然,这几件事哪个是因,哪个是果,我也分不清楚。

另一方面,那些能够随便就让自己跑到精神涣散的人,成绩、训练效果、进步速度……比我要好一些。当然这里面也存在幸存者效应。其中一些人,在旁边没人照料的时候,动不动就扭到脚、撞到人,受伤休息几个月;甚至伤情更严重一些,永远告别跑步这项运动。但幸存的那些人,确实运动效果比我要好。也有人选择从来不在路况不好的地方跑步,就可以一直涣散着跑得很好。——这里面也能看出各种 privilege,对那些能够心里完全不去顾及其它纷扰,单纯地投入地去做事的人,表示羡慕。但(也可能是我的观察样本有问题)这样的人也更偏向「岁月静好」,在自己的世界里,理所当然地不去关心远方的苦难。

老娘与海

Young Woman and the Sea,9.5/10,很好看!虽然不像 Barbie 那么亮眼,但一切中规中矩,关于那个时代的女性遭遇面面俱到,算是教科书式的女性主义励志电影模板了。

专门加一分给片名。官方的译名好像是《泳者之心》;但本来英文名就是在对照海明威的《老人与海》,于是圈子里把电影翻译成《老娘与海》,实在非常有气势!可惜这个词迅速出圈,如今在各个社交网络搜索,搜出来一堆海滩甜美自拍……

顺便看了一些横渡英吉利海峡的资料。考据一下,片中哪些是艺术加工的部分。——这当然不是在指责影片不实;实际上,每一个被巧妙地编织到情节里的,女性的不公遭遇,都让人感受到那个时代(以及现在这个时代)的各种真实。


奥运会。Ederle 并没有从 1924 巴黎奥运会完全铩羽而归,她获得了 4x100m 自由泳接力金牌、100m 和 400m 的自由泳铜牌,——这两场个人赛除了一块银牌,其它奖牌全是美国队。美国算是率先开放女性参加体育运动的第一批国家,以及 1920s 是现代自由泳姿势成型和大放异彩的年代,美国在这方面的研究处于领先地位,在国际赛场上,优势非常大。所以只是 Ederle 自己,相对于她之前的一堆世界记录而言,成绩不太理想。旅途中女性不方便训练,可能确实存在;但以此作为奥运会失败的原因,大概是艺术加工。

女教练,不存在的……Ederle 早期的竞技教练 Louis Handley 是男性,曾多次指导美国女游泳选手获得金牌。在上一条所说的自由泳技术革新和推广方面,贡献也很大。片中几次提到蛙泳和自由泳之间的选择,也与此有关。

反派男教练,是存在的,当然没有下毒那么夸张。Ederle 最初的教练是苏格兰人 Jabez Wolffe,1921 年之前 22 次尝试横渡失败(考虑早年英伦排斥自由泳姿的背景,此人大概确实是蛙泳的鼓吹者),之前也发表过女性无法横渡的言论,在 Ederle 第一次尝试横渡途中休息时,让人把她救起,导致 Ederle 丧失资格,事后 Ederle 对此强烈不满。也有人说这些都是传言,真伪不可考。

Ederle 溜下船迅速进行第二次横渡,是艺术加工。第一次尝试失败发生在 1925.8.18,和最终的成功 1926.8.6 间隔一年,而不是电影中的几天。而且两次的后援、赞助、家庭支持,都很充分。父亲还许诺成功了买辆红色跑车……

以及当时正值无线电技术发展,Ederle 的横渡似乎是第一次「现场直播」,后援船实时用电报传回最新情况,于是听众数量剧增。成功后纽约的盛大游行,也与此有关。

早期的横渡活动,每一次纪录的刷新,和对水文熟悉、路线的创新,关系非常大。前三个横渡成功的男人都是从英国游到法国(蛙泳),1923 年连续两人从法国游到英国,一下子把纪录提高了五小时(从 21:45 到 16:23),难度降低了很多,——后面的第 4~18 名成功者,全是从法国到英国方向。于是挑战横渡再一次成为热潮,一群人都来 Cap Gris-Nez 尝试新的方向,但因为对洋流的不熟悉,都废掉了。三年后女主成为第 6 个成功者(14:39),成绩大幅度提高 2 个小时。教练 Bill Burgess 对路线的选择功不可没。—— Bill 在 1911 年成为第二个横渡成功者,也是第 5 6 14 15 16……名成功者的教练或引航员。

在 Ederle 成功之后一个月,这条线路又立刻被男人们刷出 12:43 11:06 13:57,而女性纪录直到 1950 年才被人打破。

水里吃鸡腿是真的 ^^ 补给船带了鸡腿、橙子、蔬菜鸡汤。之前有的成功者,只是下水前吃了顿火腿大餐,在水里只用糖块补充能量。

浅滩迷路和篝火指路,虽然看的很飙泪,但当然也是艺术加工了。现实中不可能和后援船脱离的。传说第一个迎接 Ederle 上岸的,是英国移民局官员来查护照。这个段子在片中也有体现。

上岸后 Ederle 的样子很惨的。「被水击打的全身青紫,脸像个拳击手,盐水作用导致舌头肿胀严重,几乎不能言语,还被水母刺伤」。——很多横渡者都有被水母蛰伤的经历,但只是海上偶尔遇到的几只。故意穿越水母群,这个太艺术了,土澳群众看着瑟瑟发抖……

分体泳衣是真的。20 世纪初的女性泳衣是…羊毛连衣裙……,也确实有女性因为露腿的泳衣,被警察逮捕过(影片中有展现)。Ederle 第一次尝试时,穿的是一件会磨伤皮肤的连体泳装;而第二次成功时,把那件连体泳装,剪成了两件式。

Gertrude Ederle 并不是最先尝试横渡英吉利海峡的女性。这个网站上列出了所有尝试者的名单,上面有很多标着 Miss Mrs 的女性,前赴后继,20 多年才有人成功。而 Ederle 的成功,也激励了更多的女性来尝试,之后的几年,女性横渡成功者的人数,超越了男性。

運動無國界,嗎?

🎥 點擊封面播放視頻

由一個提問開始,我從設計師與創作的角度,談論體育運動中的民族主義,警惕「分類」思維對思考過程的影響。

今日戶外步行運動記錄:開發了一條四分馬的路線!

🎥 B站播放地址:https://www.bilibili.com/video/BV1yv421k7Mg/

🎥 YouTube 播放地址:https://youtu.be/w2KQoic8LAg

這是春節過後的第一條視頻,主要是起個頭跟大家聊聊天。如果你有任何想法,歡迎在視頻中的彈幕或評論區里和其他人一起理性討論。

❌