lucene.netnhibernate.search

Lucene 'join' how-to?


Using Nhibernate.Search at the moment.

Some code for context:

[Indexed]
class foo {
  [DocumentId]
  int id {get;set;}
  bar bar {get;set;}
}

[Indexed]
class bar {
  [DocumentId]
  int id {get;set;}
}

Question:
How to retrieve all foos where foo.bar.id==1 using IFullTextQuery?


Solution

  • If you want to include related information into the foo index you may look into the IndexedEmbeddedAttribute. This will allow you to query for relationships such as if there was a Name property on the bar object you could create a query such as this

    IFullTextQuery query = search.CreateFullTextQuery("bar.Name:Arnis");
    query.List<foo>();