Lucene 'join' how-to?

只愿长相守 提交于 2019-12-12 02:59:23

问题


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?


回答1:


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>();



回答2:


Seems that [IndexedAttribute] is an answer.



来源:https://stackoverflow.com/questions/2295139/lucene-join-how-to

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!