lucene.netで記事を閲覧しています。lucene.netを使用してインデックスを作成するためのサンプルコードをいくつか入手しましたが、数行のコードがわかりません。ここにそれらの行があります
protected void btnCreateIndex_Click(object sender, EventArgs e)
{
IndexWriter writer = new IndexWriter(MapPath("~/searchlucene/"), new StandardAnalyzer(), false);
IndexDocument(writer, "About Hockey", "hockey", "Hockey is a cool sport which I really like, bla bla");
IndexDocument(writer, "Some great players", "hockey", "Some of the great players from Sweden - well Peter Forsberg, Mats Sunding, Henrik Zetterberg");
IndexDocument(writer, "Soccer info", "soccer", "Soccer might not be as fun as hockey but it's also pretty fun");
IndexDocument(writer, "Players", "soccer", "From Sweden we have Zlatan Ibrahimovic and Henrik Larsson. They are the most well known soccer players");
IndexDocument(writer, "1994", "soccer", "I remember World Cup 1994 when Sweden took the bronze. we had great players. players , bla bla");
IndexDocument(writer, "BBA-header", "BBA-321type", "Hello BBA");
writer.Optimize();
writer.Close();
}
private void IndexDocument(IndexWriter writer, string sHeader, string sType, string sContent)
{
Document doc = new Document();
doc.Add(new Field("header", sHeader, Field.Store.YES, Field.Index.TOKENIZED));
doc.Add(new Field("type", sType, Field.Store.YES, Field.Index.TOKENIZED));
doc.Add(new Field("content", sContent, Field.Store.YES, Field.Index.TOKENIZED));
writer.AddDocument(doc);
}
いくつか質問があります
1)doc.Add(new Field( "header"、sHeader、Field.Store.YES、Field.Index.TOKENIZED)); この行の意味は何ですか。Field.Index.TOKENIZED TOKENIZED&UNTOKENIZEDとは?? タイプ引数で指定されたキーワードを検索すると、何も表示されません。行動を理解していないだけです
これは、タイプとしてインデックスであったキーワードを指定する検索のサンプルです。
ListBox1.Items.Clear();
var searcher = new Lucene.Net.Search.IndexSearcher(MapPath("~/searchlucene/"));
var oParser = new Lucene.Net.QueryParsers.QueryParser("content", new StandardAnalyzer());
string sHeader = " OR (header:" + TextBox1.Text + ")";
string sType = " OR (type:" + TextBox1.Text + ")";
string sSearchQuery = "(" + TextBox1.Text + sHeader + sType + ")";
var oHitColl = searcher.Search(oParser.Parse(sSearchQuery));
for (int i = 0; i < oHitColl.Length(); i++)
{
Document oDoc = oHitColl.Doc(i);
ListBox1.Items.Add(new ListItem(oDoc.Get("header") + oDoc.Get("type") + oDoc.Get("content")));
}
searcher.Close();
誰かが私の混乱を追い払うために私が理解するのを手伝ってください。ありがとう