What operators or wildcards is my PDF search using?

I’m trying to search the PDF below. I want to search for the sentence / phrase:

“This essay is a primer on the underlying principles and mechanics of non-coercive marketing. It’s meant to be a high-level overview that contrasts traditional marketing with the non-coercive approach. I won’t be getting into implementation details or examples here, but rest assured that’s all coming soon. I’ve been integrating this into my business throughout 2022, and the early results are promising.”

When searching this phrase (with quotes) it finds it when I have “Enabled operators and wildcards” switched on. It does not find the string when this option is switched off. I know there are probably linebreaks in the PDF text layer, but I’m not sure how / why these correlate with the setting for operators / wildcards. What wildcards or operators are actually used in a search string enclosed in quotes?

Non-Coercive Marketing- A Primer.pdf (737.6 KB)

I’m specifically asking, because I’m trying to search for this string using the ?search= parameter. As @cgrunenberg mentions here operators are not supported. But my idea was I actually wasn’t / aren’t using any operators. But apparently I am?

Hope you can enlighten me if I’m actually using operators or something else is going on :wink: Thanks!

Why are you trying to search for a paragraph of text? That’s quite unusual.

PS: I had no issue with a text search…

I’m automatically linking paragraphs (via a JS function) from my Annotations file (which contains text I have selected in the PDF and copy-pasted to the Annotations file). It allows me to go straight to the highlight from the Annotations file.

I also have no problem with the search in your screenshot, that’s exactly what I want. The problem is that when I want to use a x-devonthink-item://UUID?search=Paragraph%20text type of link, the Operators & Wildcards are not ‘switched on’ (as @cgrunenberg noted earlier) and the search does not work. Although it seems like it is just a string search as all the text is ‘connected’. But possibly the Operators & Wildcards are doing here some magic in relation to spaces or newlines?

P.S. to try what I mean, switch off the checkbox with Operators & Wildcards and the search does not deliver a result anymore.

@cgrunenberg would have to weigh in on this.

How does the full link look like currently? I just used the first two words of the phrase successfully. As the search is a simple plain string search and as the full paragraph contains linebreaks, I wonder whether these were properly encoded.

This is the string:

This essay is a primer on the underlying principles and mechanics of non-coercive marketing. It's meant to be a high-level overview that contrasts traditional marketing with the non-coercive approach. I won't be getting into implementation details or examples here, but rest assured that's all coming soon. I've been integrating this into my business throughout 2022, and the early results are promising.

This is the link used (encoded by encodeURIComponent in JS):

x-devonthink-item://FF90DDC8-4BC5-443D-AF23-8DCB1E33168F?search=This%20essay%20is%20a%20primer%20on%20the%20underlying%20principles%20and%20mechanics%20of%20non-coercive%20marketing.%20It's%20meant%20to%20be%20a%20high-level%20overview%20that%20contrasts%20traditional%20marketing%20with%20the%20non-coercive%20approach.%20I%20won't%20be%20getting%20into%20implementation%20details%20or%20examples%20here%2C%20but%20rest%20assured%20that's%20all%20coming%20soon.%20I've%20been%20integrating%20this%20into%20my%20business%20throughout%202022%2C%20and%20the%20early%20results%20are%20promising.

P.S. when switching off the Operators & Wildcards checkbox in the regular DT search the string also does not deliver a result, that’s why I presumed it needed to have that switched on…

The linebreaks were replaced with spaces (%20) actually. E.g. this link should work:

x-devonthink-item://FF90DDC8-4BC5-443D-AF23-8DCB1E33168F?search=This%20essay%20is

Ah, that would indeed be possible. Dumb of me to not have checked that myself. I think a part of the link you tried to post is missing?

No, this was just a short example of a valid & working link.

Hmm, but I might have looked too soon. In the example string no linebreaks are found right? The string I posted works fine as one line search with spaces and no linebreaks (surrounded with quotes):

Except when switching off ‘Enable Operators & Wildcards’

But I agree that in the original text layer (see PDF posted earlier in this thread) linebreaks are apparent. But apparently the Operators & Wildcards function is helping that those don’t pose a problem when searching?

But the paragraph in the document contains linebreaks, therefore the search fails. It’s an exact string search. Item links don’t use any operators or quotes etc.

Indeed. Which begs the question: how is DT actually delivering a result when I’m pasting a single line search phrase with spaces (no linebreaks)? Is the wildcards/operator doing some magic?

On your screenshot it’s enabled, that’s the difference. Without this option the inspector wouldn’t find it either.

So that options is making DT more lenient on searching (e.g. also accepting spaces where linebreaks are actually present)?

It is. In your case the easiest fix is either to properly encode the string or to just use the first few words, a longer string is rarely ever necessary.

1 Like

That’s a great workaround - I will implement that in my code.

I’ve been trying to implement this. It works mostly fine as long as I higlight lines at the start of the line. When I e.g. start highlight text at the end of a line, where the first word of the highlight is immediately followed by a linebreak, it still will not work (obviously). Would a more lenient string search (especially allowing line breaks) be possible for the search parameter in the future?

As an example: I’m trying to link the search parameter to the phrase “vision in sound design” which cannot be found because it contains a line break. It can be found with the phrase in quotes and “Enable Operators & Wildcards” selected. Having that (enclosed in quotes, operator functionality enabled) for simple string searches would be very helpful.