in Education by
i am just browsing article on lucene.net. i got some sample code for create index using lucene.net and few lines of code is not clear to me. here is those line 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); } i have couple of question 1) doc.Add(new Field("header", sHeader, Field.Store.YES, Field.Index.TOKENIZED)); what is the meaning of this line. Field.Index.TOKENIZED what is TOKENIZED & UNTOKENIZED?? when i search keyword specified in type argument then nothing is coming. just do not understand the behaviour here is sample for search where i specify a keyword which was index as type 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(); please someone help me to understand to drive out my confusion. thanks JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
I just tested your code, and it works fine with Lucene 2.9.4. Field.Index.TOKENIZED means the Analyzer will break your text in tokens, meaning it will be searchable in full-text. You would use UN_TOKENIZED for fields you dont want analyzed, like product IDs. Note: you should use Field.Index.ANALYZED and Field.Index.NOT_ANALYZED which are the replacements for their deprecrated TOKENIZED/UN_TOKENIZED counterparts. To see differences between analyzed and not, you can try both and use Luke to inspect your indexes, that will probably give you a good idea of how it works. http://code.google.com/p/luke/

Related questions

0 votes
    Which is true regarding BFS (Breadth First Search)? (a) BFS will get trapped exploring a single path (b) ... is nothing but Binary First Search Please answer the above question....
asked Oct 6, 2022 in Education by JackTerrance
0 votes
    Which is true regarding BFS (Breadth First Search)? (a) BFS will get trapped exploring a single path (b) ... is nothing but Binary First Search Please answer the above question....
asked Oct 2, 2022 in Education by JackTerrance
0 votes
    Which is true regarding BFS (Breadth First Search)? (a) BFS will get trapped exploring a single path (b) ... is nothing but Binary First Search Please answer the above question....
asked Sep 23, 2022 in Education by JackTerrance
0 votes
    I'm coding a basic portfolio page in ASP.NET Core Razor Pages. I want to have a contact form at ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 9, 2022 in Education by JackTerrance
0 votes
    What is Fit and finish features in C#.Net?...
asked Dec 30, 2020 in Technology by JackTerrance
0 votes
    How do I implement a Copy menu item in a Windows application written in C#/.NET 2.0? I want to ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 29, 2022 in Education by JackTerrance
0 votes
    Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. Want ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 19, 2022 in Education by JackTerrance
0 votes
    Is anyone using the Obout controls in C# .Net? How would you rate these controls, especially the Grid ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 11, 2022 in Education by JackTerrance
0 votes
    I have a navigation bar consisting of list items. Right at the end of the nav bar I want a ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 4, 2022 in Education by JackTerrance
0 votes
    is it possible to call c# methods written in managed code (maybe in a class or a library) from a ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 25, 2022 in Education by JackTerrance
0 votes
    What is Garbage Collection in C#.Net?...
asked Jul 27, 2021 in Technology by JackTerrance
0 votes
    What is Reflection in C#.Net?...
asked Jul 27, 2021 in Technology by JackTerrance
0 votes
    What is File Handling in C#.Net?...
asked Apr 1, 2021 in Technology by JackTerrance
0 votes
    What is Pattern matching enhancements in C#.Net?...
asked Dec 30, 2020 in Technology by JackTerrance
0 votes
    What is Top-level statements in C#.NET?...
asked Dec 30, 2020 in Technology by JackTerrance
...