LUCENE.NET-如何修复在C#中生成的查询(4个子句“ OR”和多字段中的更多内容)

时间:2018-07-26 18:43:32

标签: c# lucene

使用搜索和多字段中的4个子句中的更多子句来构建查询。

查询生成

{(tittle:g?s* body:g?s* url:g?s*) (tittle:ge?* body:ge?* url:ge?*) (tittle:esg* body:esg* url:esg*) (tittle:esj* body:esj* url:esj*) (tittle:esy* body:esy* url:esy*)}

代码

var a = new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_30);
        var MulField = new MultiFieldQueryParser(Lucene.Net.Util.Version.LUCENE_30, fields, a);
        BooleanQuery BooleanBuild = new BooleanQuery();                        
        foreach (string t in g.terms)
        {
            BooleanBuild.Add(MulField.Parse(t+"*"), Occur.SHOULD);
        }
        TopDocs topDocs = searcher.Search(BooleanBuild, cnf.limitd);
        /*REGEX
        var rq=new RegexQuery(new Term("tittle",@"(j|g|y)h?eh?sh?uh?s(\w)*"));
        TopDocs topDocs = searcher.Search(rq, cnf.limitd);
        */
        List<ObjJSON> docs = new List<ObjJSON>(cnf.limit);

数据输出

Click show image

但还有4个条款

查询

{(tittle:gesus* body:gesus* url:gesus*) (tittle:gésus* body:gésus* url:gésus*) (tittle:gehsus* body:gehsus* url:gehsus*) (tittle:ghesus* body:ghesus* url:ghesus*) (tittle:géhsus* body:géhsus* url:géhsus*) (tittle:ghésus* body:ghésus* url:ghésus*) (tittle:gesus* body:gesus* url:gesus*) (tittle:gesús* body:gesús* url:gesús*) (tittle:gesuhs* body:gesuhs* url:gesuhs*) (tittle:geshus* body:geshus* url:geshus*) (tittle:gesúhs* body:gesúhs* url:gesúhs*) (tittle:geshús* body:geshús* url:geshús*) (tittle:gesus* body:gesus* url:gesus*) (tittle:gezuz* body:gezuz* url:gezuz*) (tittle:gesus* body:gesus* url:gesus*) (tittle:jesus* body:jesus* url:jesus*) (tittle:yesus* body:yesus* url:yesus*)}

输出数据

Click show image

注意:仅执行查询中的4个firt子句。

需要帮助,对不起我的英语。

1 个答案:

答案 0 :(得分:0)

错误是<link href="https://use.fontawesome.com/releases/v5.2.0/css/all.css" rel="stylesheet"/> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="heart"><i class="far fa-heart border-heart"></i></div>中的数字并使用max number class覆盖Multi Field Query并接受Lucene格式的RAW查询来键入查询