색인을 생성하고 검색하는 방법을 모르겠습니다 (SQL 형식 datetime 포함). 연도 또는 요일 사이를 검색해야합니다. 검색을 위해 부울 쿼리를 사용하고 있습니다. 아래 코드는 숫자 필드 일반 필드 인덱싱. 당신은 표준 문자열로 색인을 저장한다면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();
확인이 : [Lucene.Net : 내 검색 결과에 날짜 필터를 추가 할 수 있습니까?] (HTTP : // 유래 인덱싱
.com/questions/4565303/lucene-net-how-can-add-a-date-filter-to-my-search-results? answertab = votes # tab-top) –