Merge pull request #496 from nicolas-raoul/unit-test-for-issue2907
[mono.git] / mcs / tools / monkeydoc / Monkeydoc / SearchableDocument.cs
1 //
2 //
3 // SearchableDocument.cs: Abstracts our model of document from the Lucene Document 
4 //
5 // Author: Mario Sopena
6 //
7 using Lucene.Net.Documents;
8
9 namespace MonkeyDoc
10 {
11         struct SearchableDocument
12         {
13                 public string title;
14                 public string url;
15                 public string fulltitle;
16                 public string hottext;
17                 public string text;
18                 public string examples;
19
20                 public Document LuceneDoc {
21                         get {
22                                 Document doc = new Document ();
23                                 doc.Add (UnIndexed ("title", title));
24                                 doc.Add (UnIndexed ("url", url));
25                                 doc.Add (UnIndexed ("fulltitle", fulltitle ?? string.Empty));
26                                 doc.Add (UnStored ("hottext", hottext));
27                                 doc.Add (UnStored ("text", text));
28                                 doc.Add (UnStored ("examples", examples));
29                                 return doc;
30                         }
31                 }
32
33                 static Field UnIndexed(System.String name, System.String value_Renamed)
34                 {
35                         return new Field(name, value_Renamed, Field.Store.YES, Field.Index.NO);
36                 }
37
38                 static Field UnStored(System.String name, System.String value_Renamed)
39                 {
40                         return new Field(name, value_Renamed, Field.Store.NO, Field.Index.ANALYZED);
41                 }
42         }
43 }