Search

Searching notes and note metadata


Search Basics

Performing a basic search of a user’s Evernote account involves three steps:

  1. An instance of NoteFilter
  2. A call to NoteStore.findNotesMetadata
  3. A subsequent call to NoteStore.getNote for any notes that match the search.

NoteFilter offers several members that can be populated depending on the type of results you’re looking for:

  • words — send a text-based search query (e.g.,“notebook:foo tag:bar”).
  • notebooksGuid — restrict the search results to a single notebook identified using it’s Notebook.guid value.
  • tagGuids — limit your search results to only those notes that are assigned these tags (represented as a collection of Tag.guid strings).
  • inactive — marking this member as true will return only inactive notes (notes in the Trash, in other words). If left as false — the default value — only active notes will be returned.

NoteStore.findNotesMetadata takes five parameters, in this order:

  1. A valid auth token (a developer token will also work here)
  2. An instance of NoteFilter
  3. The offset, or index of the first result within all possible results. This is used for retrieving a large number of results using successive calls to findNotes.
  4. The number of notes to be retrieved in this request. If there are fewer matching notes than requested, all matching notes will be returned.
  5. An instance of NotesMetadataResultSpec, which allows the user to define which information should be returned for each matching note. Essentially, this object's members are all boolean values (see the linked page for more details).

If we wanted to retrieve the titles of the 100 newest notes in an account, our code might look like this:

As you can see, we create an instance of NoteFilter and set the ascending member to False (so the results are returned in descending order), set our offset to 0 and our limit to 100. If this query results in less than 100 notes, all matching notes will be returned. By setting includeTitle to True in our instance of NotesMetadataResultSpec (and leaving the remaining values as False), we ensure that unnecessary data isn't returned.

findNotesMetadata returns a type we haven’t yet seen: NotesMetadataList. Feel free to peruse the documentation for this type if you want to learn about everything it contains. In this example, we want to see which notes are returned — those can be find by querying NotesMetadataList.notes:

When run, that code will echo the GUID and title of each matching note to the console.

Downloading entire notes

After using NoteStore.findNotesMetadata to identify which note or notes you'd like to download in their entirety, you can call NoteStore.getNote, which returns an instance of Types.Note, for each note to download the note body, attached files (Resources), and recognition information.

Stay on top of what's happening in the Evernote developer community.