开发者

lucence search all? with QueryParser

开发者 https://www.devze.com 2023-02-01 13:32 出处:网络
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 int

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

精彩评论

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