Skip to content

Instantly share code, notes, and snippets.

@NathanGloyn
Created September 13, 2012 10:09
Show Gist options
  • Save NathanGloyn/3713359 to your computer and use it in GitHub Desktop.
Save NathanGloyn/3713359 to your computer and use it in GitHub Desktop.
Raven query
[HttpPost]
public ActionResult Create(Create_Album album)
{
if(ModelState.IsValid)
{
var newAlbum = new Album();
newAlbum.Genre = session.Load<Genre>(album.GenreId);
newAlbum.Title = album.Title;
newAlbum.CountSold = album.CountSold;
newAlbum.Price = album.Price;
newAlbum.Artist = session.Query<Artist>("Artists").First(s => s.Id == album.ArtistId);
session.Store(album);
return View("Index");
}
return View(album);
}
@mattwarren
Copy link

Huh, seems like you've found a bug, I've done a small repo and for a workaround change line #11 to this:

newAlbum.Artist = session.Advanced.LuceneQuery("Artists").Where("Id:" + album.ArtistId).FirstOrDefault();

It seems like Raven is being too clever and changing the name of Id to "__document_Id", which is why you get the error "__document_id" is not indexed, cannot query on fields that are not indexed"?!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment