static void Main() { var bag = new LuceneBag(@"C:/LuceneIndexFolder"); MakeIndex(bag); Predicate pred = bag.CreateQuery("Nome", "fernando"); var result = bag.Search(pred, 40); }
public static void MakeIndex(LuceneBag bag) { DataTable dt = GetData(); foreach (DataRow row in dt.Rows) { string id = row["Id"].ToString(); string nome = row["Nome"].ToString(); var fieldId = new KeyValuePair<string, string>("Id", id); var fieldNome = new KeyValuePair<string, string>("Nome", nome); var creator = new IndexCreator(); creator.AddDocument(fieldId, FieldIndexOption.No, FieldStore.Yes); creator.AddDocument(fieldNome, FieldIndexOption.Analyzed, FieldStore.Yes); creator.Save(bag); } bag.CreateIndex(); }
public void Save(LuceneBag bag) { bag.Writer.AddDocument(this.doc); }