开发者

lucence search all? with QueryParser

Here's part of my code. Instead of searching the text in desc i'd like to search in everything (desc, title, example, etc). How do i do this? do i make another field call all and copy each field into it? can i do something like "", null or "*" to denote search them all? (I tried each and got no results).

How do i search all fields with my text?

public static List<Pair<long, float>> Search(string text)
{
    var searcher = new IndexSearcher(directory, true);
    var parser = new QueryParser(Lucene.Net.Util.Version.LUCENE_29, "desc", analyzer);
    var query = parser.Parse(text);
    var hits = searcher.Sear开发者_JAVA百科ch(query);
    // etc
}


It would be good if lucene implicitly supported the notion of "all". You are left with indexing 1 additional filed (name it as "all") whose contents will be a concatenation of desc, title, example etc but do not store it, just index.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜