Jump to content

Searching for phrases within a note


Go to solution Solved by PinkElephant,

Recommended Posts

I’m trying to search for phrases in a single note. This has to be a simple answer, but I only get single words in my results.  I’m running the latest Evernote updates on a Mac.  I’ve tried putting parentheses around a phrase in the search bar, but it doesn’t return any result. 
 

I would appreciate your feedback.  
Thank you! 

Link to comment
  • Level 5
  • Solution

The simple answer is: You can’t search for an exact match of a whole sentence. The reason behind it is how the search index is build. EN explains it in a document about the advanced search grammar, but in short they convert the text in a document into a list of words. The sentence is not searchable, because it does not exist in the search index.

But you can use the key words from your sentence (skipping words like And, The, It and so on), and it should find the sentence.

Here is the relevant passage from the grammar description ( https://dev.evernote.com/doc/articles/search_grammar.php)  :

The behavior of a quoted search should behave as if the following operations were performed on both the search query and the target note:

  1. All XML markup is removed from the document, leaving only the visible text as a string
  2. The string is converted to a list of words which are separated by one or more whitespace and/or punctuation characters.
  3. The case of each word in the list is normalized
  4. The list of words in the query must match with the same sequence of words in the converted Note

For example, if a user searches for the phrase "Spatula! City! For Bargains..." against this ENML document: 

The algorithm should convert the search phrase into a normalized list of words:

[ "spatula", "city", "for", "bargains" ]

And the document into: 
[ "come", "down", "to", "spatula", "city", "for", "bargains", "on", "spatulas" ]

The search should match, since words from the target phrase are found in the list of words extracted from the document. (The same result could be implemented without literally converting each note into a list of words, but this gives the intended behavior that we see from major search engines like Google and MS.) 

 

  • Like 1
Link to comment
31 minutes ago, PinkElephant said:

The simple answer is: You can’t search for an exact match of a whole sentence.

A small test reveals that you can search for an exact match by connecting the words with a minus sign, for example:  this-is-a-test

  • Thanks 1
Link to comment

I really appreciate the thorough explanation from Pink Elephant!  Your information will be very helpful.

I'm very surprised Evernote doesn't provide an easy solution for searching phrases.  I would think this would  be beneficial and a huge time saver for everyone.

Thanks again,

Steve

Link to comment
  • Level 5

Well, in fact EN search is existing since quite a while. Computing power and disk space was much more expensive then than they are today. The way it is constructed it is saving a lot of space, and makes for a fast search. Usually a word will show up several times in a document, especially when case normalized (which means only the word core is stored, without differing endings).

The word will show only once, and then a list of spots where the word shows up, with their location. It is obvious this is much leaner than an index that as well lists which word stands close to which other - in that case every combination needs to be saved. Words are repetitive - combinations like in a sentence are much less so. This means the index would be bloated, just to allow this one specific search case.

I think they took a decision to go for the simpler index, and write a support text about what works, and what doesn’t.

Link to comment
30 minutes ago, stevebu said:

I really appreciate the thorough explanation from Pink Elephant!  Your information will be very helpful.

I'm very surprised Evernote doesn't provide an easy solution for searching phrases.  I would think this would  be beneficial and a huge time saver for everyone.

Thanks again,

Steve

As I tried to explain, EN does provide a solution for searching phrases, just concatenate the words in the search string with a minus sign,

Search string example:  this-is-a-test

This will find the string: "this is a test" but not "this xxx is a test"

  • Thanks 1
Link to comment
7 hours ago, PinkElephant said:

Cool, it works ! It even works if there is interpunctation in the original string, not typed into the search term.

Did you find it documented anywhere, or is it a dark hack ?

I was inspired by this. EN did a perfect job to make it work in the search string as well 🙂

 

  • Like 1
  • Thanks 1
Link to comment
1 hour ago, Mike P said:

The perhaps more conventional approach of enclosing the phrase in quotation marks also seems to work and gives me identical results to the "hyphen method".

You're right, I tried it myself and it seems to work indeed!

I think we misunderstood the original question: it's probably a search problem in a note, not the database search. Quotes are impossible in a note search indeed. But I still don't understand the problem because the note search always searches for an exact match of the whole search string, no quotes required...

  • Like 1
Link to comment
20 minutes ago, eric99 said:

You're right, I tried it myself and it seems to work indeed!

I think we misunderstood the original question: it's probably a search problem in a note, not the database search. Quotes are impossible in a note search indeed...

Looking again at the original post I think you are right. However just typing the phrase (no quotation marks or hypens) seems to work fine for me. For example searching for data in this note gives me 12 results:

image.thumb.png.e3efa5d3c19c8633e01b1c0319226f43.png

 

Searching for common data gives me just one result as expected.

image.thumb.png.c172b52a954c677f57edebce51f4f036.png

Link to comment
34 minutes ago, Mike P said:

Looking again at the original post I think you are right. However just typing the phrase (no quotation marks or hypens) seems to work fine for me. For example searching for data in this note gives me 12 results:

image.thumb.png.e3efa5d3c19c8633e01b1c0319226f43.png

 

Searching for common data gives me just one result as expected.

image.thumb.png.c172b52a954c677f57edebce51f4f036.png

yeah, I already added that to my message in the mean time 🙂

But then is there any problem at all?

Link to comment
  • 9 months later...
On 3/18/2022 at 5:31 PM, eric99 said:

A small test reveals that you can search for an exact match by connecting the words with a minus sign, for example:  this-is-a-test

Thank you! This worked for me. 

  • Like 1
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...