0

I am using Lucene indexing for the first time. I have some documents in Hindi and English and I create index on the content of document.When I search the index I get result from all the documents even if my query is some english word it returns hindi document also. I have added the code below.please tell me where I am dong wrong.

        IndexSearcher searcher = new IndexSearcher(directory);
        QueryParser parser = new QueryParser("Content", analyzer);



        while (condition)
        {
            Search(text, searcher, parser);

        }


        searcher.Close();
        private static void Search(string text, IndexSearcher searcher, QueryParse parser)
    {
        Query query = parser.Parse(text);

        Hits hits = searcher.Search(query);
        int results = hits.Length();

        for (int i = 0; i < results; i++)
        {
            Lucene.Net.Documents.Document doc = hits.Doc(i);

            string show = doc.ToString();

            float score = hits.Score(i);

            /* insert doc id in database table*/

            }

Thanks all

4

1 回答 1

0

首先,我会使用Luke来检查我的查询语法是否正确。然后我会检查行为不端的英语单词是否是印地语单词的同形异形词(即与印地语单词拼写相同的英语单词)。

如果您想阻止搜索英文搜索词时出现印地语文档,您需要标记每个文档是英文还是印地语,然后在搜索查询中指定该标记。在查询解析器语法中,这可能如下所示:

ENGLISHSEARCHTERMS +(language:English)

(所有印地语文档的语言字段设置为“印地语”,所有英语文档的语言字段设置为“英语”)。

于 2012-11-02T15:24:02.227 回答