Skip to main content

Popularity Report

Total Popularity Score: 0

Loading...
Loading...
Loading...
Loading...
Loading...
Loading...

Rank

Bookmark History

Saved by 6 people (3 private), first by anonymouse user on 2006-09-04


Public Sticky notes

Let‘s go back to the database example above. If we store all of our documents with an id then we can access that field using the id. As long as we called our id field :id we can do this

  index["89721347"]["title"]

Pretty simple huh? You should note though that if there are more then one document with the same id or key then only the first one will be returned so it is probably better that you ensure the key is unique somehow. By setting Index‘s :key attribute to :id, Ferret will do this automatically for you. It can even handle multiple field primary keys. For example, you could set to :key to [:id, :model] and Ferret would keep the documents unique for that pair of fields.

Highlighted by ken