A couple of things:
Index entry names cannot be nested. Even though the document has structure, the index is flat. To compensate for this, Raven uses the convention of replacing periods with underscores. So in your index definition, you have to name your field
Origin_Name
to match.Origin_Name = item.Origin.Name
There's hardly ever a need to include the
Id
in the index map. It is handled differently behind the scenes, so it's included by default.You don't need a
Result
class in this scenario, because you aren't storing these fields or using them in a map/reduce.If you plan on doing a partial match, or a search, then having the fields analyzed is fine. If you are only doing a whole string match, then you shouldn't analyze the fields.
You should combine your
Where
queries into a single clause:.Where(n => n.Name == name && n.Origin.Name == origin)
Alternatively, you can use the Intersection Queries feature:
.Where(n => n.Name == name) .Intersect() .Where(n => n.Origin.Name == origin)
This particular query is simple enough that if you wanted you could omit the static index and Raven would create one for you automatically.