当前位置: 首页>>代码示例>>C#>>正文


C# QueryParser.SetLocale方法代码示例

本文整理汇总了C#中Lucene.Net.QueryParsers.QueryParser.SetLocale方法的典型用法代码示例。如果您正苦于以下问题:C# QueryParser.SetLocale方法的具体用法?C# QueryParser.SetLocale怎么用?C# QueryParser.SetLocale使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Lucene.Net.QueryParsers.QueryParser的用法示例。


在下文中一共展示了QueryParser.SetLocale方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Index

        public ActionResult Index(Models.Search model)
        {
            if (!string.IsNullOrEmpty(model.Phrase))
            {

                //// Use this style query to search for documents - it returns all results
                //// including those matching only some of the terms
                //Query query = new QueryParser(
                //        Lucene.Net.Util.Version.LUCENE_29,
                //        "title",
                //        new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_29)
                //    ).Parse(model.Phrase);

                // Use this style query for products - all of the terms entered must match.
                QueryParser parser = new QueryParser(
                        Lucene.Net.Util.Version.LUCENE_29,
                        "title",
                        new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_29)
                    );

                //ISynonymEngine engine = new SpecialSynonymEngine();

                //// Same as above, but modified to handle synonyms
                //QueryParser parser = new QueryParser(
                //        Lucene.Net.Util.Version.LUCENE_29,
                //        "title",
                //        new SynonymAnalyzer(Lucene.Net.Util.Version.LUCENE_29, engine)
                //    );

                // This ensures all words must match in the phrase
                parser.SetDefaultOperator(QueryParser.Operator.AND);

                // This ensures similar words will match
                //parser.SetPhraseSlop(3);

                // Sets the current culture
                parser.SetLocale(System.Threading.Thread.CurrentThread.CurrentCulture);
                Query query = parser.Parse(model.Phrase);

                // Use query.Combine to merge this query with individual facets ??

                //// Get the terms from the query
                //string[] terms = model.Phrase.Split(" ".ToCharArray());

                //PhraseQuery query = new PhraseQuery();
                //query.SetSlop(4);

                //foreach (var term in terms)
                //{
                //    query.Add(new Term("title", term));
                //}

                BrowseResult result = this.PerformSearch(query, this.IndexDirectory, null);

                //// Build results for display
                //int totalHits = result.NumHits;
                //BrowseHit[] hits = result.Hits;

                //model.Hits = result.Hits;
                //model.FacetMap = result.FacetMap;
                ////model.TotalHitCount = totalHits;

                PopulateModelResult(model, result);
            }

            return View(model);
        }
开发者ID:NightOwl888,项目名称:FacetedSearchPrototype,代码行数:67,代码来源:SearchController.cs

示例2: AssertHits

		private void  AssertHits(int expected, System.String query, IndexSearcher is_Renamed)
		{
			QueryParser qp = new QueryParser("date", new WhitespaceAnalyzer());
			qp.SetLocale(new System.Globalization.CultureInfo("en-US"));
			Query q = qp.Parse(query);
			ScoreDoc[] hits = is_Renamed.Search(q, null, 1000).ScoreDocs;
			Assert.AreEqual(expected, hits.Length);
		}
开发者ID:Mpdreamz,项目名称:lucene.net,代码行数:8,代码来源:TestQueryParser.cs

示例3: SubmitSearchSelections

        public ActionResult SubmitSearchSelections(Models.Search model)
        {
            // Use this style query for products - all of the terms entered must match.
            QueryParser parser = new QueryParser(
                    Lucene.Net.Util.Version.LUCENE_29,
                    "title",
                    new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_29)
                );

            // This ensures all words must match in the phrase
            parser.SetDefaultOperator(QueryParser.Operator.AND);

            // This ensures similar words will match
            //parser.SetPhraseSlop(3);

            // Sets the current culture
            parser.SetLocale(System.Threading.Thread.CurrentThread.CurrentCulture);
            Query query = parser.Parse(model.Phrase);

            // Use query.Combine to merge this query with individual facets

            BrowseResult result = this.PerformSearch(query, this.IndexDirectory, model.SelectionGroups);

            //// Build results for display
            //int totalHits = result.NumHits;
            //BrowseHit[] hits = result.Hits;

            //model.Hits = result.Hits;
            //model.FacetMap = result.FacetMap;
            ////model.TotalHitCount = totalHits;

            PopulateModelResult(model, result);

            return Json(model, "application/json");

            //return View("Index", new Models.Search());
        }
开发者ID:NightOwl888,项目名称:FacetedSearchPrototype,代码行数:37,代码来源:SearchController.cs


注:本文中的Lucene.Net.QueryParsers.QueryParser.SetLocale方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。