Nie wiem jak indeksować i przeszukiwać Registred_Date (Zawiera datetime formatu sql). Muszę szukać między latami lub dniami. Gdzie używam zapytania boolowskiego dla wyszukiwania. Poniższy kod jest używany do pola liczbowego i zwykłe indeksowanie pól.Jak indeksować i przeszukiwać pole Datetime w Lucene.NET?
IndexWriter indexWriter = new IndexWriter(dir, new StandardAnalyzer(),Lucene.Net.Index.IndexWriter.MaxFieldLength.UNLIMITED);
DataSet ds = new DataSet();
//ds contains table
if (ds.Tables[0] != null)
{
DataTable dt = ds.Tables[0];
if (dt.Rows.Count > 0)
{
foreach (DataRow dr in dt.Rows)
{
//Create the Document object
Document doc = new Document();
foreach (DataColumn dc in dt.Columns)
{
string check = dc.ToString();
if (check.Equals("Experience"))
{
int n=Convert.ToInt32(dr[dc.ColumnName]);
NumericField numericField = new NumericField(dc.ColumnName, Field.Store.YES, true);
numericField.SetIntValue(n);
doc.Add(numericField);
}
else if(check.Equals("Registred_Date"))
{
}
else
{
doc.Add(new Field(dc.ColumnName, dr[dc.ColumnName].ToString(), Field.Store.YES, Field.Index.ANALYZED));
}
//Populate the document with the column name and value from our query
}
// Write the Document to the catalog
indexWriter.AddDocument(doc);
}
}
}
// Close the writer
indexWriter.Close();
sprawdzić w ten sposób: [Lucene.Net: Jak mogę dodać filtr datę moich wynikach wyszukiwania?] (Http: // stackoverflow .pl/pytania/4565303/lucene-net-how-can-i-dodaj-a-filtr daty do moich wyników wyszukiwania? answerertab = głosów # tab-top) –