mostly
people don't post their hole project. so you don't have to run
it...(at least for my project)
about b) and c) options i don't have anything to say.
whatever...
thanks anway for your reply =)
On 17.11.2010 21:24, Nicholas Paldino [.NET/C# MVP] wrote:
Note by digestible, I mean, the ability to put it into a project and
run with it. The reasons being:
a) line numbers (making the code not able to be compiled)
b) windows forms project
c) assumption of certain paths existing
It's extra effort to get people to reproduce and reduces the
likelihood of people pitching in on the answer as a result.
Note, none of these are huge barriers, but it makes it difficult to
just copy the code, dump it in a file and run with it.
- Nick
-----Original Message-----
From: Granroth, Neal V. [mailto:neal.granr...@thermofisher.com]
Sent: Wednesday, November 17, 2010 2:52 PM
To: lucene-net-dev@lucene.apache.org
Subject: RE: need some help =)
Why not digestible? This type of question with clear short source code is
most likely to be answered.
- Neal
-----Original Message-----
From: Nicholas Paldino [.NET/C# MVP] [mailto:casper...@caspershouse.com]
Sent: Wednesday, November 17, 2010 1:33 PM
To: lucene-net-dev@lucene.apache.org
Subject: RE: need some help =)
Why are you adding the bytes as the field value? You should add the
fields as strings and you should be fine.
Also, note that most people won't respond to this kind of code
because it is not easily digestable.
-----Original Message-----
From: asmcad [mailto:asm...@gmail.com]
Sent: Wednesday, November 17, 2010 3:02 PM
To: lucene-net-dev
Subject: need some help =)
it's a simple index and search application but i couldn't make it work.
it doesn't give any error but it doesn't give any results too.
1.
using System;
2.
using System.Collections.Generic;
3.
using System.ComponentModel;
4.
using System.Data;
5.
using System.Drawing;
6.
using System.Linq;
7.
using System.Text;
8.
using System.Windows.Forms;
9.
using Lucene.Net;
10.
using Lucene.Net.Analysis.Standard;
11.
using Lucene.Net.Documents;
12.
using Lucene.Net.Index;
13.
using Lucene.Net.QueryParsers;
14.
using Lucene.Net.Search;
15.
using System.IO;
16.
17.
namespace newLucene
18.
{
19.
public partial class Form1 : Form
20.
{
21.
public Form1()
22.
{
23.
InitializeComponent();
24.
}
25.
26.
private void buttonIndex_Click(object sender, EventArgs e)
27.
{
28.
IndexWriter indexwrtr = new
IndexWriter(@"c:\index\",new StandardAnalyzer() , true);
29.
Document doc = new Document();
30.
string filename = @"fer.txt";
31.
Lucene.Net.QueryParsers.QueryParser df;
32.
33.
34.
35.
System.IO.StreamReader local_StreamReader = new
System.IO.StreamReader(@"C:\z\fer.txt");
36.
string file_text = local_StreamReader.ReadToEnd();
37.
38.
System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
39.
doc.Add(new
Field("text",encoding.GetBytes(file_text),Field.Store.YES));
40.
doc.Add(new
Field("path",encoding.GetBytes(@"C:\z\"),Field.Store.YES));
41.
doc.Add(new Field("title",
encoding.GetBytes(filename), Field.Store.YES));
42.
indexwrtr.AddDocument(doc);
43.
44.
indexwrtr.Optimize();
45.
indexwrtr.Close();
46.
47.
}
48.
49.
private void buttonSearch_Click(object sender, EventArgs e)
50.
{
51.
IndexSearcher indxsearcher = new
IndexSearcher(@"C:\index\");
52.
53.
QueryParser parser = new QueryParser("contents", new
StandardAnalyzer());
54.
Query query = parser.Parse(textBoxQuery.Text);
55.
56.
//Lucene.Net.QueryParsers.QueryParser qp = new
QueryParser(Lucene.Net.QueryParsers.CharStream
s).Parse(textBoxQuery.Text);
57.
Hits hits = indxsearcher.Search(query);
58.
59.
60.
for (int i = 0; i< hits.Length(); i++)
61.
{
62.
63.
Document doc = hits.Doc(i);
64.
65.
66.
string filename = doc.Get("title");
67.
string path = doc.Get("path");
68.
string folder = Path.GetDirectoryName(path);
69.
70.
71.
ListViewItem item = new ListViewItem(new string[]
{ null, filename, "asd", hits.Score(i).ToString() });
72.
item.Tag = path;
73.
74.
this.listViewResults.Items.Add(item);
75.
Application.DoEvents();
76.
}
77.
78.
indxsearcher.Close();
79.
80.
81.
82.
83.
}
84.
}
85.
}
thanks