When I was using Lucene to index my entities, I had the habit of putting all my indexed properties in a field named "all", to perform a search on "all" of my entities types.
Now, using NHibernate.Search, I can't find how to do this. I tried this :
[Indexed(Index = "MyIndex")]
public class Post
{
[DocumentId]
public virtual int Id { get; set; }
[IndexedEmbedded]
public virtual Author Author { get; set; }
[IndexedEmbedded]
public virtual IEnumerable<Category> Categories { get; set; }
[Field(Index.Tokenized, Store = Store.Yes)]
[Field(Name = "All", Index = Index.Tokenized, Store = Store.Yes)]
public virtual string Name { get; set; }
[Field(Name = "All", Index = Index.Tokenized, Store = Store.Yes)]
[Field(Index.Tokenized, Store = Store.Yes)]
public virtual string Body { get; set; }
}
But I have an exception thrown : "key already present in dictionary", in ScopedAnalyzer.cs line 26 :
scopedAnalyzers.Add(scope, analyzer);
Where "scope" is the name of the index field (here, "All"). If I put a check like
if( !scopedAnalyzers.ContainsKey( scope ) )
it will work quite well : I will have 2 fields for each "Post" document, one with the body, one with the name. However, I'm not at easy modifying NHibernate.Search source code.
Anyone got a suggestion on how to index different properties in one field ?