lucenenet-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Granroth, Neal V." <neal.granr...@thermofisher.com>
Subject RE: need some help =)
Date Wed, 17 Nov 2010 20:12:40 GMT
You need to pick a suitable analyzer for use during indexing and for queries.  The StandardAnalyzer
you are using will most likely break the words apart at the non-english characters.

You might want to consider using the Luke tool to inspect the index you've created and see
who the words in your documents were split and indexed.


- Neal

-----Original Message-----
From: asmcad [mailto:asmcad@gmail.com] 
Sent: Wednesday, November 17, 2010 3:06 PM
To: lucene-net-dev@lucene.apache.org
Subject: Re: need some help =)


i solved the problem . now i have non-english character problem.
when i search like something "çşğuı"(i'm not sure you can see this) 
characters. i don't get any results.
how can i solve this ?

by the way sorry about the "content" messing =)

thanks  for the  previous help  =)

On 17.11.2010 20:16, Digy wrote:
>
>     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
>


Mime
View raw message