When I used Lucene to index my objects, I was in the habit of putting all my indexed properties in a field called "all" to search on "all" types of objects.
Now, using NHibernate.Search, I cannot 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: "key is already present in the dictionary", in ScopedAnalyzer.cs line 26:
scopedAnalyzers.Add(scope, analyzer);
Where "scope" is the name of the index field (here "Everything"). If I put a check, for example
if( !scopedAnalyzers.ContainsKey( scope ) )
It will work very well: I will have 2 fields for each Mail document, one with a body, one with a name. However, I cannot easily modify the source code of NHibernate.Search.
- , ?